wumpus-core-0.12.0: Pure Haskell PostScript and SVG generation.

PortabilityGHC
Stabilityhighly unstable
MaintainerStephen Tetley <stephen.tetley@gmail.com>

Wumpus.Core.Utils

Contents

Description

Utility functions

Synopsis

Component-wise min and max

class CMinMax a whereSource

Component-wise min and max. Standard min and max via Ord are defined lexographically on pairs, e.g.:

 min (1,2) (2,1) = (1,2)

For certain geometrical objects (Points!) we want the (constructed-) componentwise min and max, e.g:

 cmin (1,2) (2,1) = (1,1) 
 cmax (1,2) (2,1) = (2,2)

Methods

cmin :: a -> a -> aSource

cmax :: a -> a -> aSource

Instances

Ord a => CMinMax (Point2 a) 
(Ord a, Ord b) => CMinMax (a, b) 

within :: Eq a => CMinMax a => a -> a -> a -> BoolSource

Test whether a is within opper and lower.

Three values

max3 :: Ord a => a -> a -> a -> aSource

max of 3

min3 :: Ord a => a -> a -> a -> aSource

min of 3

med3 :: Ord a => a -> a -> a -> aSource

median of 3

Truncate / print a double

class Num a => PSUnit a whereSource

truncateDouble :: Double -> StringSource

Truncate the printed decimal representation of a Double. The is prefered to showFFloat from Numeric as it produces shorter representations where appropriate.

  1. 000000000 becomes 0.0 rather than however many digs are specified.

roundup :: Double -> StringSource

Take ceilingi and show.

clamp :: Ord a => a -> a -> a -> aSource

ramp255 :: Double -> IntSource

Scale a Double between 0.0 and 1.0 to be an Int between 0 and 255.

PostScript timetmap

mkTimeStamp :: IO StringSource

Generate a time stamp for the output files. Note PostScript does no interpretation of the time stamp, it is solely for information and so the representation is arbitrary.

Pretty printers for strings

parens :: String -> StringSource

Enclose string in parens.

hsep :: [String] -> StringSource

Separate with a space.

tupled :: [String] -> StringSource

 (..., ...)

Extras

sequenceA :: Applicative f => [f a] -> f [a]Source

Applicative version of (monadic) sequence. Because we use MonadLib we don't want to bring in Control.Monad.Instances ()

(<:>) :: Applicative f => f a -> f [a] -> f [a]Source

Applicative cons.

One type - non-empty list type

data OneList a Source

Constructors

One a 
a :+ (OneList a) 

Instances

Eq a => Eq (OneList a) 
Show a => Show (OneList a) 

mkList2 :: a -> a -> OneList aSource

onesmapM_ :: Monad m => (a -> m b) -> OneList a -> m ()Source

toListWith :: (a -> b) -> OneList a -> [b]Source

toListWithM :: Monad m => (a -> m b) -> OneList a -> m [b]Source