chalkboard-0.2: Combinators for building and processing 2D images.

MaintainerAndy Gill <>




Boards are the principal type for our images. The are conceptually functions from 2D coordinates to values, typically a color.

Common Boards include

  • Board Bool -- A masking Board, or region.
  • Board RGB -- Color Board
  • Board (Alpha RGB) -- A Color Board with alpha (transparency) values.
  • Board (Maybe a) -- A Board with binary transparency.
  • Board (Maybe Color) -- A Color Board with binary transparency.
  • Board Point -- A Board (or field) of Point values.


The Board datatype

data Board a Source

'''Board''' is our primary data type, an infinite flat surface (or R2 field) of values. Conceptually, Board a = Point -> a.


looking up a point on the Board.

lookup :: Board a -> (R, R) -> aSource

Creating Boards.

coord :: Board PointSource

coord field or Board, where each point is its own coordinate in R2.

maskFor :: (Point, Point) -> Board BoolSource

build a rectangle mask or region.

circularMaskFor :: Point -> R -> Board BoolSource

build a circular mask or region, with a circle of radius R, and center Point.

Translations on a Board.

scale :: Scale c => R -> c -> cSource

scaleXY :: (R, R) -> Board a -> Board aSource

A non-overloaded version of scale which takes a independent x and y coordinate.

move :: (R, R) -> Board a -> Board aSource

move a Board by specified vector.

rotate :: Radian -> Board a -> Board aSource

rotate the Board.

crop :: Board Bool -> Board a -> Board (Maybe a)Source

crop crops a Board, based on a masking Board.

class Functor f => Applicative f where

A functor with application.

Instances should satisfy the following laws:

pure id <*> v = v
pure (.) <*> u <*> v <*> w = u <*> (v <*> w)
pure f <*> pure x = pure (f x)
u <*> pure y = pure ($ y) <*> u
ignore left value
u *> v = pure (const id) <*> u <*> v
ignore right value
u <* v = pure const <*> u <*> v

The Functor instance should satisfy

      fmap f x = pure f <*> x

If f is also a Monad, define pure = return and (<*>) = ap.

Minimal complete definition: pure and <*>.


pure :: a -> f a

Lift a value.

(<*>) :: f (a -> b) -> f a -> f b

Sequential application.

(*>) :: f a -> f b -> f b

Sequence actions, discarding the value of the first argument.

(<*) :: f a -> f b -> f a

Sequence actions, discarding the value of the second argument.