Parse error on input '=' something wrong with my Haskell -


this simple function:

len [] = 0     len (x:xs) = 1 + len xs 

and have loaded in ghci using :l, aways got error parse error on input =.

i run in computer, it's ok. computer mac. there wrong haskell?

you need newline between 2 patterns len function. works fine:

$ cat len.hs len [] = 0 len (x:xs) = 1 + len xs $ ghci ghci, version 7.4.1: http://www.haskell.org/ghc/  :? loading package ghc-prim ... linking ... done. loading package integer-gmp ... linking ... done. loading package base ... linking ... done. prelude> :l len.hs [1 of 1] compiling main             ( len.hs, interpreted ) ok, modules loaded: main. *main> len [] 0 *main> len [1] 1 *main> len [1,2,3] 3 *main>  

since mentioned it's mac, perhaps have newline-convention incompatibility. make sure text editor , ghci agree constitutes newline on platform.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -