quickcheck-state-machine-0.6.0: Test monadic programs using state machine based models

Copyright(C) 2017 ATS Advanced Telematic Systems GmbH
LicenseBSD-style (see the file LICENSE)
MaintainerStevan Andjelkovic <stevan.andjelkovic@here.com>
Stabilityprovisional
Portabilityportable
Safe HaskellSafe
LanguageHaskell2010

Test.StateMachine.Z

Description

This module contains Z-inspried combinators for working with relations. The idea is that they can be used to define concise and showable models. This module is an experiment and will likely change or move to its own package.

Synopsis

Documentation

cons :: a -> [a] -> [a] Source #

union :: Eq a => [a] -> [a] -> [a] infixr 6 Source #

intersect :: Eq a => [a] -> [a] -> [a] infixr 7 Source #

isSubsetOf :: (Eq a, Show a) => [a] -> [a] -> Logic infix 5 Source #

Subset.

>>> boolean ([1, 2] `isSubsetOf` [3, 2, 1])
True

(~=) :: (Eq a, Show a) => [a] -> [a] -> Logic infix 5 Source #

Set equality.

>>> boolean ([1, 1, 2] ~= [2, 1])
True

type Rel a b = [(a, b)] Source #

Relations.

type Fun a b = Rel a b Source #

(Partial) functions.

type (:<->) a b = Rel a b infixr 1 Source #

type (:->) a b = Fun a b infixr 1 Source #

type (:/->) a b = Fun a b infixr 1 Source #

empty :: Rel a b Source #

identity :: [a] -> Rel a a Source #

singleton :: a -> b -> Rel a b Source #

domain :: Rel a b -> [a] Source #

codomain :: Rel a b -> [b] Source #

compose :: Eq b => Rel b c -> Rel a b -> Rel a c Source #

fcompose :: Eq b => Rel a b -> Rel b c -> Rel a c Source #

inverse :: Rel a b -> Rel b a Source #

lookupDom :: Eq a => a -> Rel a b -> [b] Source #

lookupCod :: Eq b => b -> Rel a b -> [a] Source #

(<|) :: Eq a => [a] -> Rel a b -> Rel a b infixr 4 Source #

Domain restriction.

>>> ['a'] <| [ ('a', "apa"), ('b', "bepa") ]
[('a',"apa")]

(|>) :: Eq b => Rel a b -> [b] -> Rel a b infixl 4 Source #

Codomain restriction.

>>> [ ('a', "apa"), ('b', "bepa") ] |> ["apa"]
[('a',"apa")]

(<-|) :: Eq a => [a] -> Rel a b -> Rel a b infixr 4 Source #

Domain substraction.

>>> ['a'] <-| [ ('a', "apa"), ('b', "bepa") ]
[('b',"bepa")]

(|->) :: Eq b => Rel a b -> [b] -> Rel a b infixl 4 Source #

Codomain substraction.

>>> [ ('a', "apa"), ('b', "bepa"), ('c', "cepa") ] |-> ["apa"]
[('b',"bepa"),('c',"cepa")]
>>> [ ('a', "apa"), ('b', "bepa"), ('c', "cepa") ] |-> ["apa", "cepa"]
[('b',"bepa")]
>>> [ ('a', "apa"), ('b', "bepa"), ('c', "cepa") ] |-> ["apa"] |-> ["cepa"]
[('b',"bepa")]

image :: Eq a => Rel a b -> [a] -> [b] Source #

The image of a relation.

(<+) :: (Eq a, Eq b) => Rel a b -> Rel a b -> Rel a b infixr 4 Source #

Overriding.

>>> [('a', "apa")] <+ [('a', "bepa")]
[('a',"bepa")]
>>> [('a', "apa")] <+ [('b', "bepa")]
[('a',"apa"),('b',"bepa")]

(<**>) :: Eq a => Rel a b -> Rel a c -> Rel a (b, c) infixl 4 Source #

Direct product.

(<||>) :: Rel a c -> Rel b d -> Rel (a, b) (c, d) infixl 4 Source #

Parallel product.

isTotalRel :: (Eq a, Show a) => Rel a b -> [a] -> Logic Source #

isSurjRel :: (Eq b, Show b) => Rel a b -> [b] -> Logic Source #

isTotalSurjRel :: (Eq a, Eq b, Show a, Show b) => Rel a b -> [a] -> [b] -> Logic Source #

isPartialFun :: (Eq a, Eq b, Show b) => Rel a b -> Logic Source #

isTotalFun :: (Eq a, Eq b, Show a, Show b) => Rel a b -> [a] -> Logic Source #

isPartialInj :: (Eq a, Eq b, Show a, Show b) => Rel a b -> Logic Source #

isTotalInj :: (Eq a, Eq b, Show a, Show b) => Rel a b -> [a] -> Logic Source #

isPartialSurj :: (Eq a, Eq b, Show b) => Rel a b -> [b] -> Logic Source #

isTotalSurj :: (Eq a, Eq b, Show a, Show b) => Rel a b -> [a] -> [b] -> Logic Source #

isBijection :: (Eq a, Eq b, Show a, Show b) => Rel a b -> [a] -> [b] -> Logic Source #

(!) :: (Eq a, Show a, Show b) => Fun a b -> a -> b Source #

Application.

(!?) :: Eq a => Fun a b -> a -> Maybe b Source #

(.%) :: (Eq a, Eq b, Show a, Show b) => (Fun a b, a) -> (b -> b) -> Fun a b infixr 4 Source #

(.!) :: Rel a b -> a -> (Rel a b, a) infixr 9 Source #

(.=) :: (Eq a, Eq b) => (Rel a b, a) -> b -> Rel a b infix 4 Source #

Assignment.

>>> singleton 'a' "apa" .! 'a' .= "bepa"
[('a',"bepa")]
>>> singleton 'a' "apa" .! 'b' .= "bepa"
[('a',"apa"),('b',"bepa")]