blarney
Copyright(c) Matthew Naylor 2019
LicenseMIT
Maintainermattfn@gmail.com
Stabilityexperimental
Safe HaskellSafe-Inferred

Blarney.BitPat

Description

Inspired by Morten Rhiger's "Type-Safe Pattern Combinators".

Synopsis

Documentation

type BP n t0 t1 = Bit n -> t0 -> (Bit 1, t1) Source #

Bit pattern

literal :: forall n t. KnownNat n => Bit n -> BP n t t Source #

Bit pattern to match literal

variable :: forall n t. BP n (Bit n -> t) t Source #

Bit pattern to bind a variable

(<#>) :: KnownNat n0 => BP n0 t0 t1 -> BP n1 t1 t2 -> BP (n0 + n1) t0 t2 infixl 9 Source #

Sequentially combine bit patterns

(==>) :: BP n t (Action ()) -> t -> Bit n -> Action () infix 7 Source #

A case alternative (pattern plus a right-hand-side)

match :: Bit n -> [Bit n -> Action ()] -> Action () Source #

Match case subject against set of a case alternatives