[Haskell-cafe] unary pattern matching
John Meacham
john at repetae.net
Thu Jan 26 20:14:26 EST 2006
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
so you can do things like
when (/Just _/ x) $ putStrLn "x is something"
or
map /Left (Foo _ 'x')/ xs
to get a list of booleans saying whether the xs match or not.
however, the '/' syntax clearly doesn't work, nor would anything that
conflicts with normal haskell syntax. does anyone have any better ideas?
John
--
John Meacham - ⑆repetae.net⑆john⑈
More information about the Haskell-Cafe
mailing list