On Feb 16, 2006, at 7:32 PM, John Meacham wrote:
...
Again that doesn't compile, because when requires a ()-returning
monad as its second parameter, but the string parser returns
String.
Same thing with if-then-else, when used to switch IO actions and
such:
the IO actions must fully
Tomasz Zielonka wrote:
On Sun, Feb 12, 2006 at 06:22:46AM -0800, Juan Carlos Arevalo Baeza wrote:
This brings me to wonder also if it'd be possible for the compilers
to add a little bit more smarts to the do notation syntax, so that
it'll add the return () at the end if it's missing.
Juan Carlos Arevalo Baeza wrote:
myParser :: Parser ()
myParser =
do string Hello
optional (string , world!)
It makes no sense for myParser to generate any values, especially not
the result from the optional statement, so it is set to return ().
Don't you think this
Udo Stenzel wrote:
Juan Carlos Arevalo Baeza wrote:
myParser :: Parser ()
myParser =
do string Hello
optional (string , world!)
It makes no sense for myParser to generate any values, especially not
the result from the optional statement, so it is set to return ().
Juan Carlos Arevalo Baeza wrote:
Udo Stenzel wrote:
Don't you think this will interfere somehow with type inference?
With type inference? No, why? I mean... specifying the type of a
function [...]
Okay, so want an implicit (return ()) only if the type of the do-block
has been explicitly
On Thu, Feb 16, 2006 at 04:22:40AM -0800, Juan Carlos Arevalo Baeza wrote:
But... the thing is, if we have any do statement, or any monad
whatsoever, which does not return (), and the program needs it to return
() in order to be able to match its type, that transformation is always
On Sun, Feb 12, 2006 at 01:57:07PM +0100, Daniel Fischer wrote:
Am Sonntag, 12. Februar 2006 04:23 schrieb Juan Carlos Arevalo Baeza:
optional :: GenParser tok st a - GenParser tok st ()
optional p = do{ p; return ()} | return ()
Now, this completely loses the result of the
Tomasz Zielonka wrote:
On Sun, Feb 12, 2006 at 01:57:07PM +0100, Daniel Fischer wrote:
Your above parser would be
option Nothing (fmap Just p) -- or you might use liftM.
Both are easy enough. If you think the naming is unfortunate, I wouldn't
flatly contradict, but it's too late now, I
On Sun, Feb 12, 2006 at 06:22:46AM -0800, Juan Carlos Arevalo Baeza wrote:
The only programs it would break are those that specify it at the end
(they'd require an extra return (), right?
I can imagine many other cases, but none of them very likely.
This brings me to wonder also if it'd