RE: [Haskell-cafe] Strange type error with associated type synonyms

2009-05-27 Thread Simon Peyton-Jones
Claus made a suggestion about type error messages: | Apart from bracketing fully applied type synonyms, the error message | could be improved by providing the missing bit of information about | 'Memo': | | D:\home\Haskell\tmp\desktop\types.hs:11:11: | Couldn't match expected type

RE: [Haskell-cafe] Strange type error with associated type synonyms

2009-05-27 Thread Sittampalam, Ganesh
Simon Peyton-Jones wrote: NoMatchErr.hs:20:11: Couldn't match expected type `Memo d' against inferred type `Memo d1' NB: `Memo' is a (non-injective) type function In the second argument of `(.)', namely `appl' In the expression: abst . appl In the

Re: [Haskell-cafe] Strange type error with associated type synonyms

2009-04-16 Thread Claus Reinke
| But the core part of my suggestion (which this example was meant | to help explain) remains attractive, at least to me: somewhere during | type inference, GHC *does* unify the *apparently free* 'd' with an | internal type variable (lets call it 'd1, as in the type error message) You are

RE: [Haskell-cafe] Strange type error with associated type synonyms

2009-04-15 Thread Simon Peyton-Jones
| But the core part of my suggestion (which this example was meant | to help explain) remains attractive, at least to me: somewhere during | type inference, GHC *does* unify the *apparently free* 'd' with an | internal type variable (lets call it 'd1, as in the type error message) You are

Re: [Haskell-cafe] Strange type error with associated type synonyms

2009-04-09 Thread Claus Reinke
|Oh now i see what you mean: consider |f' = abst . (id :: (d-a)-(d-a)) . appl |which GHC understands to mean |f' = abst . (id :: forall d a. (d-a)-(d-a)) . appl | |GHC infers the type |f' :: (Fun d) = Memo d a - Memo d a |Now you are saying that GHC *could* have figured

Re: [Haskell-cafe] Strange type error with associated type synonyms

2009-04-07 Thread Manuel M T Chakravarty
Matt Morrow: On Mon, Apr 6, 2009 at 7:39 PM, Manuel M T Chakravarty c...@cse.unsw.edu.au wrote: Peter Berry: 3) we apply appl to x, so Memo d1 a = Memo d a. unify d = d1 But for some reason, step 3 fails. Step 3 is invalid - cf,

Re: [Haskell-cafe] Strange type error with associated type synonyms

2009-04-07 Thread Matt Morrow
On Mon, Apr 6, 2009 at 7:39 PM, Manuel M T Chakravarty c...@cse.unsw.edu.au wrote: Peter Berry: 3) we apply appl to x, so Memo d1 a = Memo d a. unify d = d1 But for some reason, step 3 fails. Step 3 is invalid - cf, http://www.haskell.org/pipermail/haskell-cafe/2009-April/059196.html.

Re: [Haskell-cafe] Strange type error with associated type synonyms

2009-04-07 Thread Claus Reinke
Basically, type checking proceeds in one of two modes: inferring or checking. The former is when there is no signature is given; the latter, if there is a user-supplied signature. GHC can infer ambiguous signatures, but it cannot check them. This is of course very confusing and we need

RE: [Haskell-cafe] Strange type error with associated type synonyms

2009-04-07 Thread Simon Peyton-Jones
| Here is a variation to make this point clearer: | | {-# LANGUAGE NoMonomorphismRestriction #-} | {-# LANGUAGE TypeFamilies, ScopedTypeVariables #-} | | class Fun d where | type Memo d :: * - * | abst :: (d - a) - Memo d a | appl :: Memo d a - (d - a) | | f = abst . appl | | -- f' ::

Re: [Haskell-cafe] Strange type error with associated type synonyms

2009-04-07 Thread Peter Berry
On 07/04/2009, Ryan Ingram ryani.s...@gmail.com wrote: On Mon, Apr 6, 2009 at 2:36 PM, Peter Berry pwbe...@gmail.com wrote: As I understand it, the type checker's thought process should be along these lines: 1) the type signature dictates that x has type Memo d a. 2) appl has type Memo d1 a

Re: [Haskell-cafe] Strange type error with associated type synonyms

2009-04-07 Thread Claus Reinke
| Here is a variation to make this point clearer: | | {-# LANGUAGE NoMonomorphismRestriction #-} | {-# LANGUAGE TypeFamilies, ScopedTypeVariables #-} | | class Fun d where | type Memo d :: * - * | abst :: (d - a) - Memo d a | appl :: Memo d a - (d - a) | | f = abst . appl | | -- f' ::

Re: [Haskell-cafe] Strange type error with associated type synonyms

2009-04-07 Thread Peter Berry
On Mon, Apr 6, 2009 at 7:39 PM, Manuel M T Chakravarty c...@cse.unsw.edu.au wrote: Peter Berry: 3) we apply appl to x, so Memo d1 a = Memo d a. unify d = d1 But for some reason, step 3 fails. Step 3 is invalid - cf, http://www.haskell.org/pipermail/haskell-cafe/2009-April/059196.html.

Re: [Haskell-cafe] Strange type error with associated type synonyms

2009-04-06 Thread Ryan Ingram
On Mon, Apr 6, 2009 at 2:36 PM, Peter Berry pwbe...@gmail.com wrote: As I understand it, the type checker's thought process should be along these lines: 1) the type signature dictates that x has type Memo d a. 2) appl has type Memo d1 a - d1 - a for some d1. 3) we apply appl to x, so Memo d1

Re: [Haskell-cafe] Strange type error with associated type synonyms

2009-04-06 Thread Manuel M T Chakravarty
Peter Berry: {-# LANGUAGE TypeFamilies, TypeSynonymInstances, ScopedTypeVariables #-} The following is a class of memo tries indexed by d: class Fun d where type Memo d :: * - * abst :: (d - a) - Memo d a appl :: Memo d a - (d - a) -- Law: abst . appl = id -- Law: appl . abst