GHC TV station?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

GHC TV station?

Haskell - Haskell-Cafe mailing list
White space in "do notation" is no longer supported by GHC but I had to guess it the hard way seeing my solutions to Hutton's book and then his own code produce "Parse error" and irritating hint "Possibly caused by a missing 'do'?". So, Hutton 2ed is outdated, Haskell Platform is dropped exhausted then perhaps GHC should have a TV station?
Fun is best when it can be shared.
Regards,
Sylvester

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: GHC TV station?

Ivan Lazar Miljenovic
On 15 May 2018 at 09:27, Sylvester Hazel via Haskell-Cafe
<[hidden email]> wrote:
> White space in "do notation" is no longer supported by GHC but I had to
> guess it the hard way seeing my solutions to Hutton's book and then his own
> code produce "Parse error" and irritating hint "Possibly caused by a missing
> 'do'?". So, Hutton 2ed is outdated, Haskell Platform is dropped exhausted
> then perhaps GHC should have a TV station?
> Fun is best when it can be shared.

What do you mean? I don't recall anything changing with how do
notation works in GHC.

--
Ivan Lazar Miljenovic
[hidden email]
http://IvanMiljenovic.wordpress.com
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: GHC TV station?

Roel van Dijk-3
In reply to this post by Haskell - Haskell-Cafe mailing list
Hi Sylvester,

Could you please give an example of code that you think should be correct, but is rejected by a recent GHC?
It is certainly annoying when code from a book on Haskell fails to parse. But perhaps the cause is not so nefarious as a backwards incompatible change in syntax.

2018-05-15 1:27 GMT+02:00 Sylvester Hazel via Haskell-Cafe <[hidden email]>:
White space in "do notation" is no longer supported by GHC but I had to guess it the hard way seeing my solutions to Hutton's book and then his own code produce "Parse error" and irritating hint "Possibly caused by a missing 'do'?". So, Hutton 2ed is outdated, Haskell Platform is dropped exhausted then perhaps GHC should have a TV station?
Fun is best when it can be shared.
Regards,
Sylvester

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.


_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: GHC TV station?

Haskell - Haskell-Cafe mailing list
                               strlen in Hutton 2ed 10.5 Derived primitives
        White Spaced                                                      
run on Windows 7 Haskell Platform 8.2.2
strlen :: IO ()                                                        
GHCi, version 8.2.2: http://www.haskell.org/ghc/  :? for help    
strlen = do putStr "Enter a string: "                       [1 of 1]
Compiling Main      ( C:\strlen.WhiteSpaced.hs, interpreted )
                  xs <-  getLine                                
                  putStr "The string has "                      
C:\strlen.WhiteSpaced.hs:2:14: error:
                  putStr (show (length xs))                        Parse
error in pattern: putStr
                  putStr " characters"                              
Possibly caused by a missing 'do'?
                                                                               
|
                                                                             
2 | strlen = do  putStr "Enter a string: "
                                                                               
|              ^^^^^^^^^^^^^^^^^^^^^^^^^^^...
                                                                             
Failed, no modules loaded.
                                                                             
Prelude>
      Bracesed
strlen :: IO                                                            
GHCi, version 8.2.2: http://www.haskell.org/ghc/  :? for help
strlen = do {putStr "Enter a string: ";                    [1 of 1]
Compiling Main             ( C:\strlen.Bracesed.hs, interpreted )
                   xs <-  getLine;                                   Ok, one
module loaded.
                   putStr "The string has ";                    *Main>
                   putStr (show (length xs));      
                   putStr " characters"}          
                                                       
                                                       
                                                       
                                                         
                                                         
                                                         
                                                         


 




--
Sent from: http://haskell.1045720.n5.nabble.com/Haskell-Haskell-Cafe-f3074699.html
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: GHC TV station?

Haskell - Haskell-Cafe mailing list
In reply to this post by Roel van Dijk-3
strlen in Hutton 2ed 10.5 Derived primitives => run on Windows 7 Haskell
Platform 8.2.2
strlen :: IO ()
strlen = do  putStr "Enter a string: "
                   xs <-  getLine
                   putStr "The string has "
                   putStr (show (length xs))
                   putStr " characters"
===================================================
GHCi, version 8.2.2: http://www.haskell.org/ghc/  :? for help
[1 of 1] Compiling Main             ( C:\strlen.WhiteSpaced.hs, interpreted
)

C:\strlen.WhiteSpaced.hs:2:14: error:
    Parse error in pattern: putStr
    Possibly caused by a missing 'do'?
  |
2 | strlen = do  putStr "Enter a string: "
  |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^...
Failed, no modules loaded.
Prelude>
==================================================
strlen :: IO ()
strlen = do {putStr "Enter a string: ";
                   xs <-  getLine;
                   putStr "The string has ";
                   putStr (show (length xs));
                   putStr " characters"}
=================================================
GHCi, version 8.2.2: http://www.haskell.org/ghc/  :? for help
[1 of 1] Compiling Main             ( C:\strlen.Bracesed.hs, interpreted )
Ok, one module loaded.
*Main>



--
Sent from: http://haskell.1045720.n5.nabble.com/Haskell-Haskell-Cafe-f3074699.html
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: GHC TV station?

Sylvain Henry-2
Some ways to fix the given code:

strlen :: IO ()
strlen = do  putStr "Enter a string: " >> do
                   xs <-  getLine
                   putStr "The string has "
                   putStr (show (length xs))
                   putStr " characters"

strlen :: IO ()
strlen = do  putStr "Enter a string: "
              do
                   xs <-  getLine
                   putStr "The string has "
                   putStr (show (length xs))
                   putStr " characters"

strlen :: IO ()
strlen = do  putStr "Enter a string: "
              xs <-  getLine
              putStr "The string has "
              putStr (show (length xs))
              putStr " characters"


On 15/05/2018 18:13, Sylvester via Haskell-Cafe wrote:

> strlen in Hutton 2ed 10.5 Derived primitives => run on Windows 7 Haskell
> Platform 8.2.2
> strlen :: IO ()
> strlen = do  putStr "Enter a string: "
>                     xs <-  getLine
>                     putStr "The string has "
>                     putStr (show (length xs))
>                     putStr " characters"
> ===================================================
> GHCi, version 8.2.2: http://www.haskell.org/ghc/  :? for help
> [1 of 1] Compiling Main             ( C:\strlen.WhiteSpaced.hs, interpreted
> )
>
> C:\strlen.WhiteSpaced.hs:2:14: error:
>      Parse error in pattern: putStr
>      Possibly caused by a missing 'do'?
>    |
> 2 | strlen = do  putStr "Enter a string: "
>    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^...
> Failed, no modules loaded.
> Prelude>
> ==================================================
> strlen :: IO ()
> strlen = do {putStr "Enter a string: ";
>                     xs <-  getLine;
>                     putStr "The string has ";
>                     putStr (show (length xs));
>                     putStr " characters"}
> =================================================
> GHCi, version 8.2.2: http://www.haskell.org/ghc/  :? for help
> [1 of 1] Compiling Main             ( C:\strlen.Bracesed.hs, interpreted )
> Ok, one module loaded.
> *Main>
>
>
>
> --
> Sent from: http://haskell.1045720.n5.nabble.com/Haskell-Haskell-Cafe-f3074699.html
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: GHC TV station?

Viktor Dukhovni
In reply to this post by Haskell - Haskell-Cafe mailing list


> On May 15, 2018, at 12:13 PM, Sylvester via Haskell-Cafe <[hidden email]> wrote:
>
> strlen in Hutton 2ed 10.5 Derived primitives => run on Windows 7 Haskell
> Platform 8.2.2
> strlen :: IO ()
> strlen = do  putStr "Enter a string: "
>                   xs <-  getLine
>                   putStr "The string has "
>                   putStr (show (length xs))
>                   putStr " characters"
> ===================================================

The above indentation looks wrong.  Try:

----------
$ cat foo.hs
strlen :: IO ()
strlen = do putStr "Enter a string: "
            xs <-  getLine
            putStr "The string has "
            putStr (show (length xs))
            putStrLn " characters"

$ ghci foo.hs
GHCi, version 8.0.2: http://www.haskell.org/ghc/  :? for help
[1 of 1] Compiling Main             ( foo.hs, interpreted )
Ok, modules loaded: Main.
Loaded GHCi configuration from /tmp/haskell-stack-ghci/05485125/ghci-script
*Main> strlen
Enter a string: foo
The string has 3 characters
*Main>
----------

If I incorrectly indent the subsequent lines:

strlen :: IO ()
strlen = do putStr "Enter a string: "
              xs <-  getLine
              putStr "The string has "
              putStr (show (length xs))
              putStrLn " characters"


Then I see an error:

foo.hs:2:13: error:
    Parse error in pattern: putStr
    Possibly caused by a missing 'do'?

--
        Viktor.

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: GHC TV station?

Neil Mayhew
In reply to this post by Haskell - Haskell-Cafe mailing list
On 2018-05-15 10:13 AM, Sylvester via Haskell-Cafe wrote:
strlen in Hutton 2ed 10.5 Derived primitives => run on Windows 7 Haskell
Platform 8.2.2
strlen :: IO ()
strlen = do  putStr "Enter a string: " 
                   xs <-  getLine 
                   putStr "The string has " 
                   putStr (show (length xs)) 
                   putStr " characters" 


This works fine if you indent the code correctly. The code following the first putStr should line up with it vertically:

strlen :: IO ()
strlen = do  putStr "Enter a string: "
             xs <- getLine
             putStr "The string has "
             putStr (show (length xs))
             putStr " characters"

This compiles for me with ghc 8.2.

The way you have the code above, the second and subsequent lines of the do block are indented further, and so would need an additional do. However, I don't think this is what's intended.

Are you using tabs by any chance? Or have you copied the source from text that uses a mixture of tabs and spaces?

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: GHC TV station?

Haskell - Haskell-Cafe mailing list
In reply to this post by Viktor Dukhovni
Hi Victor,
It is frustrating that posting plain text is contorted (via nabble.com and then again in my mail.google.com account) - please see the attachment.
I really have sent the right indentation copping the Hutton's script.
Is it so difficult for you guys to replicate this obvious failure of GHC on "do notation" with white space?
Regards,
Sylvester

On Tue, May 15, 2018 at 6:27 PM, Viktor Dukhovni <[hidden email]> wrote:


> On May 15, 2018, at 12:13 PM, Sylvester via Haskell-Cafe <[hidden email]> wrote:
>
> strlen in Hutton 2ed 10.5 Derived primitives => run on Windows 7 Haskell
> Platform 8.2.2
> strlen :: IO ()
> strlen = do  putStr "Enter a string: "
>                   xs <-  getLine
>                   putStr "The string has "
>                   putStr (show (length xs))
>                   putStr " characters"
> ===================================================

The above indentation looks wrong.  Try:

----------
$ cat foo.hs
strlen :: IO ()
strlen = do putStr "Enter a string: "
            xs <-  getLine
            putStr "The string has "
            putStr (show (length xs))
            putStrLn " characters"

$ ghci foo.hs
GHCi, version 8.0.2: http://www.haskell.org/ghc/  :? for help
[1 of 1] Compiling Main             ( foo.hs, interpreted )
Ok, modules loaded: Main.
Loaded GHCi configuration from /tmp/haskell-stack-ghci/05485125/ghci-script
*Main> strlen
Enter a string: foo
The string has 3 characters
*Main>
----------

If I incorrectly indent the subsequent lines:

strlen :: IO ()
strlen = do putStr "Enter a string: "
              xs <-  getLine
              putStr "The string has "
              putStr (show (length xs))
              putStrLn " characters"


Then I see an error:

foo.hs:2:13: error:
    Parse error in pattern: putStr
    Possibly caused by a missing 'do'?

--
        Viktor.

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.


_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.

wrong is HTML.jpg (372K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: GHC TV station?

Matt
Could you link to a GitHub gist or lambdapaste or similar? I don't see a plaintext attachment.

Matt Parsons

On Tue, May 15, 2018 at 11:01 AM, Sylvester Hazel via Haskell-Cafe <[hidden email]> wrote:
Hi Victor,
It is frustrating that posting plain text is contorted (via nabble.com and then again in my mail.google.com account) - please see the attachment.
I really have sent the right indentation copping the Hutton's script.
Is it so difficult for you guys to replicate this obvious failure of GHC on "do notation" with white space?
Regards,
Sylvester

On Tue, May 15, 2018 at 6:27 PM, Viktor Dukhovni <[hidden email]> wrote:


> On May 15, 2018, at 12:13 PM, Sylvester via Haskell-Cafe <[hidden email]> wrote:
>
> strlen in Hutton 2ed 10.5 Derived primitives => run on Windows 7 Haskell
> Platform 8.2.2
> strlen :: IO ()
> strlen = do  putStr "Enter a string: "
>                   xs <-  getLine
>                   putStr "The string has "
>                   putStr (show (length xs))
>                   putStr " characters"
> ===================================================

The above indentation looks wrong.  Try:

----------
$ cat foo.hs
strlen :: IO ()
strlen = do putStr "Enter a string: "
            xs <-  getLine
            putStr "The string has "
            putStr (show (length xs))
            putStrLn " characters"

$ ghci foo.hs
GHCi, version 8.0.2: http://www.haskell.org/ghc/  :? for help
[1 of 1] Compiling Main             ( foo.hs, interpreted )
Ok, modules loaded: Main.
Loaded GHCi configuration from /tmp/haskell-stack-ghci/05485125/ghci-script
*Main> strlen
Enter a string: foo
The string has 3 characters
*Main>
----------

If I incorrectly indent the subsequent lines:

strlen :: IO ()
strlen = do putStr "Enter a string: "
              xs <-  getLine
              putStr "The string has "
              putStr (show (length xs))
              putStrLn " characters"


Then I see an error:

foo.hs:2:13: error:
    Parse error in pattern: putStr
    Possibly caused by a missing 'do'?

--
        Viktor.

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.


_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.


_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: GHC TV station?

Bob Ippolito
In reply to this post by Haskell - Haskell-Cafe mailing list
It looks like you may be trying to do this with a proportional font, which is not going to work very well. You will have much better luck if you use a fixed width font when you need to line up columns where some of the lines have non-whitespace characters.

An alternative approach would be to have a line break immediately after "do", so all of the lines that need to be indented have only preceding whitespace. The hindent code formatter uses this style, as you can see in any of its examples with do blocks, such as this: https://github.com/commercialhaskell/hindent/blob/master/TESTS.md#function-declarations - when code is written in this style, the blocks will line up visually whether or not the font is fixed width.



On Tue, May 15, 2018 at 10:02 AM Sylvester Hazel via Haskell-Cafe <[hidden email]> wrote:
Hi Victor,
It is frustrating that posting plain text is contorted (via nabble.com and then again in my mail.google.com account) - please see the attachment.
I really have sent the right indentation copping the Hutton's script.
Is it so difficult for you guys to replicate this obvious failure of GHC on "do notation" with white space?
Regards,
Sylvester

On Tue, May 15, 2018 at 6:27 PM, Viktor Dukhovni <[hidden email]> wrote:


> On May 15, 2018, at 12:13 PM, Sylvester via Haskell-Cafe <[hidden email]> wrote:
>
> strlen in Hutton 2ed 10.5 Derived primitives => run on Windows 7 Haskell
> Platform 8.2.2
> strlen :: IO ()
> strlen = do  putStr "Enter a string: "
>                   xs <-  getLine
>                   putStr "The string has "
>                   putStr (show (length xs))
>                   putStr " characters"
> ===================================================

The above indentation looks wrong.  Try:

----------
$ cat foo.hs
strlen :: IO ()
strlen = do putStr "Enter a string: "
            xs <-  getLine
            putStr "The string has "
            putStr (show (length xs))
            putStrLn " characters"

$ ghci foo.hs
GHCi, version 8.0.2: http://www.haskell.org/ghc/  :? for help
[1 of 1] Compiling Main             ( foo.hs, interpreted )
Ok, modules loaded: Main.
Loaded GHCi configuration from /tmp/haskell-stack-ghci/05485125/ghci-script
*Main> strlen
Enter a string: foo
The string has 3 characters
*Main>
----------

If I incorrectly indent the subsequent lines:

strlen :: IO ()
strlen = do putStr "Enter a string: "
              xs <-  getLine
              putStr "The string has "
              putStr (show (length xs))
              putStrLn " characters"


Then I see an error:

foo.hs:2:13: error:
    Parse error in pattern: putStr
    Possibly caused by a missing 'do'?

--
        Viktor.

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: GHC TV station?

Haskell - Haskell-Cafe mailing list
Bingo Bob!
After all that nonsense of my contorted indentations here I discovered
(independent from Bob) that Cambria font in my notepad was the reason.
Changing it back to Consolas and correcting indentation in scripts agrees
with GHC like with all of us:-)
I am very sorry for that stupid interruption. Apology to GHC developers who
deserve continuous praise.
Thank you all for your kind attention and Best Wishes for you all:-)
Sylvester



--
Sent from: http://haskell.1045720.n5.nabble.com/Haskell-Haskell-Cafe-f3074699.html
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.