License | BSD-style |
---|---|
Maintainer | Vincent Hanquez <vincent@snarc.org> |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Foundation
Contents
Description
I tried to picture clusters of information As they moved through the computer What do they look like?
Alternative Prelude
Synopsis
- ($) :: (a -> b) -> a -> b
- ($!) :: (a -> b) -> a -> b
- (&&) :: Bool -> Bool -> Bool
- (||) :: Bool -> Bool -> Bool
- (.) :: Category cat => cat b c -> cat a b -> cat a c
- not :: Bool -> Bool
- otherwise :: Bool
- data Tuple2 a b = Tuple2 !a !b
- data Tuple3 a b c = Tuple3 !a !b !c
- data Tuple4 a b c d = Tuple4 !a !b !c !d
- class Fstable a where
- type ProductFirst a
- fst :: a -> ProductFirst a
- class Sndable a where
- type ProductSecond a
- snd :: a -> ProductSecond a
- class Thdable a where
- type ProductThird a
- thd :: a -> ProductThird a
- id :: Category cat => cat a a
- maybe :: b -> (a -> b) -> Maybe a -> b
- either :: (a -> c) -> (b -> c) -> Either a b -> c
- flip :: (a -> b -> c) -> b -> a -> c
- const :: a -> b -> a
- error :: HasCallStack => String -> a
- putStr :: String -> IO ()
- putStrLn :: String -> IO ()
- getArgs :: IO [String]
- uncurry :: (a -> b -> c) -> (a, b) -> c
- curry :: ((a, b) -> c) -> a -> b -> c
- swap :: (a, b) -> (b, a)
- until :: (a -> Bool) -> (a -> a) -> a -> a
- asTypeOf :: a -> a -> a
- undefined :: HasCallStack => a
- seq :: a -> b -> b
- class NormalForm a
- deepseq :: NormalForm a => a -> b -> b
- force :: NormalForm a => a -> a
- class Show a
- show :: Show a => a -> String
- class Eq a => Ord a where
- class Eq a where
- 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 Functor (f :: Type -> Type) where
- class Integral a where
- fromInteger :: Integer -> a
- class Fractional a where
- fromRational :: Rational -> a
- class HasNegation a where
- negate :: a -> a
- class Bifunctor (p :: Type -> Type -> Type) where
- class Functor f => Applicative (f :: Type -> Type) where
- class Applicative m => Monad (m :: Type -> Type) where
- (=<<) :: Monad m => (a -> m b) -> m a -> m b
- class IsString a where
- fromString :: String -> a
- class IsList l where
- class (Integral a, Eq a, Ord a) => IsIntegral a where
- class IsIntegral a => IsNatural a where
- class Signed a where
- class Additive a where
- class Subtractive a where
- type Difference a :: Type
- (-) :: a -> a -> Difference a
- class Multiplicative a where
- class (Additive a, Multiplicative a) => IDivisible a where
- class Multiplicative a => Divisible a where
- (/) :: a -> a -> a
- data Maybe a
- data Ordering
- data Bool
- data Char
- data Char7
- data IO a
- data Either a b
- data Int8
- data Int16
- data Int32
- data Int64
- data Word8
- data Word16
- data Word32
- data Word64
- data Word
- data Word128
- data Word256
- data Int
- data Integer
- data Natural
- type Rational = Ratio Integer
- data Float
- data Double
- newtype CountOf ty = CountOf Int
- newtype Offset ty = Offset Int
- toCount :: Int -> CountOf ty
- fromCount :: CountOf ty -> Int
- data UArray ty
- class Eq ty => PrimType ty
- data Array a
- data String
- (^^) :: (Fractional a, Integral b) => a -> b -> a
- fromIntegral :: (Integral a, Num b) => a -> b
- realToFrac :: (Real a, Fractional b) => a -> b
- class Semigroup a
- class Semigroup a => Monoid a where
- (<>) :: Semigroup a => a -> a -> a
- class (IsList c, Item c ~ Element c) => Collection c where
- null :: c -> Bool
- length :: c -> CountOf (Element c)
- elem :: forall a. (Eq a, a ~ Element c) => Element c -> c -> Bool
- notElem :: forall a. (Eq a, a ~ Element c) => Element c -> c -> Bool
- maximum :: forall a. (Ord a, a ~ Element c) => NonEmpty c -> Element c
- minimum :: forall a. (Ord a, a ~ Element c) => NonEmpty c -> Element c
- any :: (Element c -> Bool) -> c -> Bool
- all :: (Element c -> Bool) -> c -> Bool
- and :: (Collection col, Element col ~ Bool) => col -> Bool
- or :: (Collection col, Element col ~ Bool) => col -> Bool
- class (IsList c, Item c ~ Element c, Monoid c, Collection c) => Sequential c where
- take :: CountOf (Element c) -> c -> c
- revTake :: CountOf (Element c) -> c -> c
- drop :: CountOf (Element c) -> c -> c
- revDrop :: CountOf (Element c) -> c -> c
- splitAt :: CountOf (Element c) -> c -> (c, c)
- revSplitAt :: CountOf (Element c) -> c -> (c, c)
- splitOn :: (Element c -> Bool) -> c -> [c]
- break :: (Element c -> Bool) -> c -> (c, c)
- breakEnd :: (Element c -> Bool) -> c -> (c, c)
- breakElem :: Eq (Element c) => Element c -> c -> (c, c)
- takeWhile :: (Element c -> Bool) -> c -> c
- dropWhile :: (Element c -> Bool) -> c -> c
- intersperse :: Element c -> c -> c
- intercalate :: Monoid (Item c) => Element c -> c -> Element c
- span :: (Element c -> Bool) -> c -> (c, c)
- spanEnd :: (Element c -> Bool) -> c -> (c, c)
- filter :: (Element c -> Bool) -> c -> c
- partition :: (Element c -> Bool) -> c -> (c, c)
- reverse :: c -> c
- uncons :: c -> Maybe (Element c, c)
- unsnoc :: c -> Maybe (c, Element c)
- snoc :: c -> Element c -> c
- cons :: Element c -> c -> c
- find :: (Element c -> Bool) -> c -> Maybe (Element c)
- sortBy :: (Element c -> Element c -> Ordering) -> c -> c
- singleton :: Element c -> c
- head :: NonEmpty c -> Element c
- last :: NonEmpty c -> Element c
- tail :: NonEmpty c -> c
- init :: NonEmpty c -> c
- replicate :: CountOf (Element c) -> Element c -> c
- isPrefixOf :: Eq (Element c) => c -> c -> Bool
- isSuffixOf :: Eq (Element c) => c -> c -> Bool
- isInfixOf :: Eq (Element c) => c -> c -> Bool
- stripPrefix :: Eq (Element c) => c -> c -> Maybe c
- stripSuffix :: Eq (Element c) => c -> c -> Maybe c
- data NonEmpty a
- nonEmpty :: Collection c => c -> Maybe (NonEmpty c)
- class Foldable collection where
- mapMaybe :: (a -> Maybe b) -> [a] -> [b]
- catMaybes :: [Maybe a] -> [a]
- fromMaybe :: a -> Maybe a -> a
- isJust :: Maybe a -> Bool
- isNothing :: Maybe a -> Bool
- listToMaybe :: [a] -> Maybe a
- maybeToList :: Maybe a -> [a]
- partitionEithers :: [Either a b] -> ([a], [b])
- lefts :: [Either a b] -> [a]
- rights :: [Either a b] -> [b]
- on :: (b -> b -> c) -> (a -> b) -> a -> a -> c
- (<$>) :: Functor f => (a -> b) -> f a -> f b
- (<|>) :: Alternative f => f a -> f a -> f a
- (>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c
- class (Typeable e, Show e) => Exception e where
- toException :: e -> SomeException
- fromException :: SomeException -> Maybe e
- displayException :: e -> String
- class Typeable (a :: k)
- data SomeException
- data IOException
- data Proxy (t :: k) :: forall k. k -> Type = Proxy
- asProxyTypeOf :: a -> proxy a -> a
- data Partial a
- partial :: a -> Partial a
- data PartialError
- fromPartial :: Partial a -> a
- ifThenElse :: Bool -> a -> a -> a
- type LString = String
Standard
Operators
($) :: (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
($!) :: (a -> b) -> a -> b infixr 0 #
Strict (call-by-value) application operator. It takes a function and an argument, evaluates the argument to weak head normal form (WHNF), then calls the function with that value.
Functions
Strict tuple (a,b)
Constructors
Tuple2 !a !b |
Instances
Bifunctor Tuple2 Source # | |
Nthable 1 (Tuple2 a b) Source # | |
Nthable 2 (Tuple2 a b) Source # | |
(Eq a, Eq b) => Eq (Tuple2 a b) Source # | |
(Data a, Data b) => Data (Tuple2 a b) Source # | |
Defined in Foundation.Tuple Methods gfoldl :: (forall d b0. Data d => c (d -> b0) -> d -> c b0) -> (forall g. g -> c g) -> Tuple2 a b -> c (Tuple2 a b) # gunfold :: (forall b0 r. Data b0 => c (b0 -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Tuple2 a b) # toConstr :: Tuple2 a b -> Constr # dataTypeOf :: Tuple2 a b -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Tuple2 a b)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Tuple2 a b)) # gmapT :: (forall b0. Data b0 => b0 -> b0) -> Tuple2 a b -> Tuple2 a b # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Tuple2 a b -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Tuple2 a b -> r # gmapQ :: (forall d. Data d => d -> u) -> Tuple2 a b -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Tuple2 a b -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Tuple2 a b -> m (Tuple2 a b) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Tuple2 a b -> m (Tuple2 a b) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Tuple2 a b -> m (Tuple2 a b) # | |
(Ord a, Ord b) => Ord (Tuple2 a b) Source # | |
(Show a, Show b) => Show (Tuple2 a b) Source # | |
Generic (Tuple2 a b) Source # | |
(NormalForm a, NormalForm b) => NormalForm (Tuple2 a b) Source # | |
Defined in Foundation.Tuple Methods toNormalForm :: Tuple2 a b -> () # | |
Sndable (Tuple2 a b) Source # | |
Defined in Foundation.Tuple Associated Types type ProductSecond (Tuple2 a b) :: Type Source # | |
Fstable (Tuple2 a b) Source # | |
Defined in Foundation.Tuple Associated Types type ProductFirst (Tuple2 a b) :: Type Source # | |
(Hashable a, Hashable b) => Hashable (Tuple2 a b) Source # | |
type NthTy 1 (Tuple2 a b) Source # | |
Defined in Foundation.Tuple.Nth | |
type NthTy 2 (Tuple2 a b) Source # | |
Defined in Foundation.Tuple.Nth | |
type Rep (Tuple2 a b) Source # | |
Defined in Foundation.Tuple type Rep (Tuple2 a b) = D1 (MetaData "Tuple2" "Foundation.Tuple" "foundation-0.0.22-6HDBI5C2MAZH6qgd5cO9mj" False) (C1 (MetaCons "Tuple2" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 a) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 b))) | |
type ProductSecond (Tuple2 a b) Source # | |
Defined in Foundation.Tuple | |
type ProductFirst (Tuple2 a b) Source # | |
Defined in Foundation.Tuple |
Strict tuple (a,b,c)
Constructors
Tuple3 !a !b !c |
Instances
Nthable 1 (Tuple3 a b c) Source # | |
Nthable 2 (Tuple3 a b c) Source # | |
Nthable 3 (Tuple3 a b c) Source # | |
(Eq a, Eq b, Eq c) => Eq (Tuple3 a b c) Source # | |
(Data a, Data b, Data c) => Data (Tuple3 a b c) Source # | |
Defined in Foundation.Tuple Methods gfoldl :: (forall d b0. Data d => c0 (d -> b0) -> d -> c0 b0) -> (forall g. g -> c0 g) -> Tuple3 a b c -> c0 (Tuple3 a b c) # gunfold :: (forall b0 r. Data b0 => c0 (b0 -> r) -> c0 r) -> (forall r. r -> c0 r) -> Constr -> c0 (Tuple3 a b c) # toConstr :: Tuple3 a b c -> Constr # dataTypeOf :: Tuple3 a b c -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c0 (t d)) -> Maybe (c0 (Tuple3 a b c)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c0 (t d e)) -> Maybe (c0 (Tuple3 a b c)) # gmapT :: (forall b0. Data b0 => b0 -> b0) -> Tuple3 a b c -> Tuple3 a b c # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Tuple3 a b c -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Tuple3 a b c -> r # gmapQ :: (forall d. Data d => d -> u) -> Tuple3 a b c -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Tuple3 a b c -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Tuple3 a b c -> m (Tuple3 a b c) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Tuple3 a b c -> m (Tuple3 a b c) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Tuple3 a b c -> m (Tuple3 a b c) # | |
(Ord a, Ord b, Ord c) => Ord (Tuple3 a b c) Source # | |
Defined in Foundation.Tuple | |
(Show a, Show b, Show c) => Show (Tuple3 a b c) Source # | |
Generic (Tuple3 a b c) Source # | |
(NormalForm a, NormalForm b, NormalForm c) => NormalForm (Tuple3 a b c) Source # | |
Defined in Foundation.Tuple Methods toNormalForm :: Tuple3 a b c -> () # | |
Thdable (Tuple3 a b c) Source # | |
Defined in Foundation.Tuple Associated Types type ProductThird (Tuple3 a b c) :: Type Source # | |
Sndable (Tuple3 a b c) Source # | |
Defined in Foundation.Tuple Associated Types type ProductSecond (Tuple3 a b c) :: Type Source # | |
Fstable (Tuple3 a b c) Source # | |
Defined in Foundation.Tuple Associated Types type ProductFirst (Tuple3 a b c) :: Type Source # | |
(Hashable a, Hashable b, Hashable c) => Hashable (Tuple3 a b c) Source # | |
type NthTy 1 (Tuple3 a b c) Source # | |
Defined in Foundation.Tuple.Nth | |
type NthTy 2 (Tuple3 a b c) Source # | |
Defined in Foundation.Tuple.Nth | |
type NthTy 3 (Tuple3 a b c) Source # | |
Defined in Foundation.Tuple.Nth | |
type Rep (Tuple3 a b c) Source # | |
Defined in Foundation.Tuple type Rep (Tuple3 a b c) = D1 (MetaData "Tuple3" "Foundation.Tuple" "foundation-0.0.22-6HDBI5C2MAZH6qgd5cO9mj" False) (C1 (MetaCons "Tuple3" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 a) :*: (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 b) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 c)))) | |
type ProductThird (Tuple3 a b c) Source # | |
Defined in Foundation.Tuple | |
type ProductSecond (Tuple3 a b c) Source # | |
Defined in Foundation.Tuple | |
type ProductFirst (Tuple3 a b c) Source # | |
Defined in Foundation.Tuple |
Strict tuple (a,b,c,d)
Constructors
Tuple4 !a !b !c !d |
Instances
Nthable 1 (Tuple4 a b c d) Source # | |
Nthable 2 (Tuple4 a b c d) Source # | |
Nthable 3 (Tuple4 a b c d) Source # | |
Nthable 4 (Tuple4 a b c d) Source # | |
(Eq a, Eq b, Eq c, Eq d) => Eq (Tuple4 a b c d) Source # | |
(Data a, Data b, Data c, Data d) => Data (Tuple4 a b c d) Source # | |
Defined in Foundation.Tuple Methods gfoldl :: (forall d0 b0. Data d0 => c0 (d0 -> b0) -> d0 -> c0 b0) -> (forall g. g -> c0 g) -> Tuple4 a b c d -> c0 (Tuple4 a b c d) # gunfold :: (forall b0 r. Data b0 => c0 (b0 -> r) -> c0 r) -> (forall r. r -> c0 r) -> Constr -> c0 (Tuple4 a b c d) # toConstr :: Tuple4 a b c d -> Constr # dataTypeOf :: Tuple4 a b c d -> DataType # dataCast1 :: Typeable t => (forall d0. Data d0 => c0 (t d0)) -> Maybe (c0 (Tuple4 a b c d)) # dataCast2 :: Typeable t => (forall d0 e. (Data d0, Data e) => c0 (t d0 e)) -> Maybe (c0 (Tuple4 a b c d)) # gmapT :: (forall b0. Data b0 => b0 -> b0) -> Tuple4 a b c d -> Tuple4 a b c d # gmapQl :: (r -> r' -> r) -> r -> (forall d0. Data d0 => d0 -> r') -> Tuple4 a b c d -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d0. Data d0 => d0 -> r') -> Tuple4 a b c d -> r # gmapQ :: (forall d0. Data d0 => d0 -> u) -> Tuple4 a b c d -> [u] # gmapQi :: Int -> (forall d0. Data d0 => d0 -> u) -> Tuple4 a b c d -> u # gmapM :: Monad m => (forall d0. Data d0 => d0 -> m d0) -> Tuple4 a b c d -> m (Tuple4 a b c d) # gmapMp :: MonadPlus m => (forall d0. Data d0 => d0 -> m d0) -> Tuple4 a b c d -> m (Tuple4 a b c d) # gmapMo :: MonadPlus m => (forall d0. Data d0 => d0 -> m d0) -> Tuple4 a b c d -> m (Tuple4 a b c d) # | |
(Ord a, Ord b, Ord c, Ord d) => Ord (Tuple4 a b c d) Source # | |
Defined in Foundation.Tuple Methods compare :: Tuple4 a b c d -> Tuple4 a b c d -> Ordering # (<) :: Tuple4 a b c d -> Tuple4 a b c d -> Bool # (<=) :: Tuple4 a b c d -> Tuple4 a b c d -> Bool # (>) :: Tuple4 a b c d -> Tuple4 a b c d -> Bool # (>=) :: Tuple4 a b c d -> Tuple4 a b c d -> Bool # | |
(Show a, Show b, Show c, Show d) => Show (Tuple4 a b c d) Source # | |
Generic (Tuple4 a b c d) Source # | |
(NormalForm a, NormalForm b, NormalForm c, NormalForm d) => NormalForm (Tuple4 a b c d) Source # | |
Defined in Foundation.Tuple Methods toNormalForm :: Tuple4 a b c d -> () # | |
Thdable (Tuple4 a b c d) Source # | |
Defined in Foundation.Tuple Associated Types type ProductThird (Tuple4 a b c d) :: Type Source # | |
Sndable (Tuple4 a b c d) Source # | |
Defined in Foundation.Tuple Associated Types type ProductSecond (Tuple4 a b c d) :: Type Source # | |
Fstable (Tuple4 a b c d) Source # | |
Defined in Foundation.Tuple Associated Types type ProductFirst (Tuple4 a b c d) :: Type Source # | |
(Hashable a, Hashable b, Hashable c, Hashable d) => Hashable (Tuple4 a b c d) Source # | |
type NthTy 1 (Tuple4 a b c d) Source # | |
Defined in Foundation.Tuple.Nth | |
type NthTy 2 (Tuple4 a b c d) Source # | |
Defined in Foundation.Tuple.Nth | |
type NthTy 3 (Tuple4 a b c d) Source # | |
Defined in Foundation.Tuple.Nth | |
type NthTy 4 (Tuple4 a b c d) Source # | |
Defined in Foundation.Tuple.Nth | |
type Rep (Tuple4 a b c d) Source # | |
Defined in Foundation.Tuple type Rep (Tuple4 a b c d) = D1 (MetaData "Tuple4" "Foundation.Tuple" "foundation-0.0.22-6HDBI5C2MAZH6qgd5cO9mj" False) (C1 (MetaCons "Tuple4" PrefixI False) ((S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 a) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 b)) :*: (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 c) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 d)))) | |
type ProductThird (Tuple4 a b c d) Source # | |
Defined in Foundation.Tuple | |
type ProductSecond (Tuple4 a b c d) Source # | |
Defined in Foundation.Tuple | |
type ProductFirst (Tuple4 a b c d) Source # | |
Defined in Foundation.Tuple |
class Fstable a where Source #
Class of product types that have a first element
Associated Types
type ProductFirst a Source #
Methods
fst :: a -> ProductFirst a Source #
Instances
Fstable (a, b) Source # | |
Defined in Foundation.Tuple Associated Types type ProductFirst (a, b) :: Type Source # Methods fst :: (a, b) -> ProductFirst (a, b) Source # | |
Fstable (Tuple2 a b) Source # | |
Defined in Foundation.Tuple Associated Types type ProductFirst (Tuple2 a b) :: Type Source # | |
Fstable (a, b, c) Source # | |
Defined in Foundation.Tuple Associated Types type ProductFirst (a, b, c) :: Type Source # Methods fst :: (a, b, c) -> ProductFirst (a, b, c) Source # | |
Fstable (Tuple3 a b c) Source # | |
Defined in Foundation.Tuple Associated Types type ProductFirst (Tuple3 a b c) :: Type Source # | |
Fstable (a, b, c, d) Source # | |
Defined in Foundation.Tuple Associated Types type ProductFirst (a, b, c, d) :: Type Source # Methods fst :: (a, b, c, d) -> ProductFirst (a, b, c, d) Source # | |
Fstable (Tuple4 a b c d) Source # | |
Defined in Foundation.Tuple Associated Types type ProductFirst (Tuple4 a b c d) :: Type Source # |
class Sndable a where Source #
Class of product types that have a second element
Associated Types
type ProductSecond a Source #
Methods
snd :: a -> ProductSecond a Source #
Instances
Sndable (a, b) Source # | |
Defined in Foundation.Tuple Associated Types type ProductSecond (a, b) :: Type Source # Methods snd :: (a, b) -> ProductSecond (a, b) Source # | |
Sndable (Tuple2 a b) Source # | |
Defined in Foundation.Tuple Associated Types type ProductSecond (Tuple2 a b) :: Type Source # | |
Sndable (a, b, c) Source # | |
Defined in Foundation.Tuple Associated Types type ProductSecond (a, b, c) :: Type Source # Methods snd :: (a, b, c) -> ProductSecond (a, b, c) Source # | |
Sndable (Tuple3 a b c) Source # | |
Defined in Foundation.Tuple Associated Types type ProductSecond (Tuple3 a b c) :: Type Source # | |
Sndable (a, b, c, d) Source # | |
Defined in Foundation.Tuple Associated Types type ProductSecond (a, b, c, d) :: Type Source # Methods snd :: (a, b, c, d) -> ProductSecond (a, b, c, d) Source # | |
Sndable (Tuple4 a b c d) Source # | |
Defined in Foundation.Tuple Associated Types type ProductSecond (Tuple4 a b c d) :: Type Source # |
class Thdable a where Source #
Class of product types that have a third element
Associated Types
type ProductThird a Source #
Methods
thd :: a -> ProductThird a Source #
Instances
Thdable (a, b, c) Source # | |
Defined in Foundation.Tuple Associated Types type ProductThird (a, b, c) :: Type Source # Methods thd :: (a, b, c) -> ProductThird (a, b, c) Source # | |
Thdable (Tuple3 a b c) Source # | |
Defined in Foundation.Tuple Associated Types type ProductThird (Tuple3 a b c) :: Type Source # | |
Thdable (a, b, c, d) Source # | |
Defined in Foundation.Tuple Associated Types type ProductThird (a, b, c, d) :: Type Source # Methods thd :: (a, b, c, d) -> ProductThird (a, b, c, d) Source # | |
Thdable (Tuple4 a b c d) Source # | |
Defined in Foundation.Tuple Associated Types type ProductThird (Tuple4 a b c d) :: Type Source # |
maybe :: b -> (a -> b) -> Maybe a -> b #
The maybe
function takes a default value, a function, and a Maybe
value. If the Maybe
value is Nothing
, the function returns the
default value. Otherwise, it applies the function to the value inside
the Just
and returns the result.
Examples
Basic usage:
>>>
maybe False odd (Just 3)
True
>>>
maybe False odd Nothing
False
Read an integer from a string using readMaybe
. If we succeed,
return twice the integer; that is, apply (*2)
to it. If instead
we fail to parse an integer, return 0
by default:
>>>
import Text.Read ( readMaybe )
>>>
maybe 0 (*2) (readMaybe "5")
10>>>
maybe 0 (*2) (readMaybe "")
0
Apply show
to a Maybe Int
. If we have Just n
, we want to show
the underlying Int
n
. But if we have Nothing
, we return the
empty string instead of (for example) "Nothing":
>>>
maybe "" show (Just 5)
"5">>>
maybe "" show Nothing
""
either :: (a -> c) -> (b -> c) -> Either a b -> c #
Case analysis for the Either
type.
If the value is
, apply the first function to Left
aa
;
if it is
, apply the second function to Right
bb
.
Examples
We create two values of type
, one using the
Either
String
Int
Left
constructor and another using the Right
constructor. Then
we apply "either" the length
function (if we have a String
)
or the "times-two" function (if we have an Int
):
>>>
let s = Left "foo" :: Either String Int
>>>
let n = Right 3 :: Either String Int
>>>
either length (*2) s
3>>>
either length (*2) n
6
flip :: (a -> b -> c) -> b -> a -> c #
takes its (first) two arguments in the reverse order of flip
ff
.
>>>
flip (++) "hello" "world"
"worldhello"
const x
is a unary function which evaluates to x
for all inputs.
>>>
const 42 "hello"
42
>>>
map (const 42) [0..3]
[42,42,42,42]
error :: HasCallStack => String -> a #
stop execution and displays an error message
Returns a list of the program's command line arguments (not including the program name).
uncurry :: (a -> b -> c) -> (a, b) -> c #
uncurry
converts a curried function to a function on pairs.
Examples
>>>
uncurry (+) (1,2)
3
>>>
uncurry ($) (show, 1)
"1"
>>>
map (uncurry max) [(1,2), (3,4), (6,8)]
[2,4,8]
until :: (a -> Bool) -> (a -> a) -> a -> a #
yields the result of applying until
p ff
until p
holds.
undefined :: HasCallStack => a #
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.
class NormalForm a #
Data that can be fully evaluated in Normal Form
Minimal complete definition
Instances
deepseq :: NormalForm a => a -> b -> b #
force :: NormalForm a => a -> a #
Type classes
Conversion of values to readable String
s.
Derived instances of Show
have the following properties, which
are compatible with derived instances of Read
:
- The result of
show
is a syntactically correct Haskell expression containing only constants, given the fixity declarations in force at the point where the type is declared. It contains only the constructor names defined in the data type, parentheses, and spaces. When labelled constructor fields are used, braces, commas, field names, and equal signs are also used. - If the constructor is defined to be an infix operator, then
showsPrec
will produce infix applications of the constructor. - the representation will be enclosed in parentheses if the
precedence of the top-level constructor in
x
is less thand
(associativity is ignored). Thus, ifd
is0
then the result is never surrounded in parentheses; ifd
is11
it is always surrounded in parentheses, unless it is an atomic expression. - If the constructor is defined using record syntax, then
show
will produce the record-syntax form, with the fields given in the same order as the original declaration.
For example, given the declarations
infixr 5 :^: data Tree a = Leaf a | Tree a :^: Tree a
the derived instance of Show
is equivalent to
instance (Show a) => Show (Tree a) where showsPrec d (Leaf m) = showParen (d > app_prec) $ showString "Leaf " . showsPrec (app_prec+1) m where app_prec = 10 showsPrec d (u :^: v) = showParen (d > up_prec) $ showsPrec (up_prec+1) u . showString " :^: " . showsPrec (up_prec+1) v where up_prec = 5
Note that right-associativity of :^:
is ignored. For example,
produces the stringshow
(Leaf 1 :^: Leaf 2 :^: Leaf 3)"Leaf 1 :^: (Leaf 2 :^: Leaf 3)"
.
Instances
show :: Show a => a -> String #
Use the Show class to create a String.
Note that this is not efficient, since an intermediate [Char] is going to be created before turning into a real String.
The Ord
class is used for totally ordered datatypes.
Instances of Ord
can be derived for any user-defined datatype whose
constituent types are in Ord
. The declared order of the constructors in
the data declaration determines the ordering in derived Ord
instances. The
Ordering
datatype allows a single comparison to determine the precise
ordering of two objects.
The Haskell Report defines no laws for Ord
. However, <=
is customarily
expected to implement a non-strict partial order and have the following
properties:
- Transitivity
- if
x <= y && y <= z
=True
, thenx <= z
=True
- Reflexivity
x <= x
=True
- Antisymmetry
- if
x <= y && y <= x
=True
, thenx == y
=True
Note that the following operator interactions are expected to hold:
x >= y
=y <= x
x < y
=x <= y && x /= y
x > y
=y < x
x < y
=compare x y == LT
x > y
=compare x y == GT
x == y
=compare x y == EQ
min x y == if x <= y then x else y
=True
max x y == if x >= y then x else y
=True
Minimal complete definition: either compare
or <=
.
Using compare
can be more efficient for complex types.
Methods
compare :: a -> a -> Ordering #
(<) :: a -> a -> Bool infix 4 #
(<=) :: a -> a -> Bool infix 4 #
(>) :: a -> a -> Bool infix 4 #