Error Loading Stdm.lhs in Haskell platform 2012
Dear Sir/Madam I Installed *Haskell Platform 2012.2.0.0 for Windows<http://lambda.haskell.org/platform/download/2012.2.0.0/HaskellPlatform-2012.2.0.0-setup.exe> *and try to load Stdm.lhs which is downloaded from http://www.dcs.gla.ac.uk/~jtod/discrete-mathematics/Stdm.lhs I have this error: stdm.lhs:1160:14: Parse error in pattern: n + 1 Failed, modules loaded: none. Is there anything I should do to make it right? Thank you. -- Iwan Awaludin
What version of ghc are you using? In recent versions ghc doesn't support pattern matching of expressions like (n+1). You can rewrite that factorial function as factorial n = n * factorial (n-1) instead. best, Eugene On 3 September 2012 22:08, Iwan Awaludin <awaludin@gmail.com> wrote:
Dear Sir/Madam I Installed Haskell Platform 2012.2.0.0 for Windows and try to load Stdm.lhs which is downloaded from http://www.dcs.gla.ac.uk/~jtod/discrete-mathematics/Stdm.lhs I have this error: stdm.lhs:1160:14: Parse error in pattern: n + 1 Failed, modules loaded: none.
Is there anything I should do to make it right? Thank you.
-- Iwan Awaludin
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
OK, I changed the line code as suggested. It is successfully compiled. But it still has one warning: stdm.lhs:38:10: Warning: In the use of `catch' (imported from Prelude, but defined in System.IO.Error): Deprecated: "Please use the new exceptions variant, Control.Exception.catch" I don't know the effect but as long as I can use it for my course, I don't mind. Thank you for your help. On Tue, Sep 4, 2012 at 1:46 PM, Eugene Perederey <eugene.perederey@gmail.com
wrote:
What version of ghc are you using? In recent versions ghc doesn't support pattern matching of expressions like (n+1). You can rewrite that factorial function as factorial n = n * factorial (n-1) instead.
best, Eugene
On 3 September 2012 22:08, Iwan Awaludin <awaludin@gmail.com> wrote:
Dear Sir/Madam I Installed Haskell Platform 2012.2.0.0 for Windows and try to load Stdm.lhs which is downloaded from http://www.dcs.gla.ac.uk/~jtod/discrete-mathematics/Stdm.lhs I have this error: stdm.lhs:1160:14: Parse error in pattern: n + 1 Failed, modules loaded: none.
Is there anything I should do to make it right? Thank you.
-- Iwan Awaludin
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
-- Iwan Awaludin http://www.schoolofuniverse.com
The code for the book is written in Haskell '98, but recent versions of GHC default to Haskell2010. A salient difference between H98 and H2012 is the removed of n + k patterns which generates the error you are seeing. I can't find the exact command to use in the GHC docs to enable H98, but you could try the following old flag which disables GHCs extensions:
ghci -fno-glasgow-exts
I think the preferred command line invocation is:
ghci -XHaskell98
Strangely this seems to be missing in the GHC docs for Flags. On 4 September 2012 17:40, Stephen Tetley <stephen.tetley@gmail.com> wrote:
I can't find the exact command to use in the GHC docs to enable H98, but you could try the following old flag which disables GHCs extensions:
ghci -fno-glasgow-exts
participants (4)
-
Carlos J. G. Duarte -
Eugene Perederey -
Iwan Awaludin -
Stephen Tetley