Parsec problem with Flexible Contexts

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
-- parsec
import Text.Parsec
import Text.Parsec.Token

emptyDef :: Stream s m Char => GenLanguageDef s u m
emptyDef
  = LanguageDef
    {commentStart   = "",
      commentEnd     = "",
      commentLine    = "",
      nestedComments = True,
      identStart     = letter <|> char '_',
      identLetter    = alphaNum <|> oneOf "_'",
      opStart        = oneOf ":!#$%&*+./<=>?@\\^|-~",
      opLetter       = oneOf ":!#$%&*+./<=>?@\\^|-~",
      reservedOpNames= [],
      reservedNames  = [],
      caseSensitive  = True
    }

-- Works only when one of the lines marked with *** are commented

haskellStyle :: Stream s m Char => GenLanguageDef s u m
haskellStyle = emptyDef
                { commentStart   = "{-"
                , commentEnd     = "-}"
                , commentLine    = "--"
                , nestedComments = True
                , identStart     = letter
                , identLetter	 = alphaNum <|> oneOf "_'"
                , opStart	 = oneOf ":!#$%&*+./<=>?@\\^|-~" -- ***
                , opLetter	 = oneOf ":!#$%&*+./<=>?@\\^|-~" -- ***
                , reservedOpNames= []
                , reservedNames  = []
                , caseSensitive  = True
                }

Parsec problem with Flexible Contexts (annotation)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Prelude> :reload
[1 of 1] Compiling Main             ( test.hs, interpreted )

test.hs:24:16:
    Could not deduce (Stream t0 t1 Char)
      arising from a use of `emptyDef'
    from the context (Stream s m Char)
      bound by the type signature for
                 haskellStyle :: Stream s m Char => GenLanguageDef s u m
      at test.hs:(24,1)-(36,17)
    Possible fix:
      add (Stream t0 t1 Char) to the context of
        the type signature for
          haskellStyle :: Stream s m Char => GenLanguageDef s u m
      or add an instance declaration for (Stream t0 t1 Char)
    In the expression: emptyDef
    In the expression:
      emptyDef
        {commentStart = "{-", commentEnd = "-}", commentLine = "--",
         nestedComments = True, identStart = letter,
         identLetter = alphaNum <|> oneOf "_'",
         opStart = oneOf ":!#$%&*+./<=>?@\\^|-~",
         opLetter = oneOf ":!#$%&*+./<=>?@\\^|-~", reservedOpNames = [],
         reservedNames = [], caseSensitive = True}
    In an equation for `haskellStyle':
        haskellStyle
          = emptyDef
              {commentStart = "{-", commentEnd = "-}", commentLine = "--",
               nestedComments = True, identStart = letter,
               identLetter = alphaNum <|> oneOf "_'",
               opStart = oneOf ":!#$%&*+./<=>?@\\^|-~",
               opLetter = oneOf ":!#$%&*+./<=>?@\\^|-~", reservedOpNames = [],
               reservedNames = [], caseSensitive = True}
Failed, modules loaded: none.
Prelude>