On Monday 22 April 2002 23:31, Hal Daume III wrote:
> I'd like to be able to define something like
>
> instance Eq a => Coll (-> Bool) a where
>   empty    = \_ -> False
>   single x = \y -> if x == y then True else False
>   union a b = \x -> a x || b x
>   insert s x = \y -> x == y || s y
>
> and the like
>
> However, this seems to be impossible.  Is this the type lambda restriction
> that's been discussed recently on the mailing list?
>
>  - Hal

Hi Hal, 
I'd do it like this, hope it helps.
----------------------------------
module Test where

newtype  BinClass a = BC (a->Bool)


class  Coll c a where
  empty  :: c a
  single :: a->c a
  union  :: c a->c a->c a
  insert :: c a->a->c a

instance Eq a => Coll BinClass a where
    empty    = BC(\_->True)
    single x = BC(\y -> if x == y then True else False)
    union  (BC a) (BC b) = BC(\x -> a x || b x)
    insert (BC s) x      = BC(\y -> x == y || s y)




_______________________________________________
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to