cryptol-3.0.0: Cryptol: The Language of Cryptography

Safe Haskell | Safe
Language | Haskell2010

Cryptol.Utils.Patterns

Synopsis

- newtype Match b = Match (forall r. r -> (b -> r) -> r)
- type Pat a b = a -> Match b
- (|||) :: Pat a b -> Pat a b -> Pat a b
- (&&&) :: Pat a b -> Pat a c -> Pat a (b, c)
- (~>) :: Pat a b -> (b -> c) -> Pat a c
- (~~>) :: Pat a b -> c -> Pat a c
- (<~) :: (a -> b) -> Pat b c -> Pat a c
- __ :: Pat a a
- succeed :: a -> Pat x a
- checkThat :: (a -> Bool) -> Pat a ()
- lit :: Eq a => a -> Pat a ()
- matchDefault :: a -> Match a -> a
- match :: Match a -> a
- matchMaybe :: Match a -> Maybe a
- list :: [Pat a b] -> Pat [a] [b]
- (><) :: Pat a b -> Pat x y -> Pat (a, x) (b, y)
- class Matches thing pats res | pats -> thing res where
  - matches :: thing -> pats -> Match res

# Documentation

newtype Match b Source #

Constructors

Match (forall r. r -> (b -> r) -> r) |

#### Instances

Instances details

MonadFail Match Source # |
Instance details Defined in Cryptol.Utils.Patterns Methods fail :: String -> Match a Source #
Alternative Match Source # |
Instance details Defined in Cryptol.Utils.Patterns Methods empty :: Match a Source # (<|>) :: Match a -> Match a -> Match a Source # some :: Match a -> Match [a] Source # many :: Match a -> Match [a] Source #
Applicative Match Source # |
Instance details Defined in Cryptol.Utils.Patterns Methods pure :: a -> Match a Source # (<*>) :: Match (a -> b) -> Match a -> Match b Source # liftA2 :: (a -> b -> c) -> Match a -> Match b -> Match c Source # (*>) :: Match a -> Match b -> Match b Source # (<*) :: Match a -> Match b -> Match a Source #
Functor Match Source # |
Instance details Defined in Cryptol.Utils.Patterns Methods fmap :: (a -> b) -> Match a -> Match b Source # (<$) :: a -> Match b -> Match a Source #
Monad Match Source # |
Instance details Defined in Cryptol.Utils.Patterns Methods (>>=) :: Match a -> (a -> Match b) -> Match b Source # (>>) :: Match a -> Match b -> Match b Source # return :: a -> Match a Source #
MonadPlus Match Source # |
Instance details Defined in Cryptol.Utils.Patterns Methods mzero :: Match a Source # mplus :: Match a -> Match a -> Match a Source #

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.

matchMaybe :: Match a -> Maybe a Source #

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

Instances details

(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 #