
7 Aug
2012
7 Aug
'12
3:12 p.m.
Hi Joey, On Tue, Aug 07, 2012 at 02:13:09PM -0400, Joey Adams wrote:
Are you looking for existential quantification [1]?
data SomeFoo = forall a. Foo a => a
[1]: http://www.haskell.org/ghc/docs/latest/html/users_guide/data-type-extensions...
Thanks! Yes, that looks really nice. :) data A = A deriving Show data B = B deriving Show data C = C deriving Show data Foo = forall a. Show a => MkFoo a (Int -> Bool) instance Show Foo where show (MkFoo a f) = show a hasId foos id = filter (\(MkFoo a f) -> f id) foos *Main> let foos = [MkFoo A (==1), MkFoo B (==2), MkFoo C (==3)] *Main> hasId foos 1 [A] Greetings, Daniel