3 ms·
The `dimensional` library doesn't provide this, no. However, it's easy to 'tag' data in Haskell using phantom types. For example, for vectors in reference frame
by cosmic_quanta 2y ago
The `dimensional` library doesn't provide this, no. However, it's easy to 'tag' data in Haskell using phantom types. For example, for vectors in reference frames:
newtype Framed f a = MkFramed (Vector a)
add :: Framed f a -> Framed f a -> Framed f a
add (MkFramed vec1) (MkFramed vec2) = ... add vec1 and vec2
data ReferenceFrame1
data ReferenceFrame2
v1 :: Framed ReferenceFrame1 Double
v1 = ...
v2 :: Framed ReferenceFrame2 Double
v2 = ...
main :: IO ()
main = print $ v1 `add` v2 -- will not type check
There might already be a library to do this
- amelius 2y agoOk, but I'd also want to convert between polar and cartesian coordinates.