codeworld-base-0.2.0.0: Replacement base module for CodeWorld

Safe HaskellNone
LanguageHaskell98

Prelude

Contents

Description

The standard set of functions and variables available to all programs.

You may use any of these functions and variables without defining them.

Synopsis

Entry points

type Program = IO () #

A computer program.

This is a specific task or application that a computer performs. In CodeWorld, programs are defined using one of the "entry point" functions, such as drawingOf, animationOf, or activityOf.

drawingOf :: Picture -> Program #

A program that displays a drawing of a single picture.

This is the simplest way to define a program in CodeWorld. The argument is a Picture.

For example:

program = drawingOf(codeWorldLogo)

animationOf :: (Number -> Picture) -> Program #

A program that shows an animation changing over time.

The argument is a function, which maps each time (a Number in seconds since the program started) to the Picture that is shown at that time.

For example:

program = animationOf(f)
f(t) = rotated(rectangle(5,5), 45 * t)

activityOf :: ([Number] -> world, (world, Event) -> world, world -> Picture) -> Program #

A program that can interact with a user by responding to pointer and keyboard events and remember state.

To create an activity, you first choose a type for its state, called the "world" type. You will then describe the activity with three arguments:

  1. A function to create an initial world. The argument to this function is an infinite sequence of random numbers (chosen uniformly between 0 and 1) which you can use to create a different world each time your program is run.
  2. A function that describes how the world changes when things happen. The function receives an old world and an Event that occurs, and maps it to a new world.
  3. A function that converts a world into a Picture, used to display the program on the screen.

For example:

program = activityOf(initial, change, picture)

initial(randoms) = x0
  where x0 = 10 * randoms#1 - 5

change(x, KeyPress("A")) = x - 1
change(x, KeyPress("D")) = x + 1
change(x, other) = x

picture(x) = translated(solidCircle(1), x, 0)

In mathematical language, an activity is called a dynamical system. The world type is known as the phase space of the system, and the change function is called the dynamics of the system. The initial and picture functions are not part of the system, but describe how the program should simulate and display it.

debugActivityOf :: ([Number] -> world, (world, Event) -> world, world -> Picture) -> Program #

A program that acts just like one built with activityOf, but offers more tools to pause, rewind, and otherwise understand the program behavior. This can be used during development, and then changed back to activityOf once the program is complete.

groupActivityOf :: (Number, [Number] -> state, (state, Event, Number) -> state, (state, Number) -> Picture) -> Program #

A program that interacts with multiple different users by responding to their pointer and keyboard events.

The arguments to this function are similar activityOf, except that:

  1. A first argument, a Number gives the desired number of players.
  2. The change function receives an extra argument telling which player intiated the event.
  3. The picture function receives an extra argument with the player for whom the picture should be built.

The activity will always begin with a "lobby", where players can create new games or join existing games with a code. Once the desired number of players have joined, the activity will begin.

Pictures

data Picture #

A type for pictures.

Pictures can be created from geometry functions such as circle and rectangle. They can be combined by overlaying them with &. They can be modified using transformations like translated, rotated, dilated, colored, and scaled. Ultimately, a picture can be drawn on the screen using one of the CodeWorld entry points such as drawingOf.

:: HasCallStack => Picture #

The CodeWorld logo.

circle :: HasCallStack => Number -> Picture #

A thin circle, with this radius

solidCircle :: HasCallStack => Number -> Picture #

A solid circle, with this radius

thickCircle :: HasCallStack => (Number, Number) -> Picture #

A thick circle, with this radius and line width

rectangle :: HasCallStack => (Number, Number) -> Picture #

A thin rectangle, with this width and height

solidRectangle :: HasCallStack => (Number, Number) -> Picture #

A solid rectangle, with this width and height

thickRectangle :: HasCallStack => (Number, Number, Number) -> Picture #

A thick rectangle, with this width and height and line width

pictures :: HasCallStack => [Picture] -> Picture #

A picture made by drawing this list of pictures, ordered from front to back.

(&) :: HasCallStack => Picture -> Picture -> Picture infixr 0 #

A binary operation that overlays one picture in from of the other.

coordinatePlane :: HasCallStack => Picture #

A coordinate plane.

Adding this to your pictures can help you measure distances more accurately.

Example:

program = drawingOf(myPicture & coordinatePlane)
myPicture = ...

blank :: HasCallStack => Picture #

A blank picture

colored :: HasCallStack => (Picture, Color) -> Picture #

A picture drawn entirely in this color.

coloured :: HasCallStack => (Picture, Color) -> Picture #

A picture drawn entirely in this color.

translated :: HasCallStack => (Picture, Number, Number) -> Picture #

A picture drawn translated in these directions.

scaled :: HasCallStack => (Picture, Number, Number) -> Picture #

A picture scaled by these factors in the x and y directions. Factors greater than 1 stretch the picture larger in that direction, and less than 1 squish it smaller in that direction.

Negative factors also reflect the picture across that axis. For example, to mirror a picture over the x-axis: scaled(p, -1, 1).

dilated :: HasCallStack => (Picture, Number) -> Picture #

A picture with both dimensions scaled by the given factor. Factors greater than 1 make the picture bigger and less than 1 make it smaller.

Negative factors reflect the picture across the origin, which is the same as rotating it by 180 degrees.

rotated :: HasCallStack => (Picture, Number) -> Picture #

A picture rotated by this angle.

reflected :: HasCallStack => (Picture, Number) -> Picture #

A picture reflected across a line through the origin at this angle, in degrees. For example, an angle of 0 reflects the picture vertically across the x axis, while an angle of 90 reflects the picture horizontally across the y axis, and an agle of 45 reflects the picture across the main diagonal.

clipped :: HasCallStack => (Picture, Number, Number) -> Picture #

A picture clipped to a rectangle of this width and height.

polyline :: HasCallStack => [Point] -> Picture #

A thin sequence of line segments with these endpoints

thickPolyline :: HasCallStack => ([Point], Number) -> Picture #

A thin sequence of line segments, with these endpoints and line width

polygon :: HasCallStack => [Point] -> Picture #

A thin polygon with these points as vertices

thickPolygon :: HasCallStack => ([Point], Number) -> Picture #

A thin polygon with these points as vertices

solidPolygon :: HasCallStack => [Point] -> Picture #

A solid polygon with these points as vertices

curve :: HasCallStack => [Point] -> Picture #

A thin curve passing through these points.

thickCurve :: HasCallStack => ([Point], Number) -> Picture #

A thick curve passing through these points, with this line width

closedCurve :: HasCallStack => [Point] -> Picture #

A thin closed curve passing through these points.

thickClosedCurve :: HasCallStack => ([Point], Number) -> Picture #

A thick closed curve passing through these points, with this line width.

solidClosedCurve :: HasCallStack => [Point] -> Picture #

A solid closed curve passing through these points.

arc :: HasCallStack => (Number, Number, Number) -> Picture #

A thin arc, starting and ending at these angles, with this radius

sector :: HasCallStack => (Number, Number, Number) -> Picture #

A solid sector of a circle (i.e., a pie slice) starting and ending at these angles, with this radius

thickArc :: HasCallStack => (Number, Number, Number, Number) -> Picture #

A thick arc, starting and ending at these angles, with this radius and line width

lettering :: HasCallStack => Text -> Picture #

A rendering of text characters.

styledLettering :: HasCallStack => (Text, Font, TextStyle) -> Picture #

A rendering of text characters, with a specific choice of font and style.

data Font #

A font in which lettering can be drawn. Fonts are used with the styledLettering function.

NamedFont may create a program that only works correctly on computers where that font is installed, so you are encouraged to use one of the other values.

data TextStyle #

A style in which lettering can be drawn. Text styles are used with the styledLettering function.

Constructors

Plain 
Italic 
Bold 

Colors

data Color #

A color.

Colors can be described in several ways:

  1. Using common color names: red, blue, yellow, green, orange, purple, pink, black, white, brown, and gray.
  2. Transforming other colors with functions such as light, dark, bright, dull, translucent, and mixed.
  3. Constructing colors from coordinates in a color space, such as RGB, RGBA, or HSL.

Note that transparency is included in a color. Common color names and the RGB and HSL constructors only produce opaque colors, but RGBA and the translucent function work with transparency.

Instances
Eq Color # 
Instance details

Defined in Internal.Color

Methods

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

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

type Colour = Color #

A synonym for Color, using the non-US spelling.

pattern RGBA :: (Number, Number, Number, Number) -> Color #

pattern RGB :: (Number, Number, Number) -> Color #

pattern HSL :: (Number, Number, Number) -> Color #

black :: Color #

The color black

white :: Color #

The color white

red :: Color #

The color red

green :: Color #

The color green

blue :: Color #

The color blue

yellow :: Color #

The color yellow

orange :: Color #

The color orange

brown :: Color #

The color brown

pink :: Color #

The color pink

purple :: Color #

The color purple

gray :: Color #

The color gray

grey :: Color #

The color grey

This is the same color as gray, but with a non-US spelling.

mixed :: [Color] -> Color #

Produces a color by mixing other colors in equal proportion.

The order of colors is unimportant. Colors may be mixed in uneven proportions by listing a color more than once, such as mixed([red, red, orange]).

light :: Color -> Color #

Produces a lighter shade of the given color.

This function may be nested more than once to produce an even lighter shade, as in light(light(blue)).

dark :: Color -> Color #

Produces a darker shade of the given color.

This function may be nested more than once to produce an even darker shade, as in dark(dark(green)).

bright :: Color -> Color #

Produces a brighter shade of the given color; that is, less gray and more colorful.

This function may be nested more than once to produce an even brighter shade, as in bright(bright(yellow)).

dull :: Color -> Color #

Produces a duller shade of the given color; that is, more gray and less colorful.

This function may be nested more than once to produce an even duller shade, as in dull(dull(purple)).

translucent :: Color -> Color #

Produces a partially transparent color.

This function may be nested more than once to produce an even more transparent color, as in translucent(translucent(brown)).

assortedColors :: [Color] #

An infinite list of various colors.

The list is chosen to contain a variety of different hues as spread out as possible to create colorful effects.

lighter :: (Color, Number) -> Color #

Increases the luminosity of a color by the given amount.

The amount should be between -1 and 1, where:

  • lighter(c, 1) is always white, regardless of c.
  • lighter(c, 0) is the same as c.
  • lighter(c, -1) is always black, regardless of c.

darker :: (Color, Number) -> Color #

Decreases the luminosity of a color by the given amount.

The amount should be between -1 and 1, where:

  • darker(c, 1) is always black, regardless of c.
  • darker(c, 0) is the same as c.
  • darker(c, -1) is always white, regardless of c.

brighter :: (Color, Number) -> Color #

Increases the saturation of a color by the given amount.

The amount should be between -1 and 1, where:

  • brighter(c, 1) is a fully saturated version of c.
  • brighter(c, 0) is the same as c.
  • brighter(c, -1) is just a shade of gray with no color.

duller :: (Color, Number) -> Color #

Decreases the saturation of a color by the given amount.

The amount should be between -1 and 1, where:

  • duller(c, 1) is just a shade of gray with no color.
  • duller(c, 0) is the same as c.
  • duller(c, -1) is a fully saturated version of c.

Points and vectors

type Point = (Number, Number) #

A point in two dimensions. A point is written with the x coordinate first, and the y coordinate second. For example, (3, -2) is the point with x coordinate 3 a y coordinate -2.

translatedPoint :: (Point, Number, Number) -> Point #

Moves a given point by given x and y offsets

rotatedPoint :: (Point, Number) -> Point #

Rotates a given point by given angle, in degrees

scaledPoint :: (Point, Number, Number) -> Point #

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

dilatedPoint :: (Point, Number) -> Point #

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

type Vector = (Number, Number) #

A two-dimensional vector

vectorLength :: Vector -> Number #

The length of the given vector

vectorDirection :: Vector -> Number #

The counter-clockwise angle, in degrees, that a given vector make with the X-axis

vectorSum :: (Vector, Vector) -> Vector #

The sum of two vectors

vectorDifference :: (Vector, Vector) -> Vector #

The difference of two vectors

scaledVector :: (Vector, Number) -> Vector #

Scales a given vector by a given scalar multiplier

rotatedVector :: (Vector, Number) -> Vector #

Rotates a given vector by a given angle in degrees

dotProduct :: (Vector, Vector) -> Number #

The dot product of two vectors

Events

data Event #

An event initiated by the user.

Values of this type represent events that the user triggers when using an interactive program.

Key events describe the key as Text. Most keys are represented by a single character text string, with the capital letter or other symbol from the key. Keys that don't correspond to a single character use longer names from the following list. Keep in mind that not all of these keys appear on all keyboards.

  • Up, Down, Left, and Right for the cursor keys.
  • F1, F2, etc. for function keys.
  • Backspace
  • Tab
  • Enter
  • Shift
  • Ctrl
  • Alt
  • Esc
  • PageUp
  • PageDown
  • End
  • Home
  • Insert
  • Delete
  • CapsLock
  • NumLock
  • ScrollLock
  • PrintScreen
  • Break
  • Separator
  • Cancel
  • Help
Instances
Eq Event # 
Instance details

Defined in Internal.Event

Methods

(==) :: Event -> Event -> Bool

(/=) :: Event -> Event -> Bool

Debugging

traced :: (a, Text) -> a #

Numbers

data Number #

The type for numbers.

Numbers can be positive or negative, whole or fractional. For example, 5, 3.2, and -10 are all values of the type Number.

Instances
Enum Number # 
Instance details

Defined in Internal.Num

Eq Number # 
Instance details

Defined in Internal.Num

Methods

(==) :: Number -> Number -> Bool

(/=) :: Number -> Number -> Bool

Floating Number # 
Instance details

Defined in Internal.Num

Fractional Number # 
Instance details

Defined in Internal.Num

Methods

(/) :: Number -> Number -> Number

recip :: Number -> Number

fromRational :: Rational -> Number

Num Number # 
Instance details

Defined in Internal.Num

Ord Number # 
Instance details

Defined in Internal.Num

Methods

compare :: Number -> Number -> Ordering

(<) :: Number -> Number -> Bool

(<=) :: Number -> Number -> Bool

(>) :: Number -> Number -> Bool

(>=) :: Number -> Number -> Bool

max :: Number -> Number -> Number

min :: Number -> Number -> Number

Real Number # 
Instance details

Defined in Internal.Num

Methods

toRational :: Number -> Rational

RealFloat Number # 
Instance details

Defined in Internal.Num

Methods

floatRadix :: Number -> Integer

floatDigits :: Number -> Int

floatRange :: Number -> (Int, Int)

decodeFloat :: Number -> (Integer, Int)

encodeFloat :: Integer -> Int -> Number

exponent :: Number -> Int

significand :: Number -> Number

scaleFloat :: Int -> Number -> Number

isNaN :: Number -> Bool

isInfinite :: Number -> Bool

isDenormalized :: Number -> Bool

isNegativeZero :: Number -> Bool

isIEEE :: Number -> Bool

atan2 :: Number -> Number -> Number

RealFrac Number # 
Instance details

Defined in Internal.Num

Methods

properFraction :: Integral b => Number -> (b, Number)

truncate :: Integral b => Number -> b

round :: Integral b => Number -> b

ceiling :: Integral b => Number -> b

floor :: Integral b => Number -> b

Show Number # 
Instance details

Defined in Internal.Num

Methods

showsPrec :: Int -> Number -> ShowS

show :: Number -> String

showList :: [Number] -> ShowS

(+) :: Number -> Number -> Number infixl 6 #

Adds two numbers.

(-) :: Number -> Number -> Number infixl 6 #

Subtracts two numbers.

(*) :: Number -> Number -> Number infixl 7 #

Multiplies two numbers.

(/) :: HasCallStack => Number -> Number -> Number infixl 7 #

Divides two numbers. The second number should not be zero.

(^) :: HasCallStack => Number -> Number -> Number infixr 8 #

Raises a number to a power.

(>) :: Number -> Number -> Truth infix 4 #

Tells whether one number is greater than the other.

(>=) :: Number -> Number -> Truth infix 4 #

Tells whether one number is greater than or equal to the other.

(<) :: Number -> Number -> Truth infix 4 #

Tells whether one number is less than the other.

(<=) :: Number -> Number -> Truth infix 4 #

Tells whether one number is less than or equal to the other.

max :: (Number, Number) -> Number #

Gives the larger of two numbers.

min :: (Number, Number) -> Number #

Gives the smaller of two numbers.

abs :: Number -> Number #

Gives the absolute value of a number.

If the number if positive or zero, the absolute value is the same as the number. If the number is negative, the absolute value is the opposite of the number.

signum :: Number -> Number #

Gives the sign of a number.

If the number is negative, the signum is -1. If it's positive, the signum is 1. If the number is 0, the signum is 0. In general, a number is equal to its absolute value (abs) times its sign (signum).

truncation :: Number -> Number #

Gives the number without its fractional part.

For example, truncate(4.2) is 4, while truncate(-4.7) is -4.

rounded :: Number -> Number #

Gives the number rounded to the nearest integer.

For example, round(4.2) is 4, while round(4.7) is 5.

ceiling :: Number -> Number #

Gives the smallest integer that is greater than or equal to a number.

For example, ceiling(4) is 4, while ceiling(4.1) is 5. With negative numbers, ceiling(-3.5) is -3, since -3 is greater than -3.5.

floor :: Number -> Number #

Gives the largest integer that is less than or equal to a number.

For example, floor(4) is 4, while floor(3.9) is 3. With negative numbers, floor(-3.5) is -4, since -4 is less than -3.5.

quotient :: HasCallStack => (Number, Number) -> Number #

Gives the integer part of the result when dividing two numbers.

For example, 3/2 is 1.5, but quotient(3, 2) is 1, which is the integer part.

remainder :: HasCallStack => (Number, Number) -> Number #

Gives the remainder when dividing two numbers.

For example, remainder(3,2) is 1, which is the remainder when dividing 3 by 2.

pi :: Number #

The constant pi, which is equal to the ratio between the circumference and diameter of a circle.

pi is approximately 3.14.

exp :: Number -> Number #

Gives the exponential of a number. This is equal to the constant e, raised to the power of the number.

The exp function increases faster and faster very quickly. For example, if t is the current time in seconds, exp(t) will reach a million in about 14 seconds. It will reach a billion in around 21 seconds.

sqrt :: HasCallStack => Number -> Number #

Gives the square root of a number. This is the positive number that, when multiplied by itself, gives the original number back.

The sqrt always increases, but slows down. For example, if t is the current time, sqrt(t) will reach 5 in 25 seconds. But it will take 100 seconds to reach 10, and 225 seconds (almost 4 minutes) to reach 15.

log :: HasCallStack => Number -> Number #

Gives the natural log of a number. This is the opposite of the exp function.

Like sqrt, the log function always increases, but slows down. However, it slows down much sooner than the sqrt function. If t is the current time in seconds, it takes more than 2 minutes for log(t) to reach 5, and more than 6 hours to reach 10!

logBase :: HasCallStack => (Number, Number) -> Number #

Gives the logarithm of the first number, using the base of the second number.

sin :: Number -> Number #

Gives the sine of an angle, where the angle is measured in degrees.

tan :: Number -> Number #

Gives the tangent of an angle, where the angle is measured in degrees.

This is the slope of a line at that angle from horizontal.

cos :: Number -> Number #

Gives the cosine of an angle, where the angle is measured in degrees.

asin :: HasCallStack => Number -> Number #

Gives the inverse sine of a value, in degrees.

This is the unique angle between -90 and 90 that has the input as its sine.

atan :: Number -> Number #

Gives the inverse tangent of a value, in degrees.

This is the unique angle between -90 and 90 that has the input as its tangent.

acos :: HasCallStack => Number -> Number #

Gives the inverse cosine of a value, in degrees.

This is the unique angle between 0 and 180 that has the input as its cosine.

properFraction :: Number -> (Number, Number) #

Separates a number into its whole and fractional parts.

For example, properFraction(1.2) is (1, 0.2).

even :: Number -> Truth #

Tells if a number is even.

odd :: Number -> Truth #

Tells if a number is odd.

gcd :: HasCallStack => (Number, Number) -> Number #

Gives the greatest common divisor of two numbers.

This is the largest number that divides each of the two parameters. Both parameters must be integers.

lcm :: HasCallStack => (Number, Number) -> Number #

Gives the least common multiple of two numbers.

This is the smallest number that is divisible by both of the two parameters. Both parameters must be integers.

sum :: [Number] -> Number #

Gives the sum of a list of numbers.

product :: [Number] -> Number #

Gives the product of a list of numbers.

maximum :: [Number] -> Number #

Gives the largest number from a list.

minimum :: [Number] -> Number #

Gives the smallest number from a list.

isInteger :: Number -> Truth #

Tells whether a Number is an integer or not.

An integer is a whole number, such as 5, 0, or -10. Numbers with non-zero decimals, like 5.3, are not integers.

fromInteger :: Integer -> Number #

fromRational :: Rational -> Number #

fromInt :: Int -> Number #

toInt :: HasCallStack => Number -> Int #

fromDouble :: HasCallStack => Double -> Number #

toDouble :: Number -> Double #

Text

data Text #

Instances
Eq Text # 
Instance details

Defined in Internal.Text

Methods

(==) :: Text -> Text -> Bool

(/=) :: Text -> Text -> Bool

fromString :: String -> Text #

toString :: Text -> String #

(<>) :: Text -> Text -> Text infixr 6 #

lines :: Text -> [Text] #

unlines :: [Text] -> Text #

words :: Text -> [Text] #

unwords :: [Text] -> Text #

joined :: [Text] -> Text #

substitution :: (Text, Text, Text) -> Text #

Gives the result of replacing one piece of text with another.

For example, substitution("How do you do?", "do", "be") is equal to "How be you be?".

substitutions :: (Text, [(Text, Text)]) -> Text #

Gives the result of performing many substitutions in a piece of text. This is commonly used to build text to show in a program, as in this example:

substitutions("Lives: [lives] of 3 Score: [score]", [("[lives]", printed(lives)), ("[score]", printed(score))])

General purpose functions

(++) :: [a] -> [a] -> [a] #

data Bool #

Constructors

False 
True 
Instances
Bounded Bool 
Instance details

Defined in GHC.Enum

Enum Bool 
Instance details

Defined in GHC.Enum

Methods

succ :: Bool -> Bool

pred :: Bool -> Bool

toEnum :: Int -> Bool

fromEnum :: Bool -> Int

enumFrom :: Bool -> [Bool]

enumFromThen :: Bool -> Bool -> [Bool]

enumFromTo :: Bool -> Bool -> [Bool]

enumFromThenTo :: Bool -> Bool -> Bool -> [Bool]

Eq Bool 
Instance details

Defined in GHC.Classes

Methods

(==) :: Bool -> Bool -> Bool

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

Ord Bool 
Instance details

Defined in GHC.Classes

Methods

compare :: Bool -> Bool -> Ordering

(<) :: Bool -> Bool -> Bool

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

(>) :: Bool -> Bool -> Bool

(>=) :: Bool -> Bool -> Bool

max :: Bool -> Bool -> Bool

min :: Bool -> Bool -> Bool

Read Bool 
Instance details

Defined in GHC.Read

Methods

readsPrec :: Int -> ReadS Bool

readList :: ReadS [Bool]

readPrec :: ReadPrec Bool

readListPrec :: ReadPrec [Bool]

Show Bool 
Instance details

Defined in GHC.Show

Methods

showsPrec :: Int -> Bool -> ShowS

show :: Bool -> String

showList :: [Bool] -> ShowS

Generic Bool 
Instance details

Defined in GHC.Generics

Associated Types

type Rep Bool :: Type -> Type

Methods

from :: Bool -> Rep Bool x

to :: Rep Bool x -> Bool

Lift Bool 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

lift :: Bool -> Q Exp

Bits Bool 
Instance details

Defined in Data.Bits

Methods

(.&.) :: Bool -> Bool -> Bool

(.|.) :: Bool -> Bool -> Bool

xor :: Bool -> Bool -> Bool

complement :: Bool -> Bool

shift :: Bool -> Int -> Bool

rotate :: Bool -> Int -> Bool

zeroBits :: Bool

bit :: Int -> Bool

setBit :: Bool -> Int -> Bool

clearBit :: Bool -> Int -> Bool

complementBit :: Bool -> Int -> Bool

testBit :: Bool -> Int -> Bool

bitSizeMaybe :: Bool -> Maybe Int

bitSize :: Bool -> Int

isSigned :: Bool -> Bool

shiftL :: Bool -> Int -> Bool

unsafeShiftL :: Bool -> Int -> Bool

shiftR :: Bool -> Int -> Bool

unsafeShiftR :: Bool -> Int -> Bool

rotateL :: Bool -> Int -> Bool

rotateR :: Bool -> Int -> Bool

popCount :: Bool -> Int

FiniteBits Bool 
Instance details

Defined in Data.Bits

Methods

finiteBitSize :: Bool -> Int

countLeadingZeros :: Bool -> Int

countTrailingZeros :: Bool -> Int

Random Bool 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (Bool, Bool) -> g -> (Bool, g)

random :: RandomGen g => g -> (Bool, g)

randomRs :: RandomGen g => (Bool, Bool) -> g -> [Bool]

randoms :: RandomGen g => g -> [Bool]

randomRIO :: (Bool, Bool) -> IO Bool

randomIO :: IO Bool

Unbox Bool 
Instance details

Defined in Data.Vector.Unboxed.Base

SingKind Bool 
Instance details

Defined in GHC.Generics

Associated Types

type DemoteRep Bool :: Type

Methods

fromSing :: Sing a -> DemoteRep Bool

Vector Vector Bool 
Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) Bool -> m (Vector Bool)

basicUnsafeThaw :: PrimMonad m => Vector Bool -> m (Mutable Vector (PrimState m) Bool)

basicLength :: Vector Bool -> Int

basicUnsafeSlice :: Int -> Int -> Vector Bool -> Vector Bool

basicUnsafeIndexM :: Monad m => Vector Bool -> Int -> m Bool

basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) Bool -> Vector Bool -> m ()

elemseq :: Vector Bool -> Bool -> b -> b

MVector MVector Bool 
Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicLength :: MVector s Bool -> Int

basicUnsafeSlice :: Int -> Int -> MVector s Bool -> MVector s Bool

basicOverlaps :: MVector s Bool -> MVector s Bool -> Bool

basicUnsafeNew :: PrimMonad m => Int -> m (MVector (PrimState m) Bool)

basicInitialize :: PrimMonad m => MVector (PrimState m) Bool -> m ()

basicUnsafeReplicate :: PrimMonad m => Int -> Bool -> m (MVector (PrimState m) Bool)

basicUnsafeRead :: PrimMonad m => MVector (PrimState m) Bool -> Int -> m Bool

basicUnsafeWrite :: PrimMonad m => MVector (PrimState m) Bool -> Int -> Bool -> m ()

basicClear :: PrimMonad m => MVector (PrimState m) Bool -> m ()

basicSet :: PrimMonad m => MVector (PrimState m) Bool -> Bool -> m ()

basicUnsafeCopy :: PrimMonad m => MVector (PrimState m) Bool -> MVector (PrimState m) Bool -> m ()

basicUnsafeMove :: PrimMonad m => MVector (PrimState m) Bool -> MVector (PrimState m) Bool -> m ()

basicUnsafeGrow :: PrimMonad m => MVector (PrimState m) Bool -> Int -> m (MVector (PrimState m) Bool)

SingI False 
Instance details

Defined in GHC.Generics

Methods

sing :: Sing False

SingI True 
Instance details

Defined in GHC.Generics

Methods

sing :: Sing True

type Rep Bool 
Instance details

Defined in GHC.Generics

type Rep Bool = D1 (MetaData "Bool" "GHC.Types" "ghc-prim" False) (C1 (MetaCons "False" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "True" PrefixI False) (U1 :: Type -> Type))
newtype Vector Bool 
Instance details

Defined in Data.Vector.Unboxed.Base

newtype Vector Bool = V_Bool (Vector Word8)
type DemoteRep Bool 
Instance details

Defined in GHC.Generics

type DemoteRep Bool = Bool
data Sing (a :: Bool) 
Instance details

Defined in GHC.Generics

data Sing (a :: Bool) where
newtype MVector s Bool 
Instance details

Defined in Data.Vector.Unboxed.Base

newtype MVector s Bool = MV_Bool (MVector s Word8)

type Truth = Bool #

ifThenElse :: Truth -> a -> a -> a #

(==) :: a -> a -> Truth infix 4 #

Compares values to see if they are equal.

(/=) :: a -> a -> Truth infix 4 #

Compares values to see if they are not equal. Note that a /= b is the same as not (a == b).

(&&) :: Truth -> Truth -> Truth infixr 3 #

(||) :: Truth -> Truth -> Truth infixr 2 #

permutations :: [a] -> [[a]] #

subsequences :: [a] -> [[a]] #

toOperator :: ((a, b) -> c) -> a -> b -> c #

Converts a function to an operator.

Example use:

 f(x,y) = 2*x + y
 (%) = toOperator(f)

 eight = 3 % 2

This has the same effect as defining % as:

 x % y = 2*x + y
 eight = 3 % 2

fromOperator :: (a -> b -> c) -> (a, b) -> c #

Converts an operator into a normal function.

Example use:

 divide = fromOperator(/)
 four = divide(16, 4)

firstOfPair :: (a, b) -> a #

Returns the first element of an ordered pair.

secondOfPair :: (a, b) -> b #

Returns the second element of an ordered pair.

error :: HasCallStack => Text -> a #

Fails with an error message.

undefined :: HasCallStack => a #

Represents an undefined value. This lets you compile programs with unfinished values. If the value is needed, the program will crash.

fail :: HasCallStack => String -> a #

Fails with an error message. This is required (though apparently unused) by the desugaring for pattern binds in list comprehensions.

empty :: [a] -> Truth #

Determines whether a list is empty or not.

contains :: ([a], a) -> Truth #

Determines whether a value is a member of a list or not.

length :: [a] -> Number #

Gives the length of a list.

at :: HasCallStack => ([a], a, Number) -> [a] #

Gives a list with a replaced element at an index. Indices start at 1.

(#) :: HasCallStack => [a] -> Number -> a infixl 9 #

Gives the member of a list at a given index. Indices start at 1.

any :: [Truth] -> Truth #

Determines if any proposition in a list is true.

For example, any([even(n) | n <- [1,2,3]]) is True, because 2 is even.

all :: [Truth] -> Truth #

Determines if all propositions in a list are true.

For example, all([even(n) | n <- [2,3,4]]) is False, because 3 is not even.

none :: [Truth] -> Truth #

Determines if all propositions in a list are false.

For example, none([odd(n) | n <- [2,3,4]]) is False, because 3 is odd.

repeated :: ([a], Number) -> [a] #

Forms a list by repeating a source list some number of times.

repeating :: [a] -> [a] #

Forms a list by repeating a source list forever.

first :: HasCallStack => ([a], Number) -> [a] #

Gives the first members of a list, up to the given number.

last :: HasCallStack => ([a], Number) -> [a] #

Gives the last members of a list, up to the given number.

rest :: HasCallStack => ([a], Number) -> [a] #

Gives all members of a list after the given number.

In general, xs = first(xs, n) ++ rest(xs, n).

groups :: ([a], Number) -> [[a]] #

Converts a list of elements into a list of smaller lists, each of the given length.

For example, [ (x, y) | [x, y] <- groups(randomNumbers(42), 2) ].

while :: ([a], a -> Truth) -> [a] #

Gives the longest prefix of a list for which a condition is true.

For example, while([2,4,5,6], even) = [2,4].

until :: ([a], a -> Truth) -> [a] #

Gives the longest prefix of a list for which a condition is false.

For example, until([2,4,5,6], odd) = [2,4].

after :: ([a], a -> Truth) -> [a] #

Gives the remaining portion of a list after the longest prefix for which a condition is true.

In general, xs = while(xs, cond) ++ after(xs, cond).

concatenation :: [[a]] -> [a] #

Gives the concatenation of all of the lists in its input.

sorted :: [Number] -> [Number] #

Gives a list of numbers reordered into increasing order.

reversed :: [a] -> [a] #

Gives a list in the opposite order of the original.

unique :: [a] -> [a] #

Gives a list with all duplicate members removed.

transposed :: [[a]] -> [[a]] #

shuffled :: ([a], Number) -> [a] #

data IO a #

Instances
Monad IO 
Instance details

Defined in GHC.Base

Methods

(>>=) :: IO a -> (a -> IO b) -> IO b

(>>) :: IO a -> IO b -> IO b

return :: a -> IO a

fail :: String -> IO a

Functor IO 
Instance details

Defined in GHC.Base

Methods

fmap :: (a -> b) -> IO a -> IO b

(<$) :: a -> IO b -> IO a

Applicative IO 
Instance details

Defined in GHC.Base

Methods

pure :: a -> IO a

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

liftA2 :: (a -> b -> c) -> IO a -> IO b -> IO c

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

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

MonadPlus IO 
Instance details

Defined in GHC.Base

Methods

mzero :: IO a

mplus :: IO a -> IO a -> IO a

Alternative IO 
Instance details

Defined in GHC.Base

Methods

empty :: IO a

(<|>) :: IO a -> IO a -> IO a

some :: IO a -> IO [a]

many :: IO a -> IO [a]

PrimBase IO 
Instance details

Defined in Control.Monad.Primitive

Methods

internal :: IO a -> State# (PrimState IO) -> (#State# (PrimState IO), a#)

PrimMonad IO 
Instance details

Defined in Control.Monad.Primitive

Associated Types

type PrimState IO :: Type

Methods

primitive :: (State# (PrimState IO) -> (#State# (PrimState IO), a#)) -> IO a

MonadRef IO 
Instance details

Defined in Control.Monad.Ref

Associated Types

type Ref IO :: Type -> Type

Methods

newRef :: a -> IO (Ref IO a)

readRef :: Ref IO a -> IO a

writeRef :: Ref IO a -> a -> IO ()

modifyRef :: Ref IO a -> (a -> a) -> IO ()

modifyRef' :: Ref IO a -> (a -> a) -> IO ()

Quasi IO 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

qNewName :: String -> IO Name

qReport :: Bool -> String -> IO ()

qRecover :: IO a -> IO a -> IO a

qLookupName :: Bool -> String -> IO (Maybe Name)

qReify :: Name -> IO Info

qReifyFixity :: Name -> IO (Maybe Fixity)

qReifyInstances :: Name -> [Type] -> IO [Dec]

qReifyRoles :: Name -> IO [Role]

qReifyAnnotations :: Data a => AnnLookup -> IO [a]

qReifyModule :: Module -> IO ModuleInfo

qReifyConStrictness :: Name -> IO [DecidedStrictness]

qLocation :: IO Loc

qRunIO :: IO a -> IO a

qAddDependentFile :: FilePath -> IO ()

qAddTempFile :: String -> IO FilePath

qAddTopDecls :: [Dec] -> IO ()

qAddForeignFilePath :: ForeignSrcLang -> String -> IO ()

qAddModFinalizer :: Q () -> IO ()

qAddCorePlugin :: String -> IO ()

qGetQ :: Typeable a => IO (Maybe a)

qPutQ :: Typeable a => a -> IO ()

qIsExtEnabled :: Extension -> IO Bool

qExtsEnabled :: IO [Extension]

MonadAtomicRef IO 
Instance details

Defined in Control.Monad.Ref

Methods

atomicModifyRef :: Ref IO a -> (a -> (a, b)) -> IO b

atomicModifyRef' :: Ref IO a -> (a -> (a, b)) -> IO b

MonadBaseControl IO IO 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM IO a :: Type

Methods

liftBaseWith :: (RunInBase IO IO -> IO a) -> IO a

restoreM :: StM IO a -> IO a

Semigroup a => Semigroup (IO a) 
Instance details

Defined in GHC.Base

Methods

(<>) :: IO a -> IO a -> IO a #

sconcat :: NonEmpty (IO a) -> IO a

stimes :: Integral b => b -> IO a -> IO a

Monoid a => Monoid (IO a) 
Instance details

Defined in GHC.Base

Methods

mempty :: IO a

mappend :: IO a -> IO a -> IO a

mconcat :: [IO a] -> IO a

type PrimState IO 
Instance details

Defined in Control.Monad.Primitive

type PrimState IO = RealWorld
type Ref IO 
Instance details

Defined in Control.Monad.Ref

type Ref IO = IORef
type StM IO a 
Instance details

Defined in Control.Monad.Trans.Control

type StM IO a = a