On Thu, 26 Aug 1999, Andreas Rossberg wrote:
> 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
[snip]
> instance (Unit a, Unit b) => Unit(Prod a b) where
> unit = Prod
> value(Prod x) = x
> instance (Unit a, Unit b) => Unit(Quot a b) where
> unit = Quot
> value(Quot x) = x
[snip]
Isn't the issue a bit weirder than this in that you've also got pure
numbers which ought be usable with the same operators (*$,etc) (so that
you don't have to worry as you write the program) but which don't affect
the `unit type' of the thing to which they're applied? (If they don't
vanish you'll get counter-intuitive things like
a +$ a has a different type to 2 *$ a
)
___cheers,_dave______________________________________________________
email: [EMAIL PROTECTED] "He'd stay up all night inventing an
www.cs.bris.ac.uk/~tweed/pi.htm alarm clock to ensure he woke early
work tel: (0117) 954-5253 the next morning"-- Terry Pratchett