Copyright | (c) 2015-2016 Brendan Hay <brendan.g.hay@gmail.com> |
---|---|
License | Mozilla Public License, v. 2.0. |
Maintainer | Brendan Hay <brendan.g.hay@gmail.com> |
Stability | provisional |
Portability | non-portable (GHC extensions) |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- (++) :: [a] -> [a] -> [a]
- seq :: a -> b -> b
- filter :: (a -> Bool) -> [a] -> [a]
- zip :: [a] -> [b] -> [(a, b)]
- print :: Show a => a -> IO ()
- fst :: (a, b) -> a
- snd :: (a, b) -> b
- otherwise :: Bool
- map :: (a -> b) -> [a] -> [b]
- ($) :: (a -> b) -> a -> b
- fromIntegral :: (Integral a, Num b) => a -> b
- realToFrac :: (Real a, Fractional b) => a -> b
- class Bounded a where
- class Enum a where
- succ :: a -> a
- pred :: a -> a
- toEnum :: Int -> a
- fromEnum :: a -> Int
- enumFrom :: a -> [a]
- enumFromThen :: a -> a -> [a]
- enumFromTo :: a -> a -> [a]
- enumFromThenTo :: a -> a -> a -> [a]
- class Eq a where
- class Fractional a => Floating a where
- class Num a => Fractional a where
- (/) :: a -> a -> a
- recip :: a -> a
- fromRational :: Rational -> a
- class (Real a, Enum a) => Integral a where
- class Applicative m => Monad (m :: Type -> Type) where
- class Typeable a => Data a
- class Functor (f :: Type -> Type) where
- class Num a where
- class Eq a => Ord a where
- class Read a where
- class (Num a, Ord a) => Real a where
- toRational :: a -> Rational
- class (RealFrac a, Floating a) => RealFloat a where
- floatRadix :: a -> Integer
- floatDigits :: a -> Int
- floatRange :: a -> (Int, Int)
- decodeFloat :: a -> (Integer, Int)
- encodeFloat :: Integer -> Int -> a
- exponent :: a -> Int
- significand :: a -> a
- scaleFloat :: Int -> a -> a
- isNaN :: a -> Bool
- isInfinite :: a -> Bool
- isDenormalized :: a -> Bool
- isNegativeZero :: a -> Bool
- isIEEE :: a -> Bool
- atan2 :: a -> a -> a
- class (Real a, Fractional a) => RealFrac a where
- class Show a where
- class Typeable (a :: k)
- class Functor f => Applicative (f :: Type -> Type) where
- class Foldable (t :: Type -> Type) where
- foldMap :: Monoid m => (a -> m) -> t a -> m
- foldr :: (a -> b -> b) -> b -> t a -> b
- foldl :: (b -> a -> b) -> b -> t a -> b
- foldr1 :: (a -> a -> a) -> t a -> a
- foldl1 :: (a -> a -> a) -> t a -> a
- null :: t a -> Bool
- length :: t a -> Int
- elem :: Eq a => a -> t a -> Bool
- maximum :: Ord a => t a -> a
- minimum :: Ord a => t a -> a
- sum :: Num a => t a -> a
- class (Functor t, Foldable t) => Traversable (t :: Type -> Type) where
- traverse :: Applicative f => (a -> f b) -> t a -> f (t b)
- sequenceA :: Applicative f => t (f a) -> f (t a)
- mapM :: Monad m => (a -> m b) -> t a -> m (t b)
- sequence :: Monad m => t (m a) -> m (t a)
- class Generic a
- class Semigroup a where
- (<>) :: a -> a -> a
- class Semigroup a => Monoid a where
- data Bool
- data Char
- data Double
- data Float
- data Int
- data Int32
- data Int64
- data Integer
- data Natural
- data Maybe a
- data Ordering
- type Rational = Ratio Integer
- data IO a
- data Word8
- data Word32
- data Word64
- data Either a b
- type String = [Char]
- id :: a -> a
- either :: (a -> c) -> (b -> c) -> Either a b -> c
- data ByteString
- data Scientific
- (<$>) :: Functor f => (a -> b) -> f a -> f b
- class Hashable a where
- hashWithSalt :: Int -> a -> Int
- data Text
- data UTCTime
- data HashMap k v
- class ToJSON a where
- toJSON :: a -> Value
- toEncoding :: a -> Encoding
- toJSONList :: [a] -> Value
- toEncodingList :: [a] -> Encoding
- (.=) :: (KeyValue kv, ToJSON v) => Text -> v -> kv
- (.!=) :: Parser (Maybe a) -> a -> Parser a
- (.:?) :: FromJSON a => Object -> Text -> Parser (Maybe a)
- (.:) :: FromJSON a => Object -> Text -> Parser a
- withObject :: String -> (Object -> Parser a) -> Value -> Parser a
- class FromJSON a where
- object :: [Pair] -> Value
- emptyObject :: Value
- read :: Read a => String -> a
- readIO :: Read a => String -> IO a
- readLn :: Read a => IO a
- appendFile :: FilePath -> String -> IO ()
- writeFile :: FilePath -> String -> IO ()
- readFile :: FilePath -> IO String
- interact :: (String -> String) -> IO ()
- getContents :: IO String
- getLine :: IO String
- getChar :: IO Char
- putStrLn :: String -> IO ()
- putStr :: String -> IO ()
- putChar :: Char -> IO ()
- ioError :: IOError -> IO a
- type FilePath = String
- userError :: String -> IOError
- type IOError = IOException
- notElem :: (Foldable t, Eq a) => a -> t a -> Bool
- all :: Foldable t => (a -> Bool) -> t a -> Bool
- or :: Foldable t => t Bool -> Bool
- and :: Foldable t => t Bool -> Bool
- concatMap :: Foldable t => (a -> [b]) -> t a -> [b]
- concat :: Foldable t => t [a] -> [a]
- sequence_ :: (Foldable t, Monad m) => t (m a) -> m ()
- mapM_ :: (Foldable t, Monad m) => (a -> m b) -> t a -> m ()
- unwords :: [String] -> String
- words :: String -> [String]
- unlines :: [String] -> String
- lines :: String -> [String]
- reads :: Read a => ReadS a
- asProxyTypeOf :: a -> proxy a -> a
- data Proxy (t :: k) :: forall k. k -> Type = Proxy
- data KProxy t = KProxy
- lex :: ReadS String
- readParen :: Bool -> ReadS a -> ReadS a
- type ReadS a = String -> [(a, String)]
- type family If (cond :: Bool) (tru :: k) (fls :: k) :: k where ...
- lcm :: Integral a => a -> a -> a
- gcd :: Integral a => a -> a -> a
- (^^) :: (Fractional a, Integral b) => a -> b -> a
- (^) :: (Num a, Integral b) => a -> b -> a
- odd :: Integral a => a -> Bool
- even :: Integral a => a -> Bool
- showParen :: Bool -> ShowS -> ShowS
- showString :: String -> ShowS
- showChar :: Char -> ShowS
- shows :: Show a => a -> ShowS
- type ShowS = String -> String
- unzip3 :: [(a, b, c)] -> ([a], [b], [c])
- unzip :: [(a, b)] -> ([a], [b])
- zipWith3 :: (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]
- zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]
- zip3 :: [a] -> [b] -> [c] -> [(a, b, c)]
- (!!) :: [a] -> Int -> a
- lookup :: Eq a => a -> [(a, b)] -> Maybe b
- reverse :: [a] -> [a]
- break :: (a -> Bool) -> [a] -> ([a], [a])
- splitAt :: Int -> [a] -> ([a], [a])
- drop :: Int -> [a] -> [a]
- take :: Int -> [a] -> [a]
- dropWhile :: (a -> Bool) -> [a] -> [a]
- takeWhile :: (a -> Bool) -> [a] -> [a]
- cycle :: [a] -> [a]
- replicate :: Int -> a -> [a]
- repeat :: a -> [a]
- iterate :: (a -> a) -> a -> [a]
- scanr1 :: (a -> a -> a) -> [a] -> [a]
- scanr :: (a -> b -> b) -> b -> [a] -> [b]
- scanl1 :: (a -> a -> a) -> [a] -> [a]
- scanl :: (b -> a -> b) -> b -> [a] -> [b]
- init :: [a] -> [a]
- last :: [a] -> a
- tail :: [a] -> [a]
- head :: [a] -> a
- mapMaybe :: (a -> Maybe b) -> [a] -> [b]
- catMaybes :: [Maybe a] -> [a]
- listToMaybe :: [a] -> Maybe a
- maybeToList :: Maybe a -> [a]
- fromMaybe :: a -> Maybe a -> a
- fromJust :: Maybe a -> a
- isNothing :: Maybe a -> Bool
- isJust :: Maybe a -> Bool
- maybe :: b -> (a -> b) -> Maybe a -> b
- uncurry :: (a -> b -> c) -> (a, b) -> c
- curry :: ((a, b) -> c) -> a -> b -> c
- subtract :: Num a => a -> a -> a
- asTypeOf :: a -> a -> a
- until :: (a -> Bool) -> (a -> a) -> a -> a
- ($!) :: (a -> b) -> a -> b
- flip :: (a -> b -> c) -> b -> a -> c
- (.) :: (b -> c) -> (a -> b) -> a -> c
- const :: a -> b -> a
- (=<<) :: Monad m => (a -> m b) -> m a -> m b
- undefined :: HasCallStack => a
- errorWithoutStackTrace :: [Char] -> a
- error :: HasCallStack => [Char] -> a
- (&&) :: Bool -> Bool -> Bool
- (||) :: Bool -> Bool -> Bool
- not :: Bool -> Bool
- class ToHttpApiData a where
- toUrlPiece :: a -> Text
- toEncodedUrlPiece :: a -> Builder
- toHeader :: a -> ByteString
- toQueryParam :: a -> Text
- class FromHttpApiData a where
- parseUrlPiece :: Text -> Either Text a
- parseHeader :: ByteString -> Either Text a
- parseQueryParam :: Text -> Either Text a
- data URI = URI {}
- data RequestBody
- data HttpVersion = HttpVersion {}
- data StdMethod
- mapping :: (Functor f, Functor g) => AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
- _Just :: Prism (Maybe a) (Maybe b) a b
- (#) :: AReview t b -> b -> t
- (^.) :: s -> Getting a s a -> a
- lens :: (s -> a) -> (s -> b -> t) -> Lens s t a b
- type Lens' s a = Lens s s a a
- allFieldLinks' :: (HasLink (ToServantApi routes), GenericServant routes (AsLink a), ToServant routes (AsLink a) ~ MkLink (ToServantApi routes) a) => (Link -> a) -> routes (AsLink a)
- allFieldLinks :: (HasLink (ToServantApi routes), GenericServant routes (AsLink Link), ToServant routes (AsLink Link) ~ MkLink (ToServantApi routes) Link) => routes (AsLink Link)
- fieldLink' :: (IsElem endpoint (ToServantApi routes), HasLink endpoint, GenericServant routes AsApi) => (Link -> a) -> (routes AsApi -> endpoint) -> MkLink endpoint a
- fieldLink :: (IsElem endpoint (ToServantApi routes), HasLink endpoint, GenericServant routes AsApi) => (routes AsApi -> endpoint) -> MkLink endpoint Link
- allLinks' :: HasLink api => (Link -> a) -> Proxy api -> MkLink api a
- allLinks :: HasLink api => Proxy api -> MkLink api Link
- safeLink' :: (IsElem endpoint api, HasLink endpoint) => (Link -> a) -> Proxy api -> Proxy endpoint -> MkLink endpoint a
- safeLink :: (IsElem endpoint api, HasLink endpoint) => Proxy api -> Proxy endpoint -> MkLink endpoint Link
- linkURI' :: LinkArrayElementStyle -> Link -> URI
- linkURI :: Link -> URI
- linkQueryParams :: Link -> [Param]
- linkSegments :: Link -> [String]
- data Param
- data LinkArrayElementStyle
- data AsLink a
- class HasLink (endpoint :: k) where
- type StreamGet = Stream GET 200
- type StreamPost = Stream POST 200
- type StreamBody = StreamBody' ([] :: [Type])
- data StreamBody' (mods :: [Type]) framing contentType a
- type SourceIO = SourceT IO
- class ToSourceIO chunk a | a -> chunk where
- toSourceIO :: a -> SourceIO chunk
- class FromSourceIO chunk a | a -> chunk where
- fromSourceIO :: SourceIO chunk -> a
- class FramingRender (strategy :: k) where
- framingRender :: Monad m => Proxy strategy -> (a -> ByteString) -> SourceT m a -> SourceT m ByteString
- class FramingUnrender (strategy :: k) where
- framingUnrender :: Monad m => Proxy strategy -> (ByteString -> Either String a) -> SourceT m ByteString -> SourceT m a
- data NoFraming
- data NewlineFraming
- data NetstringFraming
- data WithNamedContext (name :: Symbol) (subContext :: [Type]) subApi
- type family Endpoints api :: [Type] where ...
- type family IsElem' a s :: Constraint
- type family IsElem endpoint api :: Constraint where ...
- type family IsSubAPI sub api :: Constraint where ...
- type family AllIsElem (xs :: [Type]) api :: Constraint where ...
- type family IsIn endpoint api :: Constraint where ...
- type family IsStrictSubAPI sub api :: Constraint where ...
- type family AllIsIn (xs :: [Type]) api :: Constraint where ...
- type family MapSub (e :: k) (xs :: [Type]) :: [Type] where ...
- type family AppendList (xs :: [a]) (ys :: [a]) :: [a] where ...
- type family IsSubList (a :: [t]) (b :: [t]) :: Constraint where ...
- type Elem (e :: t) (es :: [t]) = ElemGo e es es
- type family ElemGo (e :: t) (es :: [t]) (orig :: t1) :: Constraint where ...
- type family Or a b :: Constraint where ...
- type family And a b :: Constraint where ...
- data Verb (method :: k1) (statusCode :: Nat) (contentTypes :: [Type]) a :: forall k1. k1 -> Nat -> [Type] -> Type -> Type
- type Get = Verb GET 200
- type Post = Verb POST 200
- type Put = Verb PUT 200
- type Delete = Verb DELETE 200
- type Patch = Verb PATCH 200
- type PostCreated = Verb POST 201
- type PutCreated = Verb PUT 201
- type GetAccepted = Verb GET 202
- type PostAccepted = Verb POST 202
- type DeleteAccepted = Verb DELETE 202
- type PatchAccepted = Verb PATCH 202
- type PutAccepted = Verb PUT 202
- type GetNonAuthoritative = Verb GET 203
- type PostNonAuthoritative = Verb POST 203
- type DeleteNonAuthoritative = Verb DELETE 203
- type PatchNonAuthoritative = Verb PATCH 203
- type PutNonAuthoritative = Verb PUT 203
- type GetNoContent = Verb GET 204
- type PostNoContent = Verb POST 204
- type DeleteNoContent = Verb DELETE 204
- type PatchNoContent = Verb PATCH 204
- type PutNoContent = Verb PUT 204
- type GetResetContent = Verb GET 205
- type PostResetContent = Verb POST 205
- type GetPartialContent = Verb GET 206
- class ReflectMethod (a :: k) where
- reflectMethod :: Proxy a -> Method
- data (path :: k) :> a :: forall k. k -> Type -> Type
- lookupResponseHeader :: HasResponseHeader h a headers => Headers headers r -> ResponseHeader h a
- noHeader :: AddHeader h v orig new => orig -> new
- addHeader :: AddHeader h v orig new => v -> orig -> new
- getHeadersHList :: Headers ls a -> HList ls
- pattern MissingHeader :: ResponseHeader sym a
- pattern UndecodableHeader :: ByteString -> ResponseHeader sym a
- data HList (a :: [Type]) where
- class BuildHeadersTo (hs :: [Type]) where
- buildHeadersTo :: [Header] -> HList hs
- class GetHeaders ls where
- getHeaders :: ls -> [Header]
- class AddHeader (h :: Symbol) v orig new | h v orig -> new, new -> h, new -> v, new -> orig
- class HasResponseHeader (h :: Symbol) a (headers :: [Type])
- type ReqBody = ReqBody' (Required ': (Strict ': ([] :: [Type])))
- data ReqBody' (mods :: [Type]) (contentTypes :: [Type]) a
- data RemoteHost
- data Raw
- type QueryParam = QueryParam' (Optional ': (Strict ': ([] :: [Type])))
- data QueryParam' (mods :: [Type]) (sym :: Symbol) a
- data QueryParams (sym :: Symbol) a
- data QueryFlag (sym :: Symbol)
- data Header' (mods :: [Type]) (sym :: Symbol) (a :: k) :: forall k. [Type] -> Symbol -> k -> Type
- data Required
- data Optional
- data Lenient
- data Strict
- data IsSecure
- data AuthProtect (tag :: k) :: forall k. k -> Type
- data EmptyAPI = EmptyAPI
- data Summary (sym :: Symbol)
- data Description (sym :: Symbol)
- data JSON
- data PlainText
- data FormUrlEncoded
- data OctetStream
- class Accept (ctype :: k) where
- contentType :: Proxy ctype -> MediaType
- contentTypes :: Proxy ctype -> NonEmpty MediaType
- class Accept ctype => MimeRender (ctype :: k) a where
- mimeRender :: Proxy ctype -> a -> ByteString
- class Accept ctype => MimeUnrender (ctype :: k) a where
- mimeUnrender :: Proxy ctype -> ByteString -> Either String a
- mimeUnrenderWithType :: Proxy ctype -> MediaType -> ByteString -> Either String a
- data NoContent = NoContent
- type Capture = Capture' ([] :: [Type])
- data Capture' (mods :: [Type]) (sym :: Symbol) a
- data CaptureAll (sym :: Symbol) a
- data BasicAuth (realm :: Symbol) userData
- data BasicAuthData = BasicAuthData {}
- data a :<|> b = a :<|> b
- type Vault = Vault RealWorld
- class SBoolI (b :: Bool) where
- data SBool (b :: Bool) where
- data TimeOfDay
- data Day
- newtype Textual a = Textual a
- type JSONValue = Value
- parseJSONObject :: FromJSON a => HashMap Text Value -> Parser a
- parseJSONText :: FromHttpApiData a => String -> Value -> Parser a
- toJSONText :: ToHttpApiData a => a -> Value
- newtype Bytes = Bytes {}
- _Bytes :: Iso' Bytes ByteString
- newtype Nat = Nat {}
- data GDuration
- newtype DateTime' = DateTime' {}
- data Date'
- data Time'
- _Time :: Iso' Time' TimeOfDay
- _Date :: Iso' Date' Day
- _DateTime :: Iso' DateTime' UTCTime
- _GDuration :: Iso' GDuration Scientific
- newtype GFieldMask = GFieldMask Text
- newtype Seconds = Seconds Int
- data MultipartRelated (cs :: [*]) m
- data CaptureMode (s :: Symbol) (m :: Symbol) a
- data Captures (s :: Symbol) a
- class GoogleClient fn where
- type Fn fn :: *
- buildClient :: Proxy fn -> Request -> Fn fn
- class GoogleRequest a where
- class Accept c => FromStream c a where
- fromStream :: Proxy c -> Stream -> ResourceT IO (Either (String, ByteString) a)
- class Accept c => ToBody c a where
- data GClient a = GClient {
- _cliAccept :: !(Maybe MediaType)
- _cliMethod :: !Method
- _cliCheck :: !(Status -> Bool)
- _cliService :: !ServiceConfig
- _cliRequest :: !Request
- _cliResponse :: !(Stream -> ResourceT IO (Either (String, ByteString) a))
- data Request = Request {
- _rqPath :: !Builder
- _rqQuery :: !(DList (ByteString, Maybe ByteString))
- _rqHeaders :: !(DList (HeaderName, ByteString))
- _rqBody :: ![Body]
- data Body = Body !MediaType !RequestBody
- data ServiceConfig = ServiceConfig {
- _svcId :: !ServiceId
- _svcHost :: !ByteString
- _svcPath :: !Builder
- _svcPort :: !Int
- _svcSecure :: !Bool
- _svcTimeout :: !(Maybe Seconds)
- class AsError a where
- data ServiceError = ServiceError' {
- _serviceId :: !ServiceId
- _serviceStatus :: !Status
- _serviceHeaders :: ![Header]
- _serviceBody :: !(Maybe ByteString)
- data SerializeError = SerializeError' {}
- data Error
- type Stream = ConduitM () ByteString (ResourceT IO) ()
- data MediaUpload a = MediaUpload a Body
- newtype MediaDownload a = MediaDownload a
- newtype GSecret = GSecret Text
- newtype ServiceId = ServiceId Text
- newtype ClientId = ClientId Text
- newtype RefreshToken = RefreshToken Text
- newtype AccessToken = AccessToken Text
- newtype OAuthScope = OAuthScope Text
- data Multipart = Multipart
- data AltMedia = AltMedia
- data AltJSON = AltJSON
- _Coerce :: (Coercible a b, Coercible b a) => Iso' a b
- _Default :: Monoid a => Iso' (Maybe a) a
- defaultService :: ServiceId -> ByteString -> ServiceConfig
- serviceHost :: Lens' ServiceConfig ByteString
- servicePort :: Lens' ServiceConfig Int
- servicePath :: Lens' ServiceConfig Builder
- serviceSecure :: Lens' ServiceConfig Bool
- serviceTimeout :: Lens' ServiceConfig (Maybe Seconds)
- bodyContentType :: Lens' Body MediaType
- appendPath :: Request -> Builder -> Request
- appendPaths :: ToHttpApiData a => Request -> [a] -> Request
- appendQuery :: Request -> ByteString -> Maybe Text -> Request
- appendHeader :: Request -> HeaderName -> Maybe Text -> Request
- setBody :: Request -> [Body] -> Request
- clientService :: Lens' (GClient a) ServiceConfig
- mime :: FromStream c a => Proxy c -> Method -> [Int] -> Request -> ServiceConfig -> GClient a
- discard :: Method -> [Int] -> Request -> ServiceConfig -> GClient ()
- gClient :: (Stream -> ResourceT IO (Either (String, ByteString) a)) -> Maybe MediaType -> Method -> [Int] -> Request -> ServiceConfig -> GClient a
- sinkLBS :: Stream -> ResourceT IO ByteString
- buildText :: ToHttpApiData a => a -> Builder
- buildSymbol :: forall n proxy. KnownSymbol n => proxy n -> Builder
- byteSymbol :: forall n proxy. KnownSymbol n => proxy n -> ByteString
- seconds :: Seconds -> Int
- microseconds :: Seconds -> Int
Documentation
(++) :: [a] -> [a] -> [a] infixr 5 #
Append two lists, i.e.,
[x1, ..., xm] ++ [y1, ..., yn] == [x1, ..., xm, y1, ..., yn] [x1, ..., xm] ++ [y1, ...] == [x1, ..., xm, y1, ...]
If the first list is not finite, the result is the first list.
The value of seq a b
is bottom if a
is bottom, and
otherwise equal to b
. In other words, it evaluates the first
argument a
to weak head normal form (WHNF). seq
is usually
introduced to improve performance by avoiding unneeded laziness.
A note on evaluation order: the expression seq a b
does
not guarantee that a
will be evaluated before b
.
The only guarantee given by seq
is that the both a
and b
will be evaluated before seq
returns a value.
In particular, this means that b
may be evaluated before
a
. If you need to guarantee a specific order of evaluation,
you must use the function pseq
from the "parallel" package.
filter :: (a -> Bool) -> [a] -> [a] #
filter
, applied to a predicate and a list, returns the list of
those elements that satisfy the predicate; i.e.,
filter p xs = [ x | x <- xs, p x]
print :: Show a => a -> IO () #
The print
function outputs a value of any printable type to the
standard output device.
Printable types are those that are instances of class Show
; print
converts values to strings for output using the show
operation and
adds a newline.
For example, a program to print the first 20 integers and their powers of 2 could be written as:
main = print ([(n, 2^n) | n <- [0..19]])
map :: (a -> b) -> [a] -> [b] #
map
f xs
is the list obtained by applying f
to each element
of xs
, i.e.,
map f [x1, x2, ..., xn] == [f x1, f x2, ..., f xn] map f [x1, x2, ...] == [f x1, f x2, ...]
($) :: (a -> b) -> a -> b infixr 0 #
Application operator. This operator is redundant, since ordinary
application (f x)
means the same as (f
. However, $
x)$
has
low, right-associative binding precedence, so it sometimes allows
parentheses to be omitted; for example:
f $ g $ h x = f (g (h x))
It is also useful in higher-order situations, such as
,
or map
($
0) xs
.zipWith
($
) fs xs
Note that ($)
is levity-polymorphic in its result type, so that
foo $ True where foo :: Bool -> Int#
is well-typed
fromIntegral :: (Integral a, Num b) => a -> b #
general coercion from integral types
realToFrac :: (Real a, Fractional b) => a -> b #
general coercion to fractional types
The Bounded
class is used to name the upper and lower limits of a
type. Ord
is not a superclass of Bounded
since types that are not
totally ordered may also have upper and lower bounds.
The Bounded
class may be derived for any enumeration type;
minBound
is the first constructor listed in the data
declaration
and maxBound
is the last.
Bounded
may also be derived for single-constructor datatypes whose
constituent types are in Bounded
.
Instances
Class Enum
defines operations on sequentially ordered types.
The enumFrom
... methods are used in Haskell's translation of
arithmetic sequences.
Instances of Enum
may be derived for any enumeration type (types
whose constructors have no fields). The nullary constructors are
assumed to be numbered left-to-right by fromEnum
from 0
through n-1
.
See Chapter 10 of the Haskell Report for more details.
For any type that is an instance of class Bounded
as well as Enum
,
the following should hold:
- The calls
andsucc
maxBound
should result in a runtime error.pred
minBound
fromEnum
andtoEnum
should give a runtime error if the result value is not representable in the result type. For example,
is an error.toEnum
7 ::Bool
enumFrom
andenumFromThen
should be defined with an implicit bound, thus:
enumFrom x = enumFromTo x maxBound enumFromThen x y = enumFromThenTo x y bound where bound | fromEnum y >= fromEnum x = maxBound | otherwise = minBound
the successor of a value. For numeric types, succ
adds 1.
the predecessor of a value. For numeric types, pred
subtracts 1.
Convert from an Int
.
Convert to an Int
.
It is implementation-dependent what fromEnum
returns when
applied to a value that is too large to fit in an Int
.
Used in Haskell's translation of [n..]
with [n..] = enumFrom n
,
a possible implementation being enumFrom n = n : enumFrom (succ n)
.
For example:
enumFrom 4 :: [Integer] = [4,5,6,7,...]
enumFrom 6 :: [Int] = [6,7,8,9,...,maxBound :: Int]
enumFromThen :: a -> a -> [a] #
Used in Haskell's translation of [n,n'..]
with [n,n'..] = enumFromThen n n'
, a possible implementation being
enumFromThen n n' = n : n' : worker (f x) (f x n')
,
worker s v = v : worker s (s v)
, x = fromEnum n' - fromEnum n
and
f n y
| n > 0 = f (n - 1) (succ y)
| n < 0 = f (n + 1) (pred y)
| otherwise = y
For example:
enumFromThen 4 6 :: [Integer] = [4,6,8,10...]
enumFromThen 6 2 :: [Int] = [6,2,-2,-6,...,minBound :: Int]
enumFromTo :: a -> a -> [a] #
Used in Haskell's translation of [n..m]
with
[n..m] = enumFromTo n m
, a possible implementation being
enumFromTo n m
| n <= m = n : enumFromTo (succ n) m
| otherwise = []
.
For example:
enumFromTo 6 10 :: [Int] = [6,7,8,9,10]
enumFromTo 42 1 :: [Integer] = []
enumFromThenTo :: a -> a -> a -> [a] #
Used in Haskell's translation of [n,n'..m]
with
[n,n'..m] = enumFromThenTo n n' m
, a possible implementation
being enumFromThenTo n n' m = worker (f x) (c x) n m
,
x = fromEnum n' - fromEnum n
, c x = bool (>=) ((x 0)
f n y
| n > 0 = f (n - 1) (succ y)
| n < 0 = f (n + 1) (pred y)
| otherwise = y
and
worker s c v m
| c v m = v : worker s c (s v) m
| otherwise = []
For example:
enumFromThenTo 4 2 -6 :: [Integer] = [4,2,0,-2,-4,-6]
enumFromThenTo 6 8 2 :: [Int] = []
Instances
The Eq
class defines equality (==
) and inequality (/=
).
All the basic datatypes exported by the Prelude are instances of Eq
,
and Eq
may be derived for any datatype whose constituents are also
instances of Eq
.
The Haskell Report defines no laws for Eq
. However, ==
is customarily
expected to implement an equivalence relationship where two values comparing
equal are indistinguishable by "public" functions, with a "public" function
being one not allowing to see implementation details. For example, for a
type representing non-normalised natural numbers modulo 100, a "public"
function doesn't make the difference between 1 and 201. It is expected to
have the following properties: