ext_83566 ([identity profile] pozorvlak.livejournal.com) wrote in [personal profile] pozorvlak 2007-08-20 08:01 am (UTC)

In Haskell, you're right, you do this by putting every primitive function in its own typeclass.

I think it's a bit harder than that: you'd need a typeclass for every function's interface and every intersection of those interfaces that occurs. So if you had
foo buffy = spoffle buffy (winnow buffy)
bar angel = spodify angel (winnow angel)
then you'd need typeclasses as follows:
class Winnow where
    winnow :: a -> Winnowed a

class Fooable where
    spoffle :: Winnow a => a->(Winnowed a)->(Foo a)

class Barable where
    spodify :: Winnow a => a->(Winnowed a)->(Bar a)

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting