DoAndIfThenElse

2009-11-26 Thread Christian Maeder
Hi,

seeing Haskell 2010 and
http://hackage.haskell.org/trac/haskell-prime/wiki/DoAndIfThenElse

saying:
Compiler support ¶
GHC full (no flag)

I wonder why I still get a "parse error (possibly incorrect
indentation)" for:

\begin{code}
main = do
  if True then putStrLn "1"
  else putStrLn "2"
\end{code}

Can I try out this feature somehow?

Cheers Christian
___
Haskell-prime mailing list
Haskell-prime@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-prime


Re: DoAndIfThenElse

2009-11-26 Thread David Virebayre
On Thu, Nov 26, 2009 at 10:29 AM, Christian Maeder  wrote:

I wonder why I still get a "parse error (possibly incorrect
> indentation)" for:
>
> \begin{code}
> main = do
>  if True then putStrLn "1"
>  else putStrLn "2"
> \end{code}
>
>
Isn't the proposal about :

\begin{code}
main = do
 if True then putStrLn "1"
 ;else putStrLn "2"
\end{code}

?

David.
___
Haskell-prime mailing list
Haskell-prime@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-prime


Re: DoAndIfThenElse

2009-11-26 Thread Ian Lynagh

Hi Christian,

On Thu, Nov 26, 2009 at 10:29:10AM +0100, Christian Maeder wrote:
> 
> seeing Haskell 2010 and
> http://hackage.haskell.org/trac/haskell-prime/wiki/DoAndIfThenElse
> 
> saying:
> Compiler support ¶
> GHC   full (no flag)
> 
> I wonder why I still get a "parse error (possibly incorrect
> indentation)" for:
> 
> \begin{code}
> main = do
>   if True then putStrLn "1"
>   else putStrLn "2"
> \end{code}
> 
> Can I try out this feature somehow?

I can't see any support for it in GHC, even in the HEAD. The page claims
"full (no flag)" for every implementation, so I'd guess it's just a
boilerplate table that hasn't been properly filled in.


Thanks
Ian

___
Haskell-prime mailing list
Haskell-prime@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-prime


Re: DoAndIfThenElse

2009-11-26 Thread Christian Maeder
David Virebayre schrieb:
> Isn't the proposal about :
> 
> \begin{code}
> main = do
>  if True then putStrLn "1"
>  ;else putStrLn "2"
> \end{code}

This should go through, too, but also does not for me according to
http://hackage.haskell.org/trac/haskell-prime/wiki/DoAndIfThenElse


Change the syntax for conditionals to

exp -> if exp1 [;] then exp2 [;] else exp3

i.e., add optional semicolons before then and else, making the above
example legal. This has been recently added to jhc, GHC and Hugs, and so
far it has not caused any problems.


But the main purpose of the proposal was to support the notation without
 ";" and the indentation by at least one character.

I just do not see that it "has been recently added to GHC"
I've checked ghc-6.10.4 and 6.12.0.20091010

Cheers Christian

___
Haskell-prime mailing list
Haskell-prime@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-prime


Re: DoAndIfThenElse

2009-11-26 Thread Christian Maeder
David Virebayre schrieb:
> 
> On Thu, Nov 26, 2009 at 10:29 AM, Christian Maeder
> mailto:christian.mae...@dfki.de>> wrote:
> 
> I wonder why I still get a "parse error (possibly incorrect
> indentation)" for:
> 
> \begin{code}
> main = do
>  if True then putStrLn "1"
>  else putStrLn "2"
> \end{code}

This works with hugs!

>  
> Isn't the proposal about :
> 
> \begin{code}
> main = do
>  if True then putStrLn "1"
>  ;else putStrLn "2"
> \end{code}

This does not work with hugs. ";" must be indented further.

\begin{code}
main = do
  if True then putStrLn "1";
  else putStrLn "2"
\end{code}

This does also not work with hugs (";" at the end)

C.

___
Haskell-prime mailing list
Haskell-prime@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-prime


Re: DoAndIfThenElse

2009-11-26 Thread Ian Lynagh
On Thu, Nov 26, 2009 at 03:14:13PM +0100, Christian Maeder wrote:
> David Virebayre schrieb:
> > 
> > On Thu, Nov 26, 2009 at 10:29 AM, Christian Maeder
> > mailto:christian.mae...@dfki.de>> wrote:
> > 
> > I wonder why I still get a "parse error (possibly incorrect
> > indentation)" for:
> > 
> > \begin{code}
> > main = do
> >  if True then putStrLn "1"
> >  else putStrLn "2"
> > \end{code}
> 
> This works with hugs!
> 
> >  
> > Isn't the proposal about :
> > 
> > \begin{code}
> > main = do
> >  if True then putStrLn "1"
> >  ;else putStrLn "2"
> > \end{code}
> 
> This does not work with hugs. ";" must be indented further.
> 
> \begin{code}
> main = do
>   if True then putStrLn "1";
>   else putStrLn "2"
> \end{code}
> 
> This does also not work with hugs (";" at the end)

In both cases you have 2 semi-colons before the else (after the layout
rule has been applied).


Thanks
Ian

___
Haskell-prime mailing list
Haskell-prime@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-prime


Re: DoAndIfThenElse

2009-11-27 Thread Christian Maeder
S. Doaitse Swierstra schrieb:
[..]
>> \begin{code}
>> main = do
>>  if True then putStrLn "1";
>>  else putStrLn "2"
>> \end{code}
>>
>> This does also not work with hugs (";" at the end)
> 
> This does not work since now you have two ";"'s; one because you wrote
> one and one because you did not indent the else. Allowing this
> additional ; was done to prevent confusion, and as you can see even more
> confusion pops up now;-{{ That is why I expressed my concerns about this
> grammar patch.
> 
>  Doaitse

Indeed, these semicolons are confusing. I think it should be possible to
allow "then" and "else" starting in the same column as "if" without
these ";"s (in a do block).

Christian

___
Haskell-prime mailing list
Haskell-prime@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-prime