codeworld-tasks-0.1.0.0
Safe HaskellNone
LanguageHaskell2010

CodeWorld.Test

Description

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

Synopsis

Normalized Pictures

Data Type

data NormalizedPicture 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 NormalizedPicture Source # 
Instance details

Defined in CodeWorld.Test.Normalize

Methods

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

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

toConstr :: NormalizedPicture -> Constr #

dataTypeOf :: NormalizedPicture -> DataType #

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

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

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

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

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

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

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

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

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

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

Show NormalizedPicture Source # 
Instance details

Defined in CodeWorld.Test.Normalize

Drawable NormalizedPicture Source # 
Instance details

Defined in CodeWorld.Test.Normalize

Methods

rectangle :: Double -> Double -> NormalizedPicture Source #

thickRectangle :: Double -> Double -> Double -> NormalizedPicture Source #

solidRectangle :: Double -> Double -> NormalizedPicture Source #

circle :: Double -> NormalizedPicture Source #

thickCircle :: Double -> Double -> NormalizedPicture Source #

solidCircle :: Double -> NormalizedPicture Source #

arc :: Double -> Double -> Double -> NormalizedPicture Source #

sector :: Double -> Double -> Double -> NormalizedPicture Source #

thickArc :: Double -> Double -> Double -> Double -> NormalizedPicture Source #

curve :: [Point] -> NormalizedPicture Source #

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

closedCurve :: [Point] -> NormalizedPicture Source #

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

solidClosedCurve :: [Point] -> NormalizedPicture Source #

polyline :: [Point] -> NormalizedPicture Source #

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

polygon :: [Point] -> NormalizedPicture Source #

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

solidPolygon :: [Point] -> NormalizedPicture Source #

lettering :: Text -> NormalizedPicture Source #

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

translated :: Double -> Double -> NormalizedPicture -> NormalizedPicture Source #

colored :: Color -> NormalizedPicture -> NormalizedPicture Source #

dilated :: Double -> NormalizedPicture -> NormalizedPicture Source #

scaled :: Double -> Double -> NormalizedPicture -> NormalizedPicture Source #

rotated :: Double -> NormalizedPicture -> NormalizedPicture Source #

reflected :: Double -> NormalizedPicture -> NormalizedPicture Source #

clipped :: Double -> Double -> NormalizedPicture -> NormalizedPicture Source #

pictures :: [NormalizedPicture] -> NormalizedPicture Source #

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

coordinatePlane :: NormalizedPicture Source #

codeWorldLogo :: NormalizedPicture Source #

blank :: NormalizedPicture Source #

Eq NormalizedPicture Source # 
Instance details

Defined in CodeWorld.Test.Normalize

Ord NormalizedPicture Source # 
Instance details

Defined in CodeWorld.Test.Normalize

class Drawable a where Source #

The CodeWorld API as a type class. These are the same functions as seen in CodeWorld. This is used to build syntax trees of the type NormalizedPicture and another internal type used for CSE detection.

The student facing Picture type is not a member of this class to improve readability of type errors.

Methods

rectangle :: Double -> Double -> a Source #

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

thickRectangle :: Double -> Double -> Double -> a 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 -> a Source #

Draw a filled in rectangle with this length and height.

circle :: Double -> a Source #

Draw a hollow, thin circle with this radius.

thickCircle :: Double -> Double -> a 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 -> a Source #

Draw a filled in circle with this radius.

arc :: Double -> Double -> Double -> a Source #

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

sector :: Double -> Double -> Double -> a 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 -> a 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] -> a Source #

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

thickCurve :: Double -> [Point] -> a 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] -> a Source #

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

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

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

solidClosedCurve :: [Point] -> a 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] -> a Source #

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

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

Draw a sequence of line segments with this line width passing through the provided points.

polygon :: [Point] -> a Source #

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

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

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

solidPolygon :: [Point] -> a Source #

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

lettering :: Text -> a Source #

Render this text into an image.

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

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

translated :: Double -> Double -> a -> a Source #

Move the image in x and y-direction.

colored :: Color -> a -> a Source #

Apply this Color to the image.

dilated :: Double -> a -> a Source #

Scale the image in both directions using the same modifier.

scaled :: Double -> Double -> a -> a Source #

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

rotated :: Double -> a -> a Source #

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

reflected :: Double -> a -> a Source #

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

clipped :: Double -> Double -> a -> a Source #

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

pictures :: [a] -> a Source #

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

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

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

coordinatePlane :: a Source #

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

:: a Source #

A static image of the CodeWorld logo.

blank :: a Source #

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

Instances

Instances details
Drawable NormalizedPicture Source # 
Instance details

Defined in CodeWorld.Test.Normalize

Methods

rectangle :: Double -> Double -> NormalizedPicture Source #

thickRectangle :: Double -> Double -> Double -> NormalizedPicture Source #

solidRectangle :: Double -> Double -> NormalizedPicture Source #

circle :: Double -> NormalizedPicture Source #

thickCircle :: Double -> Double -> NormalizedPicture Source #

solidCircle :: Double -> NormalizedPicture Source #

arc :: Double -> Double -> Double -> NormalizedPicture Source #

sector :: Double -> Double -> Double -> NormalizedPicture Source #

thickArc :: Double -> Double -> Double -> Double -> NormalizedPicture Source #

curve :: [Point] -> NormalizedPicture Source #

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

closedCurve :: [Point] -> NormalizedPicture Source #

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

solidClosedCurve :: [Point] -> NormalizedPicture Source #

polyline :: [Point] -> NormalizedPicture Source #

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

polygon :: [Point] -> NormalizedPicture Source #

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

solidPolygon :: [Point] -> NormalizedPicture Source #

lettering :: Text -> NormalizedPicture Source #

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

translated :: Double -> Double -> NormalizedPicture -> NormalizedPicture Source #

colored :: Color -> NormalizedPicture -> NormalizedPicture Source #

dilated :: Double -> NormalizedPicture -> NormalizedPicture Source #

scaled :: Double -> Double -> NormalizedPicture -> NormalizedPicture Source #

rotated :: Double -> NormalizedPicture -> NormalizedPicture Source #

reflected :: Double -> NormalizedPicture -> NormalizedPicture Source #

clipped :: Double -> Double -> NormalizedPicture -> NormalizedPicture Source #

pictures :: [NormalizedPicture] -> NormalizedPicture Source #

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

coordinatePlane :: NormalizedPicture Source #

codeWorldLogo :: NormalizedPicture Source #

blank :: NormalizedPicture Source #

Helpers for defining NormalizedPictures

Using the Drawable API directly does not make much sense with NormalizedPictures, since concrete parameters are abstracted. The following functions can be used instead to build an image more generally.

someCircle :: NormalizedPicture Source #

Draw an abstract, hollow circle.

someSolidCircle :: NormalizedPicture Source #

Draw an abstract, filled in circle.

someSquare :: NormalizedPicture Source #

Draw an abstract, hollow square.

someRectangle :: NormalizedPicture Source #

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

someTallRectangle :: NormalizedPicture Source #

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

someWideRectangle :: NormalizedPicture Source #

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

someSolidSquare :: NormalizedPicture Source #

Draw an abstract, filled in square.

someSolidRectangle :: NormalizedPicture Source #

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

someTallSolidRectangle :: NormalizedPicture Source #

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

someWideSolidRectangle :: NormalizedPicture Source #

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

someCurve :: Int -> NormalizedPicture Source #

Draw an abstract, open curve with this many segments.

someSolidCurve :: Int -> NormalizedPicture Source #

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

someColor :: NormalizedPicture -> NormalizedPicture Source #

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

rotatedHalf :: NormalizedPicture -> NormalizedPicture Source #

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

rotatedQuarter :: NormalizedPicture -> NormalizedPicture Source #

Rotate an abstract shape by up to a quarter turn.

rotatedThreeQuarters :: NormalizedPicture -> NormalizedPicture Source #

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

rotatedUpToFull :: NormalizedPicture -> NormalizedPicture Source #

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

larger :: NormalizedPicture -> NormalizedPicture Source #

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

largerX :: NormalizedPicture -> NormalizedPicture Source #

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

largerY :: NormalizedPicture -> NormalizedPicture Source #

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

smaller :: NormalizedPicture -> NormalizedPicture Source #

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

smallerX :: NormalizedPicture -> NormalizedPicture Source #

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

smallerY :: NormalizedPicture -> NormalizedPicture Source #

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

Queries on NormalizedPictures

Functions for retrieving parameters of a NormalizedPicture. 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 :: NormalizedPicture -> NormalizedPicture -> Bool Source #

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

count :: NormalizedPicture -> NormalizedPicture -> Int Source #

Returns how often a subpicture appears in the image.

getColor :: NormalizedPicture -> Maybe AbsColor Source #

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

getRotation :: NormalizedPicture -> Maybe Angle Source #

Returns abstract rotation of the image if it has any.

getExactRotation :: NormalizedPicture -> Double Source #

Returns actual rotation of the image if it has any.

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

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

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

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

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

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

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

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

getReflectionAngle :: NormalizedPicture -> Maybe Angle Source #

Returns abstract reflection of the image if it has any.

getExactReflectionAngle :: NormalizedPicture -> Double Source #

Returns actual reflection of the image if it has any.

getCircleRadius :: NormalizedPicture -> Maybe Size Source #

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

getExactCircleRadius :: NormalizedPicture -> Maybe Double Source #

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

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

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

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

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

getExactPointList :: NormalizedPicture -> [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.

equalColorCustom :: Double -> Double -> Double -> Double -> AbsColor -> AbsColor -> Bool Source #

Allows for custom thresholds on color similarity detection. This is exported to be able to correct unexpected complications in live tests.

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 :: NormalizedPicture -> NormalizedPicture -> SpatialQuery Source #

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

isNorthOf :: NormalizedPicture -> NormalizedPicture -> SpatialQuery Source #

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

isWestOf :: NormalizedPicture -> NormalizedPicture -> SpatialQuery Source #

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

isEastOf :: NormalizedPicture -> NormalizedPicture -> SpatialQuery Source #

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

isSouthEastOf :: NormalizedPicture -> NormalizedPicture -> SpatialQuery Source #

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

isSouthWestOf :: NormalizedPicture -> NormalizedPicture -> SpatialQuery Source #

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

isNorthEastOf :: NormalizedPicture -> NormalizedPicture -> SpatialQuery Source #

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

isNorthWestOf :: NormalizedPicture -> NormalizedPicture -> SpatialQuery Source #

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

isBelow :: NormalizedPicture -> NormalizedPicture -> SpatialQuery Source #

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

isAbove :: NormalizedPicture -> NormalizedPicture -> SpatialQuery Source #

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

isLeftOf :: NormalizedPicture -> NormalizedPicture -> SpatialQuery Source #

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

isRightOf :: NormalizedPicture -> NormalizedPicture -> SpatialQuery Source #

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

atSamePosition :: NormalizedPicture -> NormalizedPicture -> 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 PicPredicate = Components -> Bool Source #

Alias for predicates on Components.

containsElem :: NormalizedPicture -> PicPredicate Source #

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

containsElems :: [NormalizedPicture] -> PicPredicate Source #

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

containsExactElems :: [NormalizedPicture] -> PicPredicate Source #

True if image contains exactly these subpictures and nothing else.

thisOften :: NormalizedPicture -> Int -> PicPredicate Source #

True if image contains this subpicture exactly this many times.

atLeast :: NormalizedPicture -> Int -> PicPredicate Source #

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

atMost :: NormalizedPicture -> Int -> PicPredicate Source #

True if image contains this subpicture at most many times.

inRangeOf :: NormalizedPicture -> (Int, Int) -> PicPredicate Source #

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

hasRelation :: SpatialQuery -> PicPredicate Source #

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

(<||>) :: PicPredicate -> PicPredicate -> PicPredicate Source #

At least one of two predicates evaluates to True.

options :: [PicPredicate] -> PicPredicate Source #

At least one of many predicates evaluates to True.

ifThen :: PicPredicate -> PicPredicate -> PicPredicate 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 :: (a -> PicPredicate) -> [a] -> PicPredicate 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.

evaluatePred :: PicPredicate -> Picture -> Bool Source #

Evaluates the given predicate on a student submission.

evaluatePreds :: [PicPredicate] -> Picture -> Bool Source #

Evaluates given predicates on a student submission.

Queries on Components

getComponents :: Picture -> Components Source #

Transforms student submission into spatial Components form.

findMaybe :: (NormalizedPicture -> Bool) -> Components -> Maybe NormalizedPicture Source #

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

findMaybeAnd :: (NormalizedPicture -> Bool) -> (NormalizedPicture -> a) -> Components -> Maybe a Source #

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

findMaybeActual :: (NormalizedPicture -> Bool) -> Picture -> Maybe NormalizedPicture Source #

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

findMaybeActualAnd :: (NormalizedPicture -> Bool) -> (NormalizedPicture -> a) -> Picture -> Maybe a Source #

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

findAll :: (NormalizedPicture -> Bool) -> Components -> [NormalizedPicture] Source #

Returns all picture elements satisfying the predicate. (translation is removed)

findAllAnd :: (NormalizedPicture -> Bool) -> (NormalizedPicture -> a) -> Components -> [a] Source #

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

findAllActual :: (NormalizedPicture -> Bool) -> Picture -> [NormalizedPicture] Source #

Returns all subpictures satisfying the predicate. (includes translation)

findAllActualAnd :: (NormalizedPicture -> Bool) -> (NormalizedPicture -> a) -> Picture -> [a] Source #

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

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
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

Methods

from :: Picture -> Rep Picture x #

to :: Rep Picture x -> Picture #

Show Picture Source # 
Instance details

Defined in CodeWorld.Tasks.Picture

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

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 -> () #

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 Rep Picture Source # 
Instance details

Defined in CodeWorld.Tasks.Picture

type DeRef Picture Source # 
Instance details

Defined in CodeWorld.Tasks.Picture

type DeRef 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 -> NormalizedPicture Source #

Convert a Picture into a NormalizedPicture. This applies a number of simplifications, abstractions and rearrangements on the syntax tree of the image. The result is a new tree in canonical form.

toConcretePicture :: NormalizedPicture -> Picture Source #

Transform a NormalizedPicture 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.

reduce :: Picture -> Picture Source #

Apply normalize, then re-concretize the abstracted syntax tree. The result is a new syntax tree, which draws the same image, but was simplified and rearranged via normalize's rules.

reduceNoOrder :: Picture -> Picture Source #

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

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

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
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-ALYWrqBU5SkHyps14Jeeld" '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 #

NFData Font Source # 
Instance details

Defined in CodeWorld.Tasks.Types

Methods

rnf :: Font -> () #

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-ALYWrqBU5SkHyps14Jeeld" '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
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-ALYWrqBU5SkHyps14Jeeld" '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

NFData TextStyle Source # 
Instance details

Defined in CodeWorld.Tasks.Types

Methods

rnf :: TextStyle -> () #

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-ALYWrqBU5SkHyps14Jeeld" '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
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-ALYWrqBU5SkHyps14Jeeld" '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 #

NFData Color Source # 
Instance details

Defined in CodeWorld.Tasks.Color

Methods

rnf :: Color -> () #

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-ALYWrqBU5SkHyps14Jeeld" '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.