extensible-0.4: Extensible, efficient, optics-friendly data types and effects

Copyright(c) Fumiaki Kinoshita 2017
LicenseBSD3
MaintainerFumiaki Kinoshita <fumiexcel@gmail.com>
Safe HaskellSafe
LanguageHaskell2010

Data.Extensible.Match

Description

Pattern matching

Synopsis

Documentation

matchWith :: (forall x. f x -> g x -> r) -> (f :* xs) -> (g :| xs) -> r Source #

Retrieve the contents so that they matches and pass both to the given function.

newtype Match h r x Source #

Turn a wrapper type into a clause for it.

Constructors

Match 

Fields

Instances

Wrapper k h => Wrapper k (Match k h r) Source # 

Associated Types

type Repr (Match k h r) (h :: Match k h r -> *) (v :: Match k h r) :: * Source #

Methods

_Wrapper :: (Functor f, Profunctor p) => Optic' * * p f (h v) (Repr (Match k h r) h v) Source #

type Repr k (Match k h r) x Source # 
type Repr k (Match k h r) x = Repr k h x -> r

match :: (Match h a :* xs) -> (h :| xs) -> a Source #

O(1) Perform pattern matching.

mapMatch :: (a -> b) -> Match h a x -> Match h b x Source #

Applies a function to the result of Match.

caseOf :: (h :| xs) -> (Match h a :* xs) -> a infix 0 Source #

Flipped match