News for hackers. Stuff that matters.
Re:What I Wish I Knew When Learning Haskell 2.0 by BasDirks on Thursday April 24, 2014 @11:05AM (#7640719)
This is not idiomatic code. Briefly:

    data Inches = MkInches Double deriving (Eq,Show)
There is newtype for this.

    (MkInches u) \+/ (MkInches v) = MkInches ( u + v )
First two pairs of parens are redundant.

    from_inches_to_cm vin =
        MkCm (vin_as_pure_double * 2.54)
            where
                (MkInches vin_as_pure_double) = vin
Surely you want:

    inchToCm (MkInches x) = MkCm (x * 2.54)
In Haskell we use camelCase.

Besides these fairly trivial mistakes there are simply better approaches for dealing with units.

There are no comments on this comment yet.