[erlang-questions] View patterns  Thomas Lindgren <> Wed Jul 25
18:34:30 CEST 2007  --- ok <> wrote:  > Haskell is starting to
eat Erlang's lunch, except > for hot loading. > Data.ByteString
(and especially > Data.ByteString.Lazy) is an effective >
replacement for Erlang binaries, with support for > packing and
unpacking > stuff.  There's even talk about an analogue of 'bit
> syntax'.  If this also involved monads, what I've seen of it
looked interesting, but figuring out the details made my head
hurt.   (I've in recent years seen at least a handful of
distinct non-Erlang efforts on translating between bits and tree
data, actually. PADS and Packettypes are two examples. Also,
"high level views of low level representations" in ICFP 2005.)
> One of the things which is about to be added to GHC > is view
patterns. > The idea is that if E is an expression and P is a >
pattern, then >       (E -> P) > is a pattern.  This pattern
matches a value V if and > only if > P = (E)(V).  So a simple
compilation scheme would be: