[Haskell-beginners] Parse error in pattern

Magnus Therning magnus at therning.org
Fri Feb 26 11:37:30 EST 2010


It doesn't look like a complete piece of code so these comments aren't
backed up by running it through GHCi or anything.

On Fri, Feb 26, 2010 at 16:29, Florian Duret <flo.morphe at gmail.com> wrote:
> Hello,
>
>
> I try to set up a verification on the number of arguments given to my
> program, but keep on getting "Parse error in pattern"
> Here is what my code looks like:
> main :: IO()
> main = do
>     -- On commence par ouvrir le fichier SAC en mode binaire
>     argsList <- getArgs
>     if (length (argsList) == 0)
>        then do
>              putStrLn $ "No filename given to the program.\n $ ProgramName
> file.sac"
>              return ()

I believe the 'do' here is unecessary.

>       else
>              sacFile1 <- openBinaryFile fileToOpen ReadMode

Here you do need a 'do' though, I believe.

>
> ghci complains, and tells "Parse error in pattern", indicating the 'if' line
> number.
> Can you please help ?
> Thank you very much,
> Florian
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
>



-- 
Magnus Therning                        (OpenPGP: 0xAB4DFBA4)
magnus@therning.org          Jabber: magnus@therning.org
http://therning.org/magnus         identi.ca|twitter: magthe


More information about the Beginners mailing list