ideas-1.1: Feedback services for intelligent tutoring systems

Portabilityportable (depends on ghc)
Stabilityprovisional
Maintainerbastiaan.heeren@ou.nl
Safe HaskellNone

Ideas.Common.View

Contents

Description

This module defines views on data-types, as described in Canonical Forms in Interactive Exercise Assistants

Synopsis

Documentation

class Category a => Arrow a where

The basic arrow class.

Minimal complete definition: arr and first, satisfying the laws

where

 assoc ((a,b),c) = (a,(b,c))

The other combinators have sensible default definitions, which may be overridden for efficiency.

Methods

arr :: (b -> c) -> a b c

Lift a function to an arrow.

first :: a b c -> a (b, d) (c, d)

Send the first component of the input through the argument arrow, and copy the rest unchanged to the output.

second :: a b c -> a (d, b) (d, c)

A mirror image of first.

The default definition may be overridden with a more efficient version if desired.

(***) :: a b c -> a b' c' -> a (b, b') (c, c')

Split the input between the two argument arrows and combine their output. Note that this is in general not a functor.

The default definition may be overridden with a more efficient version if desired.

(&&&) :: a b c -> a b c' -> a b (c, c')

Fanout: send the input to both argument arrows and combine their output.

The default definition may be overridden with a more efficient version if desired.

class Arrow a => ArrowChoice a where

Choice, for arrows that support it. This class underlies the if and case constructs in arrow notation. Minimal complete definition: left, satisfying the laws

where

 assocsum (Left (Left x)) = Left x
 assocsum (Left (Right y)) = Right (Left y)
 assocsum (Right z) = Right (Right z)

The other combinators have sensible default definitions, which may be overridden for efficiency.

Methods

left :: a b c -> a (Either b d) (Either c d)

Feed marked inputs through the argument arrow, passing the rest through unchanged to the output.

right :: a b c -> a (Either d b) (Either d c)

A mirror image of left.

The default definition may be overridden with a more efficient version if desired.

(+++) :: a b c -> a b' c' -> a (Either b b') (Either c c')

Split the input between the two argument arrows, retagging and merging their outputs. Note that this is in general not a functor.

The default definition may be overridden with a more efficient version if desired.

(|||) :: a b d -> a c d -> a (Either b c) d

Fanin: Split the input between the two argument arrows and merge their outputs.

The default definition may be overridden with a more efficient version if desired.

class Arrow a => ArrowZero a where

Methods

zeroArrow :: a b c

class ArrowZero a => ArrowPlus a where

A monoid on arrows.

Methods

(<+>) :: a b c -> a b c -> a b c

An associative operation with identity zeroArrow.

(>>>) :: Category cat => cat a b -> cat b c -> cat a c

Left-to-right composition

(<<<) :: Category cat => cat b c -> cat a b -> cat a c

Right-to-left composition

IsMatch type class

class IsMatcher f whereSource

Methods

match :: f a b -> a -> Maybe bSource

matcher :: f a b -> Matcher a bSource

matchM :: (Monad m, IsMatcher f) => f a b -> a -> m bSource

generalized monadic variant of match

belongsTo :: IsMatcher f => a -> f a b -> BoolSource

viewEquivalent :: (IsMatcher f, Eq b) => f a b -> a -> a -> BoolSource

viewEquivalentWith :: IsMatcher f => (b -> b -> Bool) -> f a b -> a -> a -> BoolSource

makeMatcher :: (a -> Maybe b) -> Matcher a bSource

IsView type class

class IsMatcher f => IsView f whereSource

Minimal complete definition: toView or both match and build.

Methods

build :: f a b -> b -> aSource

toView :: f a b -> View a bSource

simplify :: IsView f => f a b -> a -> aSource

simplifyWith :: IsView f => (b -> b) -> f a b -> a -> aSource

simplifyWithM :: IsView f => (b -> Maybe b) -> f a b -> a -> aSource

canonical :: IsView f => f a b -> a -> Maybe aSource

canonicalWith :: IsView f => (b -> b) -> f a b -> a -> Maybe aSource

canonicalWithM :: IsView f => (b -> Maybe b) -> f a b -> a -> Maybe aSource

isCanonical :: (IsView f, Eq a) => f a b -> a -> BoolSource

isCanonicalWith :: IsView f => (a -> a -> Bool) -> f a b -> a -> BoolSource

Views

identity :: Category f => f a aSource

makeView :: (a -> Maybe b) -> (b -> a) -> View a bSource

matcherView :: Matcher a b -> (b -> a) -> View a bSource

Isomorphisms

from :: Isomorphism a b -> a -> bSource

to :: Isomorphism a b -> b -> aSource

Lifting with views

class LiftView f whereSource

Methods

liftView :: View a b -> f b -> f aSource

liftViewIn :: View a (b, c) -> f b -> f aSource

Some combinators

swapView :: Isomorphism (a, b) (b, a)Source

listView :: View a b -> View [a] [b]Source

Specialized version of traverseView

traverseView :: Traversable f => View a b -> View (f a) (f b)Source

($<) :: Traversable f => View a (f b) -> View b c -> View a (f c)Source

Packaging a view

data ViewPackage whereSource

Constructors

ViewPackage :: (Show a, Show b, Eq a) => (String -> Maybe a) -> View a b -> ViewPackage 

Instances

Properties on views

propIdempotence :: (Show a, Eq a) => Gen a -> View a b -> PropertySource

propSoundness :: Show a => (a -> a -> Bool) -> Gen a -> View a c -> PropertySource

propNormalForm :: (Show a, Eq a) => Gen a -> View a b -> PropertySource