5 ms·
That's why you want newtype Kilogram = Kilogram Double which has no runtime overhead but does enforce the fact the Kilogram is a distinct type.
by jweese 12y ago
That's why you want
newtype Kilogram = Kilogram Double
which has no runtime overhead but does enforce the fact the Kilogram is a distinct type.
- sparkie 12y agoWe probably wanna add to it to make it useful {-# LANGUAGE GeneralizedNewtypeDeriving #-} newtype Kilogram = Kilogram Double deriving (Show, Eq, Ord, Num, Real, Fractional, Floating, ...) And remind ourselves that Haskell is really quite expressive.
- dllthomas 12y agoThough unfortunately can't handle (mass * accel :: Newton) without swapping out the Prelude.