Bertram Felgenhauer:
> How does
> 
>   class F a where
>       data B a :: *
>       data E a :: *
>       wrap :: B a -> E a
>       unwrap :: E a -> B a
> 
> sound? 'B a' would represent the 'b' in your previous attempt,
> 
>   class F a b | a -> b where
>   ...
> 

I'm with Simon in thinking that this code is suspicious.

For any given call to "wrap" or "unwrap", how is the compiler supposed
to determine which instance to use, given that "a" cannot be uniquely
determined from the type of the function? The same question also applies
to Matthew's original formulation using functional dependencies:

> class G a b | a -> b where
>     data E a :: *
>     wrap :: b -> E a
>     unwrap :: E a -> b

Simon's reformulation doesn't have this problem:

> class G a where
>     data E a :: *
>     wrap :: a -> E a
>     unwrap :: E a -> a

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

Reply via email to