I'm trying to get this trivial parsec code to compile
import Text.Parsec
simple = letter
but I keep getting this error
No instance for (Stream s0 m0 Char)
arising from a use of `letter'
Possible fix: add an instance declaration for (Stream s0 m0 Char)
In the expression: letter
In an equation for `simple': simple = letter
Compile Time Errors are sometimes also referred to as Syntax errors. These kind of errors are easy to spot and rectify because the java compiler finds them for you. The compiler will tell you which piece of code in the program got in trouble and its best guess as to what you did wrong.
The Parsec web app only works in recent versions of Chrome and Edge, please use one of these browsers or install the Parsec app on your client to continue. Check if the machine is online, get a new link if applicable, or try to restart Parsec on both ends.
The compiler will tell you which piece of code in the program got in trouble and its best guess as to what you did wrong. Usually, the compiler indicates the exact line where the error is, or sometimes the line just before it, however, if the problem is with incorrectly nested braces, the actual error may be at the beginning of the block.
Type II Error In statistical hypothesis testing, a type II error is a situation wherein a hypothesis test fails to reject the null hypothesis that is false. In other Conditional Probability Conditional probability is the probability of an event occurring given that another event has already occurred.
I think you have ran against the monomorphism restriction. This restriction means: If a variable is declared with no explicit arguments, its type has to be monomorphic. This forces the typechecker to pick a particular instance of Stream
, but it can't decide.
There are two ways to fight it:
Give simple
an explicit signature:
simple :: Stream s m Char => ParsecT s u m Char
simple = letter
Disable the monorphism restriction:
{-# LANGUAGE NoMonomorphismRestriction #-}
import Text.Parsec
simple = letter
See What is the monomorphism restriction? for more information on the monomorphism restriction.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With