Parse error in Haskell -
the following code:
import io import system(getargs) main = args <- getargs let l = length args if l == 0 putstrln "foo" else putstrln "bar"
generates parse error if-else clause. have tried using curly braces no avail. help!
just demonstrate comment mark's answer,
import system.environment (getargs) main :: io () main = args <- getargs let l = length args if l == 0 putstrln "foo" else putstrln "bar"
is legal haskell.
with ghc 7.0's {-# language rebindablesyntax #-}
extension, can away with
class ifthenelse b c d | b c -> d ifthenelse :: -> b -> c -> d instance ifthenelse bool a ifthenelse true = const ifthenelse false = flip const instance (monad m, ifthenelse (m b) (m b) (m b)) => ifthenelse (m a) (m b) (m b) (m b) ifthenelse = liftm ifthenelse main = if liftm null getargs putstrln "foo" else putstrln "bar"
(shamelessly aped blog.n-sch.de.)
Comments
Post a Comment