[Haskell-cafe] Possible to automatically determine typeclass
membership?
Ryan Ingram
ryani.spam at gmail.com
Sun Mar 30 21:23:22 EDT 2008
Is it possible in Haskell + GHC extensions to use reflection
techniques to determine typeclass membership? I'm thinking of things
like the following:
Idea 1:
> data MaybeEq a = NoEq a | Eq a => HasEq a
> checkEq :: (some typeclass constraint) => a -> MaybeEq a
(such that checkEq x returns HasEq x if and only if x has an Eq instance.)
Idea 2:
> data HTrue
> data HFalse
> class MaybeEq a b | a -> b
> instance Eq a => MaybeEq a HTrue
> instance (otherwise) => MaybeEq a HFalse
-- ryan
More information about the Haskell-Cafe
mailing list