codeworld-tasks
Safe HaskellNone
LanguageHaskell2010

CodeWorld.Test

Description

Module exporting all functionality needed for running tests on student submissions.

Synopsis

Normalized Pictures

Data Type

data AbstractPicture Source #

A more abstract syntax tree representing images. Comparisons between values of this type are intentionally fuzzy: Concrete number or point values are abstracted into coarser categories. Notably, those values are not lost and can be retrieved if desired.

The constructors of this type are not exposed. Values are built using the CodeWorld API.

Instances

Instances details
Data AbstractPicture Source # 
Instance details

Defined in CodeWorld.Test.Abstract

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> AbstractPicture -> c AbstractPicture #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c AbstractPicture #

toConstr :: AbstractPicture -> Constr #

dataTypeOf :: AbstractPicture -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c AbstractPicture) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AbstractPicture) #

gmapT :: (forall b. Data b => b -> b) -> AbstractPicture -> AbstractPicture #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> AbstractPicture -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> AbstractPicture -> r #

gmapQ :: (forall d. Data d => d -> u) -> AbstractPicture -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> AbstractPicture -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> AbstractPicture -> m AbstractPicture #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> AbstractPicture -> m AbstractPicture #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> AbstractPicture -> m AbstractPicture #

Show AbstractPicture Source # 
Instance details

Defined in CodeWorld.Test.Abstract

Eq AbstractPicture Source # 
Instance details

Defined in CodeWorld.Test.Abstract

Ord AbstractPicture Source # 
Instance details

Defined in CodeWorld.Test.Abstract

Helpers for defining AbstractPictures

You'll want to compare something to or query for some abstract picture frequently in tests, e.g. ask if there's a *yellow circle* somewhere in the image (but the size of the circle is not important).

The following functions can be used to build such a generalized image directly, instead of creating a normal picture, then abstracting it.

someCircle :: AbstractPicture Source #

Draw an abstract, hollow circle.

someSolidCircle :: AbstractPicture Source #

Draw an abstract, filled in circle.

someSquare :: AbstractPicture Source #

Draw an abstract, hollow square.

someRectangle :: AbstractPicture Source #

Draw an abstract, hollow rectangle. This is an alias for someSquare.

someTallRectangle :: AbstractPicture Source #

Draw an abstract, hollow rectangle that is taller than wide.

someWideRectangle :: AbstractPicture Source #

Draw an abstract, hollow rectangle that is wider than tall.

someSolidSquare :: AbstractPicture Source #

Draw an abstract, filled in square.

someSolidRectangle :: AbstractPicture Source #

Draw an abstract, filled in rectangle. This is an alias for someSolidSquare.

someTallSolidRectangle :: AbstractPicture Source #

Draw an abstract, filled in rectangle that is taller than wide.

someWideSolidRectangle :: AbstractPicture Source #

Draw an abstract, filled in rectangle that is wider than tall.

someCurve :: Int -> AbstractPicture Source #

Draw an abstract, open curve with this many segments.

someSolidCurve :: Int -> AbstractPicture Source #

Draw an abstract, filled in and closed curve with this many segments.

withColor :: Color -> AbstractPicture -> AbstractPicture Source #

Provide an abstract shape with a specific color. The color will be treated as equal to any color with *similar* HSL values. (See isSameColor for more information)

someColor :: AbstractPicture -> AbstractPicture Source #

Provide an abstract shape with a wildcard color. The color will be treated as equal to any other color.

rotatedHalf :: AbstractPicture -> AbstractPicture Source #

Rotate an abstract shape by between a quarter and half turn.

rotatedQuarter :: AbstractPicture -> AbstractPicture Source #

Rotate an abstract shape by up to a quarter turn.

rotatedThreeQuarters :: AbstractPicture -> AbstractPicture Source #

Rotate an abstract shape by between a half and three quarters turn.

rotatedUpToFull :: AbstractPicture -> AbstractPicture Source #

Rotate an abstract shape by between a three quarters and up to a full turn. The full turn itself is excluded.

larger :: AbstractPicture -> AbstractPicture Source #

Enlarge an abstract shape. Both directions are scaled an equal amount.

largerX :: AbstractPicture -> AbstractPicture Source #

Enlarge an abstract shape in X-direction. The Y-direction is unchanged.

largerY :: AbstractPicture -> AbstractPicture Source #

Enlarge an abstract shape in Y-direction. The X-direction is unchanged.

smaller :: AbstractPicture -> AbstractPicture Source #

Shrink an abstract shape. Both directions are scaled an equal amount.

smallerX :: AbstractPicture -> AbstractPicture Source #

Shrink an abstract shape in X-direction. The Y-direction is unchanged.

smallerY :: AbstractPicture -> AbstractPicture Source #

Shrink an abstract shape in Y-direction. The X-direction is unchanged.

(.&.) :: AbstractPicture -> AbstractPicture -> AbstractPicture Source #

Compose two abstract pictures.

Queries on AbstractPictures

Functions for retrieving parameters of an AbstractPicture. For each parameter there is an abstract and a concrete version. The concrete version simply removes the abstract type wrapper and returns the contained value.

These are meant to be used on non-composite values only (no & or pictures), meaning only one value is returned. Use the functions in Queries on Components if retrieval of all parameters of a specific kind is desired.

contains :: AbstractPicture -> AbstractPicture -> Bool Source #

True if the first image contains the second image. This uses fuzzy comparison.

count :: AbstractPicture -> AbstractPicture -> Int Source #

Returns how often a subpicture appears in the image.

getColor :: AbstractPicture -> Maybe AbsColor Source #

Returns the AbsColor of the image. Nothing if it is one of logo or coordinate plane. Black if none.

getRotation :: AbstractPicture -> Maybe Angle Source #

Returns abstract rotation of the image if it has any.

getExactRotation :: AbstractPicture -> Double Source #

Returns actual rotation of the image if it has any.

getScalingFactors :: AbstractPicture -> (Factor, Factor) Source #

Returns the abstract scaling factors of the image. Neutral factors if none.

getExactScalingFactors :: AbstractPicture -> (Double, Double) Source #

Returns actual scaling factors of the image. (1,1) if none.

getTranslation :: AbstractPicture -> (Position, Position) Source #

Returns the abstract translation of the image. Neutral translation if none.

getExactTranslation :: AbstractPicture -> (Double, Double) Source #

Returns the actual translation of the image. (0,0) if none.

getReflectionAngle :: AbstractPicture -> Maybe Angle Source #

Returns abstract reflection of the image if it has any.

getExactReflectionAngle :: AbstractPicture -> Double Source #

Returns actual reflection of the image if it has any.

getCircleRadius :: AbstractPicture -> Maybe Size Source #

Returns abstract radius of the image if it actually a circle or circle segment.

getExactCircleRadius :: AbstractPicture -> Maybe Double Source #

Returns actual radius of the image if it actually a circle or circle segment.

getRectangleLengths :: AbstractPicture -> Maybe (Size, Size) Source #

Returns abstract side lengths of the image if it actually a rectangle.

getExactRectangleLengths :: AbstractPicture -> Maybe (Double, Double) Source #

Returns actual side lengths of the image if it actually a rectangle.

getExactPointList :: AbstractPicture -> [Point] Source #

Returns actual list of points in the image if it is a "free shape", [] otherwise.

Abstract Representations of CodeWorld Types

Abstract versions of data types used as parameters in CodeWorld's Picture type. Retain the concrete value, unless stated otherwise, so it can be extracted if necessary.

data Size Source #

Abstract representation of radii and side lengths. All values are considered equal.

Instances

Instances details
Data Size Source # 
Instance details

Defined in CodeWorld.Test.AbsTypes

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Size -> c Size #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Size #

toConstr :: Size -> Constr #

dataTypeOf :: Size -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Size) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Size) #

gmapT :: (forall b. Data b => b -> b) -> Size -> Size #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Size -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Size -> r #

gmapQ :: (forall d. Data d => d -> u) -> Size -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Size -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Size -> m Size #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Size -> m Size #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Size -> m Size #

Show Size Source # 
Instance details

Defined in CodeWorld.Test.AbsTypes

Methods

showsPrec :: Int -> Size -> ShowS #

show :: Size -> String #

showList :: [Size] -> ShowS #

Eq Size Source # 
Instance details

Defined in CodeWorld.Test.AbsTypes

Methods

(==) :: Size -> Size -> Bool #

(/=) :: Size -> Size -> Bool #

Ord Size Source # 
Instance details

Defined in CodeWorld.Test.AbsTypes

Methods

compare :: Size -> Size -> Ordering #

(<) :: Size -> Size -> Bool #

(<=) :: Size -> Size -> Bool #

(>) :: Size -> Size -> Bool #

(>=) :: Size -> Size -> Bool #

max :: Size -> Size -> Size #

min :: Size -> Size -> Size #

data ShapeKind Source #

Abstract representation of line drawing and filling mode. Differentiates between the three common shapes: standard, thick, filled.

This does not retain the concrete value.

Instances

Instances details
Data ShapeKind Source # 
Instance details

Defined in CodeWorld.Test.AbsTypes

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ShapeKind -> c ShapeKind #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c ShapeKind #

toConstr :: ShapeKind -> Constr #

dataTypeOf :: ShapeKind -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c ShapeKind) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ShapeKind) #

gmapT :: (forall b. Data b => b -> b) -> ShapeKind -> ShapeKind #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ShapeKind -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ShapeKind -> r #

gmapQ :: (forall d. Data d => d -> u) -> ShapeKind -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> ShapeKind -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> ShapeKind -> m ShapeKind #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ShapeKind -> m ShapeKind #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ShapeKind -> m ShapeKind #

Show ShapeKind Source # 
Instance details

Defined in CodeWorld.Test.AbsTypes

Eq ShapeKind Source # 
Instance details

Defined in CodeWorld.Test.AbsTypes

Ord ShapeKind Source # 
Instance details

Defined in CodeWorld.Test.AbsTypes

data Angle Source #

Abstract representation of angles. Rotation is divided into four equal sections on the unit circle.

Instances

Instances details
Data Angle Source # 
Instance details

Defined in CodeWorld.Test.AbsTypes

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Angle -> c Angle #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Angle #

toConstr :: Angle -> Constr #

dataTypeOf :: Angle -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Angle) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Angle) #

gmapT :: (forall b. Data b => b -> b) -> Angle -> Angle #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Angle -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Angle -> r #

gmapQ :: (forall d. Data d => d -> u) -> Angle -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Angle -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Angle -> m Angle #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Angle -> m Angle #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Angle -> m Angle #

Show Angle Source # 
Instance details

Defined in CodeWorld.Test.AbsTypes

Methods

showsPrec :: Int -> Angle -> ShowS #

show :: Angle -> String #

showList :: [Angle] -> ShowS #

Eq Angle Source # 
Instance details

Defined in CodeWorld.Test.AbsTypes

Methods

(==) :: Angle -> Angle -> Bool #

(/=) :: Angle -> Angle -> Bool #

Ord Angle Source # 
Instance details

Defined in CodeWorld.Test.AbsTypes

Methods

compare :: Angle -> Angle -> Ordering #

(<) :: Angle -> Angle -> Bool #

(<=) :: Angle -> Angle -> Bool #

(>) :: Angle -> Angle -> Bool #

(>=) :: Angle -> Angle -> Bool #

max :: Angle -> Angle -> Angle #

min :: Angle -> Angle -> Angle #

data Factor Source #

Abstract representation of scaling factors. Considers values equal if both are scaled larger, smaller or not at all.

Instances

Instances details
Data Factor Source # 
Instance details

Defined in CodeWorld.Test.AbsTypes

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Factor -> c Factor #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Factor #

toConstr :: Factor -> Constr #

dataTypeOf :: Factor -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Factor) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Factor) #

gmapT :: (forall b. Data b => b -> b) -> Factor -> Factor #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Factor -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Factor -> r #

gmapQ :: (forall d. Data d => d -> u) -> Factor -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Factor -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Factor -> m Factor #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Factor -> m Factor #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Factor -> m Factor #

Show Factor Source # 
Instance details

Defined in CodeWorld.Test.AbsTypes

Eq Factor Source # 
Instance details

Defined in CodeWorld.Test.AbsTypes

Methods

(==) :: Factor -> Factor -> Bool #

(/=) :: Factor -> Factor -> Bool #

Ord Factor Source # 
Instance details

Defined in CodeWorld.Test.AbsTypes

data Position Source #

Abstract representation of translations. Considers values equal if both are translated by a positive or negative number or not at all.

Instances

Instances details
Data Position Source # 
Instance details

Defined in CodeWorld.Test.AbsTypes

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Position -> c Position #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Position #

toConstr :: Position -> Constr #

dataTypeOf :: Position -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Position) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Position) #

gmapT :: (forall b. Data b => b -> b) -> Position -> Position #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Position -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Position -> r #

gmapQ :: (forall d. Data d => d -> u) -> Position -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Position -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Position -> m Position #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Position -> m Position #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Position -> m Position #

Num Position Source # 
Instance details

Defined in CodeWorld.Test.AbsTypes

Show Position Source # 
Instance details

Defined in CodeWorld.Test.AbsTypes

Eq Position Source # 
Instance details

Defined in CodeWorld.Test.AbsTypes

Ord Position Source # 
Instance details

Defined in CodeWorld.Test.AbsTypes

data AbsPoint Source #

Abstract representation of points in 2D space. All values are considered equal.

Instances

Instances details
Data AbsPoint Source # 
Instance details

Defined in CodeWorld.Test.AbsTypes

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> AbsPoint -> c AbsPoint #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c AbsPoint #

toConstr :: AbsPoint -> Constr #

dataTypeOf :: AbsPoint -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c AbsPoint) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AbsPoint) #

gmapT :: (forall b. Data b => b -> b) -> AbsPoint -> AbsPoint #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> AbsPoint -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> AbsPoint -> r #

gmapQ :: (forall d. Data d => d -> u) -> AbsPoint -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> AbsPoint -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> AbsPoint -> m AbsPoint #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> AbsPoint -> m AbsPoint #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> AbsPoint -> m AbsPoint #

Show AbsPoint Source # 
Instance details

Defined in CodeWorld.Test.AbsTypes

Eq AbsPoint Source # 
Instance details

Defined in CodeWorld.Test.AbsTypes

Ord AbsPoint Source # 
Instance details

Defined in CodeWorld.Test.AbsTypes

data AbsColor Source #

Abstract representation of Color. Equal if each HSLA parameter has an acceptable distance from those of the other color.

Instances

Instances details
Data AbsColor Source # 
Instance details

Defined in CodeWorld.Test.AbsTypes

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> AbsColor -> c AbsColor #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c AbsColor #

toConstr :: AbsColor -> Constr #

dataTypeOf :: AbsColor -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c AbsColor) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AbsColor) #

gmapT :: (forall b. Data b => b -> b) -> AbsColor -> AbsColor #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> AbsColor -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> AbsColor -> r #

gmapQ :: (forall d. Data d => d -> u) -> AbsColor -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> AbsColor -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> AbsColor -> m AbsColor #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> AbsColor -> m AbsColor #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> AbsColor -> m AbsColor #

Show AbsColor Source # 
Instance details

Defined in CodeWorld.Test.AbsTypes

Eq AbsColor Source # 
Instance details

Defined in CodeWorld.Test.AbsTypes

Ord AbsColor Source # 
Instance details

Defined in CodeWorld.Test.AbsTypes

isSameColor :: AbsColor -> AbsColor -> Bool Source #

A more strict equality test for AbsColor. Contrary to the Eq instance, this only succeeds if both colors are completely identical in their HSLA values.

Spatial View

Aside from normalizing the picture and retrieving (individual) parameters, we also want to inspect how components are laid out on the canvas and query their parameters as a whole. The following data types and functions implement this more zoomed out approach.

type SpatialQuery = [RelativePicSpec] -> Bool Source #

Alias for queries on spatial relationships.

isSouthOf :: AbstractPicture -> AbstractPicture -> SpatialQuery Source #

True if the first argument is below the second and aligned on the X-axis.

isNorthOf :: AbstractPicture -> AbstractPicture -> SpatialQuery Source #

True if the first argument is above the second and aligned on the X-axis.

isWestOf :: AbstractPicture -> AbstractPicture -> SpatialQuery Source #

True if the first argument is left of the second and aligned on the Y-axis.

isEastOf :: AbstractPicture -> AbstractPicture -> SpatialQuery Source #

True if the first argument is right of the second and aligned on the Y-axis.

isSouthEastOf :: AbstractPicture -> AbstractPicture -> SpatialQuery Source #

True if the first argument is below and to the right of the second.

isSouthWestOf :: AbstractPicture -> AbstractPicture -> SpatialQuery Source #

True if the first argument is below and to the left of the second.

isNorthEastOf :: AbstractPicture -> AbstractPicture -> SpatialQuery Source #

True if the first argument is above and to the right of the second.

isNorthWestOf :: AbstractPicture -> AbstractPicture -> SpatialQuery Source #

True if the first argument is above and to the left of the second.

isBelow :: AbstractPicture -> AbstractPicture -> SpatialQuery Source #

True if the first argument is below the second, ignoring horizontal positioning.

isAbove :: AbstractPicture -> AbstractPicture -> SpatialQuery Source #

True if the first argument is above the second, ignoring horizontal positioning.

isLeftOf :: AbstractPicture -> AbstractPicture -> SpatialQuery Source #

True if the first argument is left of the second, ignoring vertical positioning.

isRightOf :: AbstractPicture -> AbstractPicture -> SpatialQuery Source #

True if the first argument is right of the second, ignoring vertical positioning.

atSamePosition :: AbstractPicture -> AbstractPicture -> SpatialQuery Source #

True if the first argument is at the same position as the second.

Predicates on Components

data Components Source #

Abstract representation of a picture in terms of its components and the pairwise spatial positioning between them.

type StaticImage = (Picture, Components) Source #

The environment for tests on still images.

type Animation = Double -> StaticImage Source #

The environment for tests on animations.

containsElem :: MonadReader StaticImage m => AbstractPicture -> m Bool Source #

True if image contains at least this subpicture and optionally something else.

containsElems :: MonadReader StaticImage m => [AbstractPicture] -> m Bool Source #

True if image contains at least these subpictures and optionally something else.

containsExactElems :: MonadReader StaticImage m => [AbstractPicture] -> m Bool Source #

True if image contains exactly these subpictures and nothing else.

thisOften :: MonadReader StaticImage m => AbstractPicture -> Int -> m Bool Source #

True if image contains this subpicture exactly this many times.

atLeast :: MonadReader StaticImage m => AbstractPicture -> Int -> m Bool Source #

True if image contains this subpicture at least this many times.

atMost :: MonadReader StaticImage m => AbstractPicture -> Int -> m Bool Source #

True if image contains this subpicture at most many times.

inRangeOf :: MonadReader StaticImage m => AbstractPicture -> (Int, Int) -> m Bool Source #

True if amount of times this subpicture is contained in the image lies in the specified range.

hasRelation :: MonadReader StaticImage m => SpatialQuery -> m Bool Source #

True if image contains the specified spatial relations. Used with corresponding functions like isNorthOf, isLeftOf, etc.

(<||>) :: MonadReader env m => m Bool -> m Bool -> m Bool Source #

At least one of two predicates evaluates to True.

(<&&>) :: MonadReader env m => m Bool -> m Bool -> m Bool Source #

Both predicates evaluate to True.

(<^^>) :: MonadReader env m => m Bool -> m Bool -> m Bool Source #

Only one of two predicates evaluate to True (XOR).

option :: MonadReader env m => m Bool -> m Bool -> m Bool Source #

Alias for (<||>)

options :: MonadReader env m => [m Bool] -> m Bool Source #

At least one of many predicates evaluates to True.

ifThen :: MonadReader env m => m Bool -> m Bool -> m Bool Source #

Runs the first predicate p, then the second q if p evaluated to True. Does not run q if p evaluates to False.

oneOf :: MonadReader env m => (a -> m Bool) -> [a] -> m Bool Source #

The predicate is satisfied by at least one of the given options. Use when there's multiple shape primitives a student could use to solve the task.

Queries on Components

rawImage :: MonadReader StaticImage m => m Picture Source #

Returns the unmodified Picture.

normalizedImage :: MonadReader StaticImage m => m Picture Source #

Returns the normalized Picture.

findAll :: MonadReader StaticImage m => (AbstractPicture -> Bool) -> m [AbstractPicture] Source #

Returns all subpictures satisfying the predicate. (translation is removed)

findAllThen :: MonadReader StaticImage m => (AbstractPicture -> Bool) -> (AbstractPicture -> a) -> m [a] Source #

Finds all subpictures satisfying a predicate, then applies a function. (translation is removed)

findAllTranslated :: MonadReader StaticImage m => (AbstractPicture -> Bool) -> m [AbstractPicture] Source #

Returns all subpictures satisfying the predicate. (includes translation)

findAllTranslatedThen :: MonadReader StaticImage m => (AbstractPicture -> Bool) -> (AbstractPicture -> a) -> m [a] Source #

Finds all subpictures satisfying a predicate, then applies a function. (includes translation)

findFirst :: MonadReader StaticImage m => (AbstractPicture -> Bool) -> m (Maybe AbstractPicture) Source #

Returns the first subpictures satisfying the predicate if it exists. (translation is removed)

findFirstThen :: MonadReader StaticImage m => (AbstractPicture -> Bool) -> (AbstractPicture -> a) -> m (Maybe a) Source #

Finds the first subpictures satisfying a predicate, then applies a function if it exists. (translation is removed)

findFirstTranslated :: MonadReader StaticImage m => (AbstractPicture -> Bool) -> m (Maybe AbstractPicture) Source #

Returns the first subpicture satisfying the predicate if it exists. (includes translation)

findFirstTranslatedThen :: MonadReader StaticImage m => (AbstractPicture -> Bool) -> (AbstractPicture -> a) -> m (Maybe a) Source #

Finds the first subpicture satisfying a predicate, then applies a function if it exists. (includes translation)

Helpers for Animations

mapAnimation :: MonadReader Animation m => (StaticImage -> a) -> m (Double -> a) Source #

Returns the animation environment with its output mapped over by the argument.

atTime :: forall (m :: Type -> Type) a. Double -> ReaderT StaticImage m a -> ReaderT Animation m a Source #

Samples the animation at the given time point and applies a predicate or query to it.

rawImagesAt :: forall (m :: Type -> Type). Monad m => [Double] -> ReaderT Animation m [Picture] Source #

Samples the animation at multiple time points and returns a list of unmodified results.

normalizedImagesAt :: forall (m :: Type -> Type). Monad m => [Double] -> ReaderT Animation m [Picture] Source #

Samples the animation at multiple time points and returns a list of normalized results.

anyAt :: [Double] -> Reader StaticImage Bool -> Reader Animation Bool Source #

Samples the animation at multiple time points and applies a predicate to each image. Returns True if any sample satisfied the predicate.

allAt :: [Double] -> Reader StaticImage Bool -> Reader Animation Bool Source #

Samples the animation at multiple time points and applies a predicate to each image. Returns True if all samples satisfied the predicate.

allAtWithTime :: [Double] -> (Double -> Reader StaticImage Bool) -> Reader Animation Bool Source #

Samples the animation at multiple time points and applies a predicate dependent on the current time point to each image. Returns True if all samples satisfied the predicate.

noneAt :: [Double] -> Reader StaticImage Bool -> Reader Animation Bool Source #

Samples the animation at multiple time points and applies a predicate to each image. Returns True if none of the samples satisfied the predicate.

queryAt :: forall (m :: Type -> Type) a. Applicative m => [Double] -> ReaderT StaticImage m a -> ReaderT Animation m [a] Source #

Samples the animation at multiple time points and applies a predicate or query to each image, then returns a list of results.

Running Tests

complain :: String -> Reader env Bool -> ReaderT env (Except String) () Source #

Builds a fallible test given an error message and a predicate.

testPicture :: Picture -> ReaderT StaticImage (Except String) () -> String Source #

Executes the given test suite on a static image and returns the error message of the first failed test or the empty String if all tests passed.

testAnimation :: (Double -> Picture) -> ReaderT Animation (Except String) () -> String Source #

Executes the given test suite on an animation and returns the error message of the first failed test or the empty String if all tests passed.

Strict Pictures

Exposed internals of the student facing Picture type. This is useful if specific attributes can be determined directly from the un-normalized syntax tree. Primitives from Uniplate can then be employed to generically traverse the structure.

Type Internals

data Picture where Source #

Student facing, basic picture type. A value of this type can be build using the CodeWorld API.

CodeWorld.Test also exports pattern synonyms for all contained constructors. This allows for easier pattern matching in generic traversals.

Bundled Patterns

pattern Rectangle :: Double -> Double -> Picture 
pattern ThickRectangle :: Double -> Double -> Double -> Picture 
pattern SolidRectangle :: Double -> Double -> Picture 
pattern Circle :: Double -> Picture 
pattern ThickCircle :: Double -> Double -> Picture 
pattern SolidCircle :: Double -> Picture 
pattern Polygon :: [Point] -> Picture 
pattern SolidPolygon :: [Point] -> Picture 
pattern ThickPolygon :: Double -> [Point] -> Picture 
pattern Polyline :: [Point] -> Picture 
pattern ThickPolyline :: Double -> [Point] -> Picture 
pattern Sector :: Double -> Double -> Double -> Picture 
pattern Arc :: Double -> Double -> Double -> Picture 
pattern ThickArc :: Double -> Double -> Double -> Double -> Picture 
pattern Curve :: [Point] -> Picture 
pattern ThickCurve :: Double -> [Point] -> Picture 
pattern ClosedCurve :: [Point] -> Picture 
pattern SolidClosedCurve :: [Point] -> Picture 
pattern ThickClosedCurve :: Double -> [Point] -> Picture 
pattern Lettering :: Text -> Picture 
pattern StyledLettering :: TextStyle -> Font -> Text -> Picture 
pattern Color :: Color -> Picture -> Picture 
pattern Translate :: Double -> Double -> Picture -> Picture 
pattern Scale :: Double -> Double -> Picture -> Picture 
pattern Dilate :: Double -> Picture -> Picture 
pattern Rotate :: Double -> Picture -> Picture 
pattern Reflect :: Double -> Picture -> Picture 
pattern Clip :: Double -> Double -> Picture -> Picture 
pattern Pictures :: [Picture] -> Picture 
pattern And :: Picture -> Picture -> Picture 
pattern CoordinatePlane :: Picture 
pattern :: Picture 
pattern Blank :: Picture 

Instances

Instances details
MuRef Picture Source # 
Instance details

Defined in CodeWorld.Tasks.Picture

Associated Types

type DeRef Picture 
Instance details

Defined in CodeWorld.Tasks.Picture

type DeRef Picture = ReifyPicture

Methods

mapDeRef :: Applicative f => (forall b. (MuRef b, DeRef Picture ~ DeRef b) => b -> f u) -> Picture -> f (DeRef Picture u)

NFData Picture Source # 
Instance details

Defined in CodeWorld.Tasks.Picture

Methods

rnf :: Picture -> () #

Data Picture Source # 
Instance details

Defined in CodeWorld.Tasks.Picture

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Picture -> c Picture #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Picture #

toConstr :: Picture -> Constr #

dataTypeOf :: Picture -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Picture) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Picture) #

gmapT :: (forall b. Data b => b -> b) -> Picture -> Picture #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Picture -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Picture -> r #

gmapQ :: (forall d. Data d => d -> u) -> Picture -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Picture -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Picture -> m Picture #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Picture -> m Picture #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Picture -> m Picture #

Generic Picture Source # 
Instance details

Defined in CodeWorld.Tasks.Picture

Associated Types

type Rep Picture 
Instance details

Defined in CodeWorld.Tasks.Picture

type Rep Picture = D1 ('MetaData "Picture" "CodeWorld.Tasks.Picture" "codeworld-tasks-0.1.0.0-HDTRBEVOXsr1YTQ9DZ9YSS" 'True) (C1 ('MetaCons "PRec" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ReifyPicture Picture))))

Methods

from :: Picture -> Rep Picture x #

to :: Rep Picture x -> Picture #

Show Picture Source # 
Instance details

Defined in CodeWorld.Tasks.Picture

Eq Picture Source # 
Instance details

Defined in CodeWorld.Tasks.Picture

Methods

(==) :: Picture -> Picture -> Bool #

(/=) :: Picture -> Picture -> Bool #

Ord Picture Source # 
Instance details

Defined in CodeWorld.Tasks.Picture

type DeRef Picture Source # 
Instance details

Defined in CodeWorld.Tasks.Picture

type DeRef Picture = ReifyPicture
type Rep Picture Source # 
Instance details

Defined in CodeWorld.Tasks.Picture

type Rep Picture = D1 ('MetaData "Picture" "CodeWorld.Tasks.Picture" "codeworld-tasks-0.1.0.0-HDTRBEVOXsr1YTQ9DZ9YSS" 'True) (C1 ('MetaCons "PRec" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ReifyPicture Picture))))

Misc. Functions for Pictures

hasInnerPicture :: Picture -> Bool Source #

Returns True if the argument is not a basic shape.

Warning: This is intended to be used on non-composite pictures only. Pictures and And will be treated as a basic picture (i.e. returning False) if used as an argument.

innerPicture :: Picture -> Picture Source #

Returns the contained Picture if the argument is not a basic shape and the argument itself if it is.

Warning: This is intended to be used on non-composite pictures only. Pictures and And will be treated as a basic picture (i.e. the function will behave like id) if used as an argument.

isIn :: Picture -> (Point, Point) -> Bool Source #

Checks if the argument is contained completely inside a box. The coordinates of the box are given as two points with the following format:

  1. (minimum x-value, maximum x-value)
  2. (minimum y-value, maximum y-value)

Test Utility

Miscellaneous functions to use in tests.

Type Conversions

normalize :: Picture -> Picture Source #

Apply a set of rewriting rules to the Picture's syntax tree. The result is a normalized and simplified tree in canonical form, which draws the same image.

normalizeNoOrder :: Picture -> Picture Source #

Same as normalize, but also erases information on which subpictures are drawn in front or behind others.

normalizeAndAbstract :: Picture -> AbstractPicture Source #

Apply a set of rewriting rules to the Picture's syntax tree, then abstract concrete parameters of the nodes, resulting in an AbstractPicture.

The new tree is normalized, simplified and allows for more fuzzy comparisons and queries.

toConcretePicture :: AbstractPicture -> Picture Source #

Transform an AbstractPicture into a Picture. Used to compare normalized sample solution to student submission in plain form. This only makes sense if there's exactly one way to solve the given task.

Functions for Point-based Shapes

Point list based shapes like curve, polyline or polygon differ from other basic shapes in that they can be drawn anywhere instead of only in a fixed position in the origin. Conventional detection of translation, rotation or scaling is thus not possible. These functions help remedy this problem by comparing two point lists to see if a transformation was applied to one to get the other.

wasTranslatedBy :: [Point] -> [Point] -> Maybe Point Source #

Returns which translation needs to be applied to argument 1 to get argument 2. Nothing if the polygons are different.

This can be used to detect translation in point list based shapes.

wasScaledBy :: [Point] -> [Point] -> Maybe (Maybe Double, Maybe Double) Source #

Returns which scaling factors need to be applied to argument 1 to get argument 2.

  • Nothing if the polygons are not similar.
  • Factors themselves can also be Nothing if the factor is undeterminable.

E.g. a possible result could be Just (Just 3, Nothing). This means the second shape is a scaled version of the first and the factor in X-direction is 3, but the factor in Y-direction cannot be determined.

This can be used to detect size scaling in point list based shapes.

wasRotatedBy :: [Point] -> [Point] -> Maybe Double Source #

Returns which rotation needs to be applied to argument 1 to get argument 2. Nothing if it does not exist.

This can be used to detect rotation in point list based shapes.

Animation Test Frame Generators

irregularSamples :: [Double] Source #

An infinite list of animation sampling points. The basis is made of irrational square roots, exp(1) and π. The provided samples should not overlap with any particular phase a student submitted animation may have.

samplesUntil :: Double -> Double -> [Double] Source #

Generates irregular sample frames starting from 0 with given step size and cutoff point. The step size is only an approximation, since the generated values are based on irrational numbers.

CSE detection

testCSE :: Picture -> IO (Maybe String) Source #

Produce student feedback on common subexpression elimination for a Picture value. This compares the results of the Hashcons and Reify methods to determine unused sharing potential. Returns Nothing if all possible terms are shared.

This runs in an IO context, since Reify uses StableName to track sharing.

Re-exports of CodeWorld Interface

Pictures

rectangle :: Double -> Double -> Picture Source #

Draw a hollow, thin rectangle with this length and height.

thickRectangle :: Double -> Double -> Double -> Picture Source #

Draw a hollow rectangle with this line width, length and height. Specifying a negative line width causes a runtime error (mirrors behaviour in CodeWorld editor).

solidRectangle :: Double -> Double -> Picture Source #

Draw a filled in rectangle with this length and height.

circle :: Double -> Picture Source #

Draw a hollow, thin circle with this radius.

thickCircle :: Double -> Double -> Picture Source #

Draw a hollow circle with this line width and radius. Specifying a negative line width or a line width greater than the circles diameter causes a runtime error (mirrors behaviour in CodeWorld editor).

solidCircle :: Double -> Picture Source #

Draw a filled in circle with this radius.

arc :: Double -> Double -> Double -> Picture Source #

Draw a thin, hollow circle segment with these start and end angles and radius.

sector :: Double -> Double -> Double -> Picture Source #

Draw a filled in circle segment with these start and end angles and radius. This would be solidArc following the usual naming scheme.

thickArc :: Double -> Double -> Double -> Double -> Picture Source #

Draw a hollow circle segment with this line width, these start and end angles and radius. Specifying a negative line width causes a runtime error (mirrors behaviour in CodeWorld editor).

curve :: [Point] -> Picture Source #

Draw a thin curve passing through the provided points via a number of Bézier splices.

thickCurve :: Double -> [Point] -> Picture Source #

Draw a curve with this line width passing through the provided points via a number of Bézier splices. Specifying a negative line width causes a runtime error (mirrors behaviour in CodeWorld editor).

closedCurve :: [Point] -> Picture Source #

Same as curve but adds another splice between the start and end points to close the shape.

thickClosedCurve :: Double -> [Point] -> Picture Source #

Same as thickCurve but adds another splice between the start and end points to close the shape.

solidClosedCurve :: [Point] -> Picture Source #

Draw a curve passing through the provided points via a number of Bézier splices. Adds another splice between the start and end points to close the shape and completely fills the enclosed area.

polyline :: [Point] -> Picture Source #

Draw a sequence of thin line segments passing through the provided points.

thickPolyline :: Double -> [Point] -> Picture Source #

Draw a sequence of line segments with this line width passing through the provided points. Specifying a negative line width causes a runtime error (mirrors behaviour in CodeWorld editor).

polygon :: [Point] -> Picture Source #

Same as polyline but adds another segment between the start and end points to close the shape.

thickPolygon :: Double -> [Point] -> Picture Source #

Same as thickPolyline but adds another segment between the start and end points to close the shape.

solidPolygon :: [Point] -> Picture Source #

Draw a sequence of line segments with this line width passing through the provided points and completely fill the enclosed area.

lettering :: Text -> Picture Source #

Render this text into an image.

styledLettering :: TextStyle -> Font -> Text -> Picture Source #

Render this text into an image using the provided TextStyle and Font.

colored :: Color -> Picture -> Picture Source #

Apply this Color to the image.

translated :: Double -> Double -> Picture -> Picture Source #

Move the image in x and y-direction.

scaled :: Double -> Double -> Picture -> Picture Source #

Scale the image in x and y-directions using these modifiers.

dilated :: Double -> Picture -> Picture Source #

Scale the image in both directions using the same modifier.

rotated :: Double -> Picture -> Picture Source #

Rotate the image around the origin using this angle in radians.

reflected :: Double -> Picture -> Picture Source #

Reflect the image across a line through the origin with this angle to the x-axis.

clipped :: Double -> Double -> Picture -> Picture Source #

Clip the image in a rectangle with this length and height.

pictures :: [Picture] -> Picture Source #

Compose a list of Pictures. Equivalent to foldr (&) blank.

(&) :: Picture -> Picture -> Picture Source #

Compose two Pictures. The left argument will be drawn on top of the right argument if they overlap.

coordinatePlane :: Picture Source #

A static image of a coordinate plane extending 5 units in all directions.

:: Picture Source #

A static image of the CodeWorld logo.

blank :: Picture Source #

An empty Picture. This is the identity element of &.

Math

type Point = (Double, Double) Source #

A point in 2D space. Synonym for a pair of Double values.

type Vector = (Double, Double) Source #

A vector in 2D space. Synonym for a pair of Double values.

translatedPoint :: Double -> Double -> Point -> Point Source #

Moves a point in X and Y-directions.

rotatedPoint :: Double -> Point -> Point Source #

Rotates a point around the origin by the given angle in radians.

reflectedPoint :: Double -> Point -> Point Source #

Reflects a point across a line through the origin at this angle from the X-axis.

scaledPoint :: Double -> Double -> Point -> Point Source #

Scales a point by given X and Y scaling factor. Scaling by a negative factor also reflects across that axis.

dilatedPoint :: Double -> Point -> Point Source #

Dilates a point by given uniform scaling factor. Dilating by a negative factor also reflects across the origin.

vectorLength :: Vector -> Double Source #

The length of a vector.

vectorDirection :: Vector -> Double Source #

The counter-clockwise angle of a vector from the X-axis.

vectorSum :: Vector -> Vector -> Vector Source #

The sum of two vectors.

vectorDifference :: Vector -> Vector -> Vector Source #

The difference of two vectors.

scaledVector :: Double -> Double -> Vector -> Vector Source #

Scales a vector by the given scalar multiplier.

rotatedVector :: Double -> Vector -> Vector Source #

Rotates a vector by the given angle in radians.

Text Rendering Modifiers

data Font Source #

Text font type used for stylized message rendering.

Instances

Instances details
NFData Font Source # 
Instance details

Defined in CodeWorld.Tasks.Types

Methods

rnf :: Font -> () #

Data Font Source # 
Instance details

Defined in CodeWorld.Tasks.Types

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Font -> c Font #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Font #

toConstr :: Font -> Constr #

dataTypeOf :: Font -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Font) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Font) #

gmapT :: (forall b. Data b => b -> b) -> Font -> Font #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Font -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Font -> r #

gmapQ :: (forall d. Data d => d -> u) -> Font -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Font -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Font -> m Font #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Font -> m Font #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Font -> m Font #

Generic Font Source # 
Instance details

Defined in CodeWorld.Tasks.Types

Associated Types

type Rep Font 
Instance details

Defined in CodeWorld.Tasks.Types

type Rep Font = D1 ('MetaData "Font" "CodeWorld.Tasks.Types" "codeworld-tasks-0.1.0.0-HDTRBEVOXsr1YTQ9DZ9YSS" 'False) ((C1 ('MetaCons "SansSerif" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Serif" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Monospace" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "Handwriting" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Fancy" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "NamedFont" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))))

Methods

from :: Font -> Rep Font x #

to :: Rep Font x -> Font #

Show Font Source # 
Instance details

Defined in CodeWorld.Tasks.Types

Methods

showsPrec :: Int -> Font -> ShowS #

show :: Font -> String #

showList :: [Font] -> ShowS #

Eq Font Source # 
Instance details

Defined in CodeWorld.Tasks.Types

Methods

(==) :: Font -> Font -> Bool #

(/=) :: Font -> Font -> Bool #

Ord Font Source # 
Instance details

Defined in CodeWorld.Tasks.Types

Methods

compare :: Font -> Font -> Ordering #

(<) :: Font -> Font -> Bool #

(<=) :: Font -> Font -> Bool #

(>) :: Font -> Font -> Bool #

(>=) :: Font -> Font -> Bool #

max :: Font -> Font -> Font #

min :: Font -> Font -> Font #

type Rep Font Source # 
Instance details

Defined in CodeWorld.Tasks.Types

type Rep Font = D1 ('MetaData "Font" "CodeWorld.Tasks.Types" "codeworld-tasks-0.1.0.0-HDTRBEVOXsr1YTQ9DZ9YSS" 'False) ((C1 ('MetaCons "SansSerif" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Serif" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Monospace" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "Handwriting" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Fancy" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "NamedFont" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))))

data TextStyle Source #

Font modifier type used for stylized message rendering.

Constructors

Plain 
Bold 
Italic 

Instances

Instances details
NFData TextStyle Source # 
Instance details

Defined in CodeWorld.Tasks.Types

Methods

rnf :: TextStyle -> () #

Data TextStyle Source # 
Instance details

Defined in CodeWorld.Tasks.Types

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TextStyle -> c TextStyle #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c TextStyle #

toConstr :: TextStyle -> Constr #

dataTypeOf :: TextStyle -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c TextStyle) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TextStyle) #

gmapT :: (forall b. Data b => b -> b) -> TextStyle -> TextStyle #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TextStyle -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TextStyle -> r #

gmapQ :: (forall d. Data d => d -> u) -> TextStyle -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> TextStyle -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> TextStyle -> m TextStyle #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TextStyle -> m TextStyle #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TextStyle -> m TextStyle #

Generic TextStyle Source # 
Instance details

Defined in CodeWorld.Tasks.Types

Associated Types

type Rep TextStyle 
Instance details

Defined in CodeWorld.Tasks.Types

type Rep TextStyle = D1 ('MetaData "TextStyle" "CodeWorld.Tasks.Types" "codeworld-tasks-0.1.0.0-HDTRBEVOXsr1YTQ9DZ9YSS" 'False) (C1 ('MetaCons "Plain" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Bold" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Italic" 'PrefixI 'False) (U1 :: Type -> Type)))
Show TextStyle Source # 
Instance details

Defined in CodeWorld.Tasks.Types

Eq TextStyle Source # 
Instance details

Defined in CodeWorld.Tasks.Types

Ord TextStyle Source # 
Instance details

Defined in CodeWorld.Tasks.Types

type Rep TextStyle Source # 
Instance details

Defined in CodeWorld.Tasks.Types

type Rep TextStyle = D1 ('MetaData "TextStyle" "CodeWorld.Tasks.Types" "codeworld-tasks-0.1.0.0-HDTRBEVOXsr1YTQ9DZ9YSS" 'False) (C1 ('MetaCons "Plain" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Bold" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Italic" 'PrefixI 'False) (U1 :: Type -> Type)))

Colour

data Color Source #

Color type mirroring CodeWorld's equivalent type. The exposed constructors allow for setting colors directly via numerical values.

Instances

Instances details
NFData Color Source # 
Instance details

Defined in CodeWorld.Tasks.Color

Methods

rnf :: Color -> () #

Data Color Source # 
Instance details

Defined in CodeWorld.Tasks.Color

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Color -> c Color #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Color #

toConstr :: Color -> Constr #

dataTypeOf :: Color -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Color) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Color) #

gmapT :: (forall b. Data b => b -> b) -> Color -> Color #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Color -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Color -> r #

gmapQ :: (forall d. Data d => d -> u) -> Color -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Color -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Color -> m Color #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Color -> m Color #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Color -> m Color #

Generic Color Source # 
Instance details

Defined in CodeWorld.Tasks.Color

Associated Types

type Rep Color 
Instance details

Defined in CodeWorld.Tasks.Color

type Rep Color = D1 ('MetaData "Color" "CodeWorld.Tasks.Color" "codeworld-tasks-0.1.0.0-HDTRBEVOXsr1YTQ9DZ9YSS" 'False) ((((C1 ('MetaCons "Yellow" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Green" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Red" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "Blue" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Orange" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Brown" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "Pink" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Purple" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Grey" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "White" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Black" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Bright" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Color)))))) :+: (((C1 ('MetaCons "Brighter" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Double) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Color)) :+: (C1 ('MetaCons "Dull" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Color)) :+: C1 ('MetaCons "Duller" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Double) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Color)))) :+: (C1 ('MetaCons "Light" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Color)) :+: (C1 ('MetaCons "Lighter" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Double) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Color)) :+: C1 ('MetaCons "Dark" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Color))))) :+: ((C1 ('MetaCons "Darker" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Double) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Color)) :+: (C1 ('MetaCons "Translucent" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Color)) :+: C1 ('MetaCons "Mixed" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Color])))) :+: ((C1 ('MetaCons "RGB" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Double) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Double) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Double))) :+: C1 ('MetaCons "HSL" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Double) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Double) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Double)))) :+: (C1 ('MetaCons "RGBA" 'PrefixI 'False) ((S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Double) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Double)) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Double) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Double))) :+: C1 ('MetaCons "AnyColor" 'PrefixI 'False) (U1 :: Type -> Type))))))

Methods

from :: Color -> Rep Color x #

to :: Rep Color x -> Color #

Show Color Source # 
Instance details

Defined in CodeWorld.Tasks.Color

Methods

showsPrec :: Int -> Color -> ShowS #

show :: Color -> String #

showList :: [Color] -> ShowS #

Eq Color Source # 
Instance details

Defined in CodeWorld.Tasks.Color

Methods

(==) :: Color -> Color -> Bool #

(/=) :: Color -> Color -> Bool #

Ord Color Source # 
Instance details

Defined in CodeWorld.Tasks.Color

Methods

compare :: Color -> Color -> Ordering #

(<) :: Color -> Color -> Bool #

(<=) :: Color -> Color -> Bool #

(>) :: Color -> Color -> Bool #

(>=) :: Color -> Color -> Bool #

max :: Color -> Color -> Color #

min :: Color -> Color -> Color #

type Rep Color Source # 
Instance details

Defined in CodeWorld.Tasks.Color

type Rep Color = D1 ('MetaData "Color" "CodeWorld.Tasks.Color" "codeworld-tasks-0.1.0.0-HDTRBEVOXsr1YTQ9DZ9YSS" 'False) ((((C1 ('MetaCons "Yellow" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Green" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Red" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "Blue" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Orange" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Brown" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "Pink" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Purple" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Grey" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "White" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Black" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Bright" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Color)))))) :+: (((C1 ('MetaCons "Brighter" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Double) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Color)) :+: (C1 ('MetaCons "Dull" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Color)) :+: C1 ('MetaCons "Duller" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Double) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Color)))) :+: (C1 ('MetaCons "Light" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Color)) :+: (C1 ('MetaCons "Lighter" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Double) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Color)) :+: C1 ('MetaCons "Dark" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Color))))) :+: ((C1 ('MetaCons "Darker" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Double) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Color)) :+: (C1 ('MetaCons "Translucent" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Color)) :+: C1 ('MetaCons "Mixed" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Color])))) :+: ((C1 ('MetaCons "RGB" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Double) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Double) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Double))) :+: C1 ('MetaCons "HSL" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Double) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Double) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Double)))) :+: (C1 ('MetaCons "RGBA" 'PrefixI 'False) ((S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Double) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Double)) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Double) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Double))) :+: C1 ('MetaCons "AnyColor" 'PrefixI 'False) (U1 :: Type -> Type))))))

type Colour = Color Source #

Alias for Color.

red :: Color Source #

Constant basic colour.

green :: Color Source #

Constant basic colour.

yellow :: Color Source #

Constant basic colour.

black :: Color Source #

Constant basic colour.

white :: Color Source #

Constant basic colour.

blue :: Color Source #

Constant basic colour.

orange :: Color Source #

Constant basic colour.

brown :: Color Source #

Constant basic colour.

pink :: Color Source #

Constant basic colour.

purple :: Color Source #

Constant basic colour.

grey :: Color Source #

Constant basic colour.

gray :: Color Source #

Alias for grey.

mixed :: [Color] -> Color Source #

Blend a new color from the arguments.

lighter :: Double -> Color -> Color Source #

Increase argument's luminosity by a user defined amount.

light :: Color -> Color Source #

Slightly increase argument's luminosity.

darker :: Double -> Color -> Color Source #

Decrease argument's luminosity by a user defined amount.

dark :: Color -> Color Source #

Slightly decrease argument's luminosity.

brighter :: Double -> Color -> Color Source #

Increase argument's saturation by a user defined amount.

bright :: Color -> Color Source #

Slightly increase argument's saturation.

duller :: Double -> Color -> Color Source #

Decrease argument's saturation by a user defined amount.

dull :: Color -> Color Source #

Slightly decrease argument's saturation.

translucent :: Color -> Color Source #

Slightly increase argument's transparency.

assortedColors :: [Color] Source #

An infinite list of different colours.

hue :: Color -> Double Source #

Returns the hue of the argument according to the HSL model.

saturation :: Color -> Double Source #

Returns the saturation of the argument according to the HSL model.

luminosity :: Color -> Double Source #

Returns the luminosity of the argument according to the HSL model.

alpha :: Color -> Double Source #

Returns the transparency of the argument.