On Wed, Nov 23, 2011 at 4:03 PM, Holger Reinhardt <[email protected]> wrote: > You can do this with phantom types, i.e.: >> data Thing a = Thing Stuff >> >> instance Monoid (Thing a) where >> mappend (Thing stuff1) (Thing stuff2) = Thing (stuff1 `mappend` stuff2) >> mempty = Thing mempty >> >> data ID1 >> data ID2 >> >> thing1 :: Thing ID1 >> thing1 = Thing Stuff >> >> thing2 :: Thing ID2 >> thing2 = Thing Stuff >> >> -- will not typecheck: >> f = thing1 `mappend` thing2
Well yes, but the key feature is that the IDs are arbitrary strings. And they're not knowable at compile time, since they are read from user input... _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
