john at repetae.net
Mon Aug 14 12:40:12 EDT 2006
On Mon, Aug 14, 2006 at 12:15:05AM -0400, kahl at cas.mcmaster.ca wrote:
> Unfortunately the relevant prelude functions, like not, &&, all, ...,
> are all written in a way that they don't work for Silliness.
newtype deriving is really great here.
newtype NumberOfBalls = NumberOfBalls Int
now you have a type that works almost the same as Int, you can add,
substract, etc.. on it. but you can't accidentally add one to a plain
Of course, to take the most advantage of this sort of thing, you want to
define your own classes for some shared syntax.
class HasSize a where
size :: a -> Int
class IsEmpty a where
isEmpty :: a -> Bool
newtype IdMap a = IdMap (Map.Map Id a)
and so forth.
John Meacham - ⑆repetae.net⑆john⑈
More information about the Libraries