cryptol-2.9.1: Cryptol: The Language of Cryptography

Safe HaskellSafe
LanguageHaskell2010

Cryptol.Utils.Patterns

Synopsis

Documentation

newtype Match b Source #

Constructors

Match (forall r. r -> (b -> r) -> r) 
Instances
Monad Match Source # 
Instance details

Defined in Cryptol.Utils.Patterns

Methods

(>>=) :: Match a -> (a -> Match b) -> Match b #

(>>) :: Match a -> Match b -> Match b #

return :: a -> Match a #

fail :: String -> Match a #

Functor Match Source # 
Instance details

Defined in Cryptol.Utils.Patterns

Methods

fmap :: (a -> b) -> Match a -> Match b #

(<$) :: a -> Match b -> Match a #

MonadFail Match Source # 
Instance details

Defined in Cryptol.Utils.Patterns

Methods

fail :: String -> Match a #

Applicative Match Source # 
Instance details

Defined in Cryptol.Utils.Patterns

Methods

pure :: a -> Match a #

(<*>) :: Match (a -> b) -> Match a -> Match b #

liftA2 :: (a -> b -> c) -> Match a -> Match b -> Match c #

(*>) :: Match a -> Match b -> Match b #

(<*) :: Match a -> Match b -> Match a #

Alternative Match Source # 
Instance details

Defined in Cryptol.Utils.Patterns

Methods

empty :: Match a #

(<|>) :: Match a -> Match a -> Match a #

some :: Match a -> Match [a] #

many :: Match a -> Match [a] #

MonadPlus Match Source # 
Instance details

Defined in Cryptol.Utils.Patterns

Methods

mzero :: Match a #

mplus :: Match a -> Match a -> Match a #

type Pat a b = a -> Match b Source #

(|||) :: Pat a b -> Pat a b -> Pat a b Source #

(&&&) :: Pat a b -> Pat a c -> Pat a (b, c) Source #

Check that a value satisfies multiple patterns. For example, an "as" pattern is (__ &&& p).

(~>) :: Pat a b -> (b -> c) -> Pat a c Source #

Match a value, and modify the result.

(~~>) :: Pat a b -> c -> Pat a c Source #

Match a value, and return the given result

(<~) :: (a -> b) -> Pat b c -> Pat a c Source #

View pattern.

__ :: Pat a a Source #

Variable pattern.

succeed :: a -> Pat x a Source #

Constant pattern.

checkThat :: (a -> Bool) -> Pat a () Source #

Predicate pattern

lit :: Eq a => a -> Pat a () Source #

Check for exact value.

matchDefault :: a -> Match a -> a Source #

Match a pattern, using the given default if valure.

match :: Match a -> a Source #

Match an irrefutable pattern. Crashes on faliure.

list :: [Pat a b] -> Pat [a] [b] Source #

(><) :: Pat a b -> Pat x y -> Pat (a, x) (b, y) Source #

class Matches thing pats res | pats -> thing res where Source #

Methods

matches :: thing -> pats -> Match res Source #

Instances
(f ~ Pat a a1', a1 ~ Pat a1' r1) => Matches a (f, a1) r1 Source # 
Instance details

Defined in Cryptol.Utils.Patterns

Methods

matches :: a -> (f, a1) -> Match r1 Source #

(op ~ Pat a (a1', a2'), a1 ~ Pat a1' r1, a2 ~ Pat a2' r2) => Matches a (op, a1, a2) (r1, r2) Source # 
Instance details

Defined in Cryptol.Utils.Patterns

Methods

matches :: a -> (op, a1, a2) -> Match (r1, r2) Source #

(op ~ Pat a (a1', a2', a3'), a1 ~ Pat a1' r1, a2 ~ Pat a2' r2, a3 ~ Pat a3' r3) => Matches a (op, a1, a2, a3) (r1, r2, r3) Source # 
Instance details

Defined in Cryptol.Utils.Patterns

Methods

matches :: a -> (op, a1, a2, a3) -> Match (r1, r2, r3) Source #