Copyright | (c) George Ungureanu 2015-2017 |
---|---|

License | BSD-style (see the file LICENSE) |

Maintainer | ugeorge@kth.se |

Stability | experimental |

Portability | portable |

Safe Haskell | Safe |

Language | Haskell2010 |

This module exports the core entities of the extended behavior
layer: interfaces for atoms and common patterns of atoms. It does
*NOT* export any implementation or instantiation of any specific
behavior extension type. For an overview about atoms, layers and
patterns, please refer to the ForSyDe.Atom module documentation.

**IMPORTANT!!!**
see the naming convention rules
on how to interpret, use and develop your own constructors.

## Synopsis

- class Functor b => ExB b where
- res22 :: ExB b => (a1 -> a2 -> (a1', a2')) -> b a1 -> b a2 -> (b a1', b a2')
- filter :: ExB b => b Bool -> b a -> b a
- filter' :: ExB b => Bool -> a -> b a
- degen :: ExB b => a -> b a -> a
- ignore22 :: ExB b => (a1 -> a2 -> a1' -> a2' -> (a1, a2)) -> a1 -> a2 -> b a1' -> b a2' -> (a1, a2)

# Atoms

class Functor b => ExB b where Source #

Class which defines the atoms for the extended behavior layer.

As its name suggests, this layer is extending the behavior of the wrapped entity/function by expanding its domains set with symbols having clearly defined semantics (e.g. special events with known responses).

The types associated with this layer can simply be describes as:

where \(\alpha\) is a base type and \(b\) is the type extension, i.e. a set of symbols with clearly defined semantics.

Extended behavior atoms are functions of these types, defined as
interfaces in the `ExB`

type class.

Extends a value (from a layer below) with a set of symbols with known semantics, as described by a type instantiating this class.

(/.\) :: (a -> a') -> b a -> b a' infixl 4 Source #

Basic functor operator. Lifts a function (from a layer below) into the domain of the extended behavior layer.

(/*\) :: b (a -> a') -> b a -> b a' infixl 4 Source #

Applicative operator. Defines a resolution between two extended behavior symbols.

(/&\) :: b Bool -> b a -> b a infixl 4 Source #

Predicate operator. Generates a defined behavior based on an extended Boolean predicate.

(/!\) :: a -> b a -> a infixl 4 Source #

Degenerate operator. Degenerates a behavior-extended value into a non-extended one (from a layer below), based on a kernel value. Used also to throw exceptions.

# Patterns

:: ExB b | |

=> (a1 -> a2 -> (a1', a2')) | function on values |

-> b a1 | first input |

-> b a2 | second input |

-> (b a1', b a2') | tupled output |

The `res`

behavior pattern lifts a function on values to the
extended behavior domain, and applies a resolution between two
extended behavior symbols.

Constructors: `res[1-8][1-4]`

.

filter' :: ExB b => Bool -> a -> b a Source #

Same as `filter`

but takes base (non-extended) values as
input arguments.

:: ExB b | |

=> (a1 -> a2 -> a1' -> a2' -> (a1, a2)) | function of |

-> a1 | |

-> a2 | |

-> b a1' | |

-> b a2' | |

-> (a1, a2) |

The `ignoreXY`

pattern takes a function of `Y + X`

arguments, `Y`

basic inputs followed by `X`

behavior-extended inputs. The function
is first lifted and applied on the `X`

behavior-extended arguments,
and the result is then degenerated using the `Y`

non-extended
arguments as fallback. The effect is similar to "ignoring" a the
result of a function evaluation if \(\in b\).

The main application of this pattern is as extended behavior wrapper for stateful processes which do not "understand" extended behavior semantics, i.e. it simply propagates the current state \((\in \alpha)\) if the inputs belongs to the set of extended values \((\in b)\).

Constructors: `ignore[1-4][1-4]`

.