forsyde-atom-0.3.0.0: Shallow-embedded DSL for modeling cyber-physical systems
Copyright(c) George Ungureanu 2015-2016
LicenseBSD-style (see the file LICENSE)
Maintainerugeorge@kth.se
Stabilityexperimental
Portabilityportable
Safe HaskellSafe
LanguageHaskell2010

ForSyDe.Atom.ExB.Absent

Description

This module implements the constructors and assocuated utilities of a type which extends the behavior of a function to express "absent events" (see [Halbwachs91]).

The AbstExt type can be used directly with the atom patterns defined in ForSyDe.Atom.ExB, and no helpers or utilities are needed. Example usage:

>>> res21 (+) (Prst 1) (Prst 2)
3
>>> res21 (+) Abst     Abst
>>> filter Abst         (Prst 1)
>>> filter (Prst False) (Prst 1)
>>> filter (Prst True)  (Prst 1)
1
>>> filter' False 1 :: AbstExt Int
>>> filter' True  1 :: AbstExt Int
1
>>> degen 0 (Prst 1)
1
>>> degen 0 Abst
0
>>> ignore11 (+) 1 (Prst 1)
2
>>> ignore11 (+) 1 Abst
1

Incorrect usage (not covered by doctest):

λ> res21 (+) (Prst 1) Abst 
*** Exception: [ExB.Absent] Illegal occurrence of an absent and present event
Synopsis

Documentation

data AbstExt a Source #

The AbstExt type extends the base type with the '(bot)' symbol denoting the absence of a value/event (see [Halbwachs91]).

Constructors

Abst

\(\bot\) denotes the absence of a value

Prst a

\(\top\) a present event with a value

Instances

Instances details
Functor AbstExt Source #

Functor instance. Bypasses the special values and maps a function to the wrapped value.

Instance details

Defined in ForSyDe.Atom.ExB.Absent

Methods

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

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

Applicative AbstExt Source #

Applicative instance, defines a resolution. Check source code for the lifting rules.

Instance details

Defined in ForSyDe.Atom.ExB.Absent

Methods

pure :: a -> AbstExt a #

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

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

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

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

ExB AbstExt Source #

Implements the absent semantics of the extended behavior atoms.

Instance details

Defined in ForSyDe.Atom.ExB.Absent

Methods

extend :: a -> AbstExt a Source #

(/.\) :: (a -> a') -> AbstExt a -> AbstExt a' Source #

(/*\) :: AbstExt (a -> a') -> AbstExt a -> AbstExt a' Source #

(/&\) :: AbstExt Bool -> AbstExt a -> AbstExt a Source #

(/!\) :: a -> AbstExt a -> a Source #

Eq a => Eq (AbstExt a) Source # 
Instance details

Defined in ForSyDe.Atom.ExB.Absent

Methods

(==) :: AbstExt a -> AbstExt a -> Bool #

(/=) :: AbstExt a -> AbstExt a -> Bool #

Read a => Read (AbstExt a) Source #

Reads the '_' character to an Abst and a normal value to Prst-wrapped one.

Instance details

Defined in ForSyDe.Atom.ExB.Absent

Show a => Show (AbstExt a) Source #

Shows Abst as \(\bot\), while a present event is represented with its value.

Instance details

Defined in ForSyDe.Atom.ExB.Absent

Methods

showsPrec :: Int -> AbstExt a -> ShowS #

show :: AbstExt a -> String #

showList :: [AbstExt a] -> ShowS #

(Show a, Plottable a) => Plottable (AbstExt a) Source #

Absent-extended plottable types

Instance details

Defined in ForSyDe.Atom.Utility.Plot

Methods

toCoord :: AbstExt a -> String Source #

Module ForSyDe.Atom.ExB is re-exported for convenience, to access the atom patterns more easily.