2008/3/21 Krzysztof Skrzętnicki <[EMAIL PROTECTED]>:
>  ...
>  I'd like to write the following code:
>
>  instance (Ord a) => YOrd a where
>     ycmp x y = case x `compare` y of
>                  LT -> (x,y)
>                  GT -> (y,x)
>                  EQ -> (x,y)
>
>  But i get an error "Undecidable instances" for any type [a].
>  Does anyone know the way to solve this?

The module compiles fine when you add the following pragma's to your module:

{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE UndecidableInstances #-}

See:
http://www.haskell.org/ghc/docs/latest/html/users_guide/type-class-extensions.html#instance-rules
http://www.haskell.org/ghc/docs/latest/html/users_guide/type-class-extensions.html#undecidable-instances

regards,

Bas
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to