[email protected]
[Top] [All Lists]

Re: [Haskell-cafe] type families and type signatures

Subject: Re: [Haskell-cafe] type families and type signatures
From: Manuel M T Chakravarty
Date: Thu, 10 Apr 2008 14:52:10 +1000
Lennart Augustsson:
Let's look at this example from a higher level.

Haskell is a language which allows you to write type signatures for functions, and even encourages you to do it. Sometimes you even have to do it. Any language feature that stops me from writing a type signature is in my opinion broken. TFs as implemented in currently implemented ghc stops me from writing type signatures. They are thus, in my opinion, broken.

The problem of ambiguity is not at all restricted to TFs. In fact, you need neither TFs nor FDs to get the exact same behaviour. You don't even need MPTCs:

{-# LANGUAGE FlexibleContexts #-}
module Ambiguity where

class C a

bar :: C (a, b) => b -> b
bar = id

bar' :: C (a, b) => b -> b
bar' = bar

This gives us

   Could not deduce (C (a, b)) from the context (C (a1, b))
     arising from a use of `bar'
                  at /Users/chak/Code/haskell/Ambiguity.hs:10:7-9
   Possible fix:
     add (C (a, b)) to the context of the type signature for `bar''
     or add an instance declaration for (C (a, b))
   In the expression: bar
   In the definition of `bar'': bar' = bar

So, we have this problem as soon as we have flexible contexts and/or MPTCs, independent of TFs and FDs.


Haskell-Cafe mailing list
[email protected]

<Prev in Thread] Current Thread [Next in Thread>