Picon
Gravatar

Parsec type error with Flexible Contexts

Hi.

I wanted to generalize the definitions in Text.Parsec.Language to be
able to use them with Parsec Text instead of Parsec String.  I'm
getting a type error with the following code snippet:
http://hpaste.org/72844

I don't really understand the error, specially with regard to the fact
that the if I comment one of the marked lines on the code pasted the
program build.

Any help is welcome.

Greetings.

--

-- 
marcot
http://marcot.eti.br/
Felipe Almeida Lessa | 10 Aug 2012 00:51
Picon
Gravatar

Re: Parsec type error with Flexible Contexts

Hello!

I've managed to reduce your code to a much simpler test case (without
parsec) but I'm still not sure why this is happening:

{-# LANGUAGE MultiParamTypeClasses, FlexibleContexts #-}

data D m
  = D { bar1 :: P m ()
      , bar2 :: P m ()
      }

data P m c = P

class S m c where

foo :: S m () => P m ()
foo = undefined

emptyDef :: S m () => D m
emptyDef
  = D
    { bar1 = foo
    , bar2 = foo
    }

haskellStyle :: S m () => D m
haskellStyle
  = emptyDef
    { bar1 = foo
(Continue reading)

Felipe Almeida Lessa | 10 Aug 2012 00:57
Picon
Gravatar

Re: Parsec type error with Flexible Contexts

Here's an even smaller one:

{-# LANGUAGE MultiParamTypeClasses, FlexibleContexts #-}

data D m = D { bar :: P m () }
data P m c = P
class S m c where

foo :: S m () => P m ()
foo = undefined

emptyDef :: S m () => D m
emptyDef = D foo

haskellStyle :: S m () => D m
haskellStyle = emptyDef { bar = foo }

Cheers,

--

-- 
Felipe.

Gmane