| Portability | portable |
|---|---|
| Stability | experimental |
| Maintainer | Reiner Pope <reiner.pope@gmail.com> |
Data.Pattern
Description
The main import module for first-class-patterns.
As an example, the following functions, ex1 and ex2 are
semantically equivalent:
ex1, ex2 :: Num a => Either a (a, a) -> a ex1 a =matcha $left(cst4)->>0<|>leftvar->>id<|>right(tup2varvar)->>(+) ex2 a = case a of Left 4 -> 0 Left x -> x Right (x,y) -> x+y
Also, when optimisation is turned on, GHC will compile them to the same code.
- module Data.Pattern.Base
- module Data.Pattern.Common
- (<|>) :: Alternative f => forall a. f a -> f a -> f a
Documentation
module Data.Pattern.Base
module Data.Pattern.Common
(<|>) :: Alternative f => forall a. f a -> f a -> f a
An associative binary operation