Not sure it will work... how do you handle 
        Quot (Prod Metres Metres) (Prod Seconds Metres)
or make sure that
        Prod Metres Seconds
is the same as
        Prod Seconds Metres
???


On Aug 26, 10:36, Andreas Rossberg wrote:
> Subject: Re: Units of measure
> Tom Pledger wrote:
> > 
> > Where do units of measure fit into a type system?
> 
> In Haskell this should be quite easy. Off my head I would suggest
> something like
> 
>       class Unit a where
>               unit  :: Float -> a
>               value :: a -> Float
> 
>       newtype Metres  = Metres Float
>       newtype Seconds = Seconds Float
> 
>       instance Unit Metres where
>               unit = Metres
>               value(Metres x) = x
>       instance Unit Seconds where
>               unit = Seconds
>               value(Seconds x) = x
> 
>       newtype Prod a b = Prod Float
>       newtype Quot a b = Quot Float
> 

-- 
Anatoli Tubman <[EMAIL PROTECTED]> - opinions aren't


Reply via email to