[Haskell-cafe] unary pattern matching

Donald Bruce Stewart dons at cse.unsw.edu.au
Thu Jan 26 20:28:23 EST 2006


john:
> I have often wanted a shorthand syntax for testing if a value matches a
> given pattern. I want to implement such an extension for jhc but can't
> decide an appropriate syntax so I thought I'd ask the group. basically I
> want something like
> 
> /Left (Just _)/   expands to 
> 
> \x -> case x of
>         Left (Just _) -> True
>         _ -> False

Something like pattern guards?

    f x | Just _ <- x = putStrLn "something"

-- Don


More information about the Haskell-Cafe mailing list