Domanda

Sono un principiante completo a Haskell. Sto cercando di compilare questo file Haskell ho scaricato ma mi sta dando alcuni errori.

No instance for (Text.Parsec.Prim.Stream s m Char)
  arising from a use of 'letter' at Parse.lhs:649:26-31
Possible fix:
  add an instance declaration for (Text.Parsec.Prim.Stream s m Char)
In the first argument of '(<|>)', namely 'letter'
In the expression: letter <|> oneOf "_"
In the definition of 'firstAllowed':
  firstAllowed = letter <|> oneOf "_"

Non sono sicuro se questo è sufficiente, ma qui è la sezione del codice con l'errore:

parseIdent = do { str <- indent
                ; return (makeIdent str)
                } <?> "identifier"
  where firstAllowed = oneOf "_" <|> letter
È stato utile?

Soluzione

Nella parte che ha citato la funzione firstAllowed locale non sembra essere utilizzato ovunque. Che cosa succede se si rimuove la linea where?

In alternativa si potrebbe provare ad aggiungere questa firma tipo di firstAllowed:

 where
    firstAllowed :: Stream s m Char => ParsecT s u m Char
    firstAllowed = ...
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top