Contract.Prelude
A custom Prelude that re-exports Purescript's prelude and further expands.
Re-exports from Ctl.Internal.Helpers
#liftMWith
#liftM
#liftEither
liftEither :: forall (a :: Type) (e :: Type) (m :: Type -> Type). MonadThrow e m => Either e a -> m a
#fromJustEff
fromJustEff :: forall (a :: Type). String -> Maybe a -> Effect a
Throws provided error on Nothing
#filterMapWithKeyM
#filterMapM
#appendLastMaybe
appendLastMaybe :: forall (a :: Type). Maybe a -> Maybe a -> Maybe a
Combine two Maybe
s taking the Last
Maybe
#appendFirstMaybe
appendFirstMaybe :: forall (a :: Type). Maybe a -> Maybe a -> Maybe a
Combine two Maybe
s taking the First
Maybe
#(<\>)
Operator alias for Ctl.Internal.Helpers.appendFirstMaybe (right-associative / precedence 5)
#(<<>>)
Operator alias for Ctl.Internal.Helpers.maybeArrayMerge (right-associative / precedence 5)
#(</>)
Operator alias for Ctl.Internal.Helpers.appendLastMaybe (right-associative / precedence 5)
Re-exports from Data.Either
#Either
data Either a b
The Either
type is used to represent a choice between two types of value.
A common use case for Either
is error handling, where Left
is used to
carry an error value and Right
is used to carry a success value.
Constructors
Instances
Functor (Either a)
Generic (Either a b) _
Invariant (Either a)
Apply (Either e)
The
Apply
instance allows functions contained within aRight
to transform a value contained within aRight
using the(<*>)
operator:Right f <*> Right x == Right (f x)
Left
values are left untouched:Left f <*> Right x == Left f Right f <*> Left y == Left y
Combining
Functor
's<$>
withApply
's<*>
can be used to transform a pure function to takeEither
-typed arguments sof :: a -> b -> c
becomesf :: Either l a -> Either l b -> Either l c
:f <$> Right x <*> Right y == Right (f x y)
The
Left
-preserving behaviour of both operators means the result of an expression like the above but where any one of the values isLeft
means the whole result becomesLeft
also, taking the firstLeft
value found:f <$> Left x <*> Right y == Left x f <$> Right x <*> Left y == Left y f <$> Left x <*> Left y == Left x
Applicative (Either e)
The
Applicative
instance enables lifting of values intoEither
with thepure
function:pure x :: Either _ _ == Right x
Combining
Functor
's<$>
withApply
's<*>
andApplicative
'spure
can be used to pass a mixture ofEither
and non-Either
typed values to a function that does not usually expect them, by usingpure
for any value that is not alreadyEither
typed:f <$> Right x <*> pure y == Right (f x y)
Even though
pure = Right
it is recommended to usepure
in situations like this as it allows the choice ofApplicative
to be changed later without having to go through and replaceRight
with a new constructor.Alt (Either e)
The
Alt
instance allows for a choice to be made between twoEither
values with the<|>
operator, where the firstRight
encountered is taken.Right x <|> Right y == Right x Left x <|> Right y == Right y Left x <|> Left y == Left y
Bind (Either e)
The
Bind
instance allows sequencing ofEither
values and functions that return anEither
by using the>>=
operator:Left x >>= f = Left x Right x >>= f = f x
Either
's "do notation" can be understood to work like this:x :: forall e a. Either e a x = -- y :: forall e b. Either e b y = -- foo :: forall e a. (a -> b -> c) -> Either e c foo f = do x' <- x y' <- y pure (f x' y')
...which is equivalent to...
x >>= (\x' -> y >>= (\y' -> pure (f x' y')))
...and is the same as writing...
foo :: forall e a. (a -> b -> c) -> Either e c foo f = case x of Left e -> Left e Right x -> case y of Left e -> Left e Right y -> Right (f x y)
Monad (Either e)
The
Monad
instance guarantees that there are bothApplicative
andBind
instances forEither
.Extend (Either e)
The
Extend
instance allows sequencing ofEither
values and functions that accept anEither
and return a non-Either
result using the<<=
operator.f <<= Left x = Left x f <<= Right x = Right (f (Right x))
(Show a, Show b) => Show (Either a b)
The
Show
instance allowsEither
values to be rendered as a string withshow
whenever there is anShow
instance for both type theEither
can contain.(Eq a, Eq b) => Eq (Either a b)
The
Eq
instance allowsEither
values to be checked for equality with==
and inequality with/=
whenever there is anEq
instance for both types theEither
can contain.(Eq a) => Eq1 (Either a)
(Ord a, Ord b) => Ord (Either a b)
The
Ord
instance allowsEither
values to be compared withcompare
,>
,>=
,<
and<=
whenever there is anOrd
instance for both types theEither
can contain.Any
Left
value is considered to be less than aRight
value.(Ord a) => Ord1 (Either a)
(Bounded a, Bounded b) => Bounded (Either a b)
(Semigroup b) => Semigroup (Either a b)
#note'
#note
#isRight
#isLeft
#hush
#fromRight'
fromRight' :: forall a b. (Unit -> b) -> Either a b -> b
Similar to fromRight
but for use in cases where the default value may be
expensive to compute. As PureScript is not lazy, the standard fromRight
has to evaluate the default value before returning the result,
whereas here the value is only computed when the Either
is known
to be Left
.
#fromRight
#fromLeft'
fromLeft' :: forall a b. (Unit -> a) -> Either a b -> a
Similar to fromLeft
but for use in cases where the default value may be
expensive to compute. As PureScript is not lazy, the standard fromLeft
has to evaluate the default value before returning the result,
whereas here the value is only computed when the Either
is known
to be Right
.
#fromLeft
#either
either :: forall a b c. (a -> c) -> (b -> c) -> Either a b -> c
Takes two functions and an Either
value, if the value is a Left
the
inner value is applied to the first function, if the value is a Right
the inner value is applied to the second function.
either f g (Left x) == f x
either f g (Right y) == g y
Re-exports from Data.Enum
#Cardinality
newtype Cardinality :: forall k. k -> Type
newtype Cardinality a
A type for the size of finite enumerations.
Constructors
Instances
Newtype (Cardinality a) _
Eq (Cardinality a)
Ord (Cardinality a)
Show (Cardinality a)
#BoundedEnum
class (Bounded a, Enum a) <= BoundedEnum a where
Type class for finite enumerations.
This should not be considered a part of a numeric hierarchy, as in Haskell.
Rather, this is a type class for small, ordered sum types with
statically-determined cardinality and the ability to easily compute
successor and predecessor elements like DayOfWeek
.
Laws:
succ bottom >>= succ >>= succ ... succ [cardinality - 1 times] == top
pred top >>= pred >>= pred ... pred [cardinality - 1 times] == bottom
forall a > bottom: pred a >>= succ == Just a
forall a < top: succ a >>= pred == Just a
forall a > bottom: fromEnum <$> pred a = pred (fromEnum a)
forall a < top: fromEnum <$> succ a = succ (fromEnum a)
e1 `compare` e2 == fromEnum e1 `compare` fromEnum e2
toEnum (fromEnum a) = Just a
Members
cardinality :: Cardinality a
toEnum :: Int -> Maybe a
fromEnum :: a -> Int
Instances
#Enum
class (Ord a) <= Enum a where
Type class for enumerations.
Laws:
- Successor:
all (a < _) (succ a)
- Predecessor:
all (_ < a) (pred a)
- Succ retracts pred:
pred >=> succ >=> pred = pred
- Pred retracts succ:
succ >=> pred >=> succ = succ
- Non-skipping succ:
b <= a || any (_ <= b) (succ a)
- Non-skipping pred:
a <= b || any (b <= _) (pred a)
The retraction laws can intuitively be understood as saying that succ
is
the opposite of pred
; if you apply succ
and then pred
to something,
you should end up with what you started with (although of course this
doesn't apply if you tried to succ
the last value in an enumeration and
therefore got Nothing
out).
The non-skipping laws can intuitively be understood as saying that succ
shouldn't skip over any elements of your type. For example, without the
non-skipping laws, it would be permissible to write an Enum Int
instance
where succ x = Just (x+2)
, and similarly pred x = Just (x-2)
.
Members
Instances
#upFromIncluding
upFromIncluding :: forall a u. Enum a => Unfoldable1 u => a -> u a
Produces all successors of an Enum
value, including the start value.
upFromIncluding bottom
will return all values in an Enum
.
#upFrom
upFrom :: forall a u. Enum a => Unfoldable u => a -> u a
Produces all successors of an Enum
value, excluding the start value.
#toEnumWithDefaults
toEnumWithDefaults :: forall a. BoundedEnum a => a -> a -> Int -> a
Like toEnum
but returns the first argument if x
is less than
fromEnum bottom
and the second argument if x
is greater than
fromEnum top
.
toEnumWithDefaults False True (-1) -- False
toEnumWithDefaults False True 0 -- False
toEnumWithDefaults False True 1 -- True
toEnumWithDefaults False True 2 -- True
#enumFromTo
enumFromTo :: forall a u. Enum a => Unfoldable1 u => a -> a -> u a
Returns a contiguous sequence of elements from the first value to the second value (inclusive).
enumFromTo 0 3 = [0, 1, 2, 3]
enumFromTo 'c' 'a' = ['c', 'b', 'a']
The example shows Array
return values, but the result can be any type
with an Unfoldable1
instance.
#enumFromThenTo
enumFromThenTo :: forall f a. Unfoldable f => Functor f => BoundedEnum a => a -> a -> a -> f a
Returns a sequence of elements from the first value, taking steps according to the difference between the first and second value, up to (but not exceeding) the third value.
enumFromThenTo 0 2 6 = [0, 2, 4, 6]
enumFromThenTo 0 3 5 = [0, 3]
Note that there is no BoundedEnum
instance for integers, they're just
being used here for illustrative purposes to help clarify the behaviour.
The example shows Array
return values, but the result can be any type
with an Unfoldable1
instance.
#downFromIncluding
downFromIncluding :: forall a u. Enum a => Unfoldable1 u => a -> u a
Produces all predecessors of an Enum
value, including the start value.
downFromIncluding top
will return all values in an Enum
, in reverse
order.
#downFrom
downFrom :: forall a u. Enum a => Unfoldable u => a -> u a
Produces all predecessors of an Enum
value, excluding the start value.
#defaultToEnum
defaultToEnum :: forall a. Bounded a => Enum a => Int -> Maybe a
Provides a default implementation for toEnum
.
- Assumes
fromEnum bottom = 0
. - Cannot be used in conjuction with
defaultSucc
.
Runs in O(n)
where n
is fromEnum a
.
#defaultSucc
defaultSucc :: forall a. (Int -> Maybe a) -> (a -> Int) -> a -> Maybe a
Provides a default implementation for succ
, given a function that maps
integers to values in the Enum
, and a function that maps values in the
Enum
back to integers. The integer mapping must agree in both directions
for this to implement a law-abiding succ
.
If a BoundedEnum
instance exists for a
, the toEnum
and fromEnum
functions can be used here:
succ = defaultSucc toEnum fromEnum
#defaultPred
defaultPred :: forall a. (Int -> Maybe a) -> (a -> Int) -> a -> Maybe a
Provides a default implementation for pred
, given a function that maps
integers to values in the Enum
, and a function that maps values in the
Enum
back to integers. The integer mapping must agree in both directions
for this to implement a law-abiding pred
.
If a BoundedEnum
instance exists for a
, the toEnum
and fromEnum
functions can be used here:
pred = defaultPred toEnum fromEnum
#defaultFromEnum
defaultFromEnum :: forall a. Enum a => a -> Int
Provides a default implementation for fromEnum
.
- Assumes
toEnum 0 = Just bottom
. - Cannot be used in conjuction with
defaultPred
.
Runs in O(n)
where n
is fromEnum a
.
#defaultCardinality
defaultCardinality :: forall a. Bounded a => Enum a => Cardinality a
Provides a default implementation for cardinality
.
Runs in O(n)
where n
is fromEnum top
Re-exports from Data.Foldable
#Foldable
class Foldable :: (Type -> Type) -> Constraint
class Foldable f where
Foldable
represents data structures which can be folded.
foldr
folds a structure from the rightfoldl
folds a structure from the leftfoldMap
folds a structure by accumulating values in aMonoid
Default implementations are provided by the following functions:
foldrDefault
foldlDefault
foldMapDefaultR
foldMapDefaultL
Note: some combinations of the default implementations are unsafe to use together - causing a non-terminating mutually recursive cycle. These combinations are documented per function.
Members
foldr :: forall a b. (a -> b -> b) -> b -> f a -> b
foldl :: forall a b. (b -> a -> b) -> b -> f a -> b
foldMap :: forall a m. Monoid m => (a -> m) -> f a -> m
Instances
Foldable Array
Foldable Maybe
Foldable First
Foldable Last
Foldable Additive
Foldable Dual
Foldable Disj
Foldable Conj
Foldable Multiplicative
Foldable (Either a)
Foldable (Tuple a)
Foldable Identity
Foldable (Const a)
(Foldable f, Foldable g) => Foldable (Product f g)
(Foldable f, Foldable g) => Foldable (Coproduct f g)
(Foldable f, Foldable g) => Foldable (Compose f g)
(Foldable f) => Foldable (App f)
#surroundMap
surroundMap :: forall f a m. Foldable f => Semigroup m => m -> (a -> m) -> f a -> m
foldMap
but with each element surrounded by some fixed value.
For example:
> surroundMap "*" show []
= "*"
> surroundMap "*" show [1]
= "*1*"
> surroundMap "*" show [1, 2]
= "*1*2*"
> surroundMap "*" show [1, 2, 3]
= "*1*2*3*"
#surround
#sum
#product
#or
or :: forall a f. Foldable f => HeytingAlgebra a => f a -> a
The disjunction of all the values in a data structure. When specialized
to Boolean
, this function will test whether any of the values in a data
structure is true
.
#oneOfMap
#oneOf
#null
#notElem
#minimumBy
#minimum
#maximumBy
#maximum
#lookup
#length
#intercalate
intercalate :: forall f m. Foldable f => Monoid m => m -> f m -> m
Fold a data structure, accumulating values in some Monoid
,
combining adjacent elements using the specified separator.
For example:
> intercalate ", " ["Lorem", "ipsum", "dolor"]
= "Lorem, ipsum, dolor"
> intercalate "*" ["a", "b", "c"]
= "a*b*c"
> intercalate [1] [[2, 3], [4, 5], [6, 7]]
= [2, 3, 1, 4, 5, 1, 6, 7]
#indexr
#indexl
#foldrDefault
foldrDefault :: forall f a b. Foldable f => (a -> b -> b) -> b -> f a -> b
A default implementation of foldr
using foldMap
.
Note: when defining a Foldable
instance, this function is unsafe to use
in combination with foldMapDefaultR
.
#foldlDefault
foldlDefault :: forall f a b. Foldable f => (b -> a -> b) -> b -> f a -> b
A default implementation of foldl
using foldMap
.
Note: when defining a Foldable
instance, this function is unsafe to use
in combination with foldMapDefaultL
.
#foldMapDefaultR
foldMapDefaultR :: forall f a m. Foldable f => Monoid m => (a -> m) -> f a -> m
A default implementation of foldMap
using foldr
.
Note: when defining a Foldable
instance, this function is unsafe to use
in combination with foldrDefault
.
#foldMapDefaultL
foldMapDefaultL :: forall f a m. Foldable f => Monoid m => (a -> m) -> f a -> m
A default implementation of foldMap
using foldl
.
Note: when defining a Foldable
instance, this function is unsafe to use
in combination with foldlDefault
.
#foldM
#fold
#findMap
#find
#elem
#any
any :: forall a b f. Foldable f => HeytingAlgebra b => (a -> b) -> f a -> b
any f
is the same as or <<< map f
; map a function over the structure,
and then get the disjunction of the results.
#and
and :: forall a f. Foldable f => HeytingAlgebra a => f a -> a
The conjunction of all the values in a data structure. When specialized
to Boolean
, this function will test whether all of the values in a data
structure are true
.
#all
all :: forall a b f. Foldable f => HeytingAlgebra b => (a -> b) -> f a -> b
all f
is the same as and <<< map f
; map a function over the structure,
and then get the conjunction of the results.
Re-exports from Data.Generic.Rep
#Generic
class Generic a rep | a -> rep
The Generic
class asserts the existence of a type function from types
to their representations using the type constructors defined in this module.
Re-exports from Data.Log.Level
Re-exports from Data.Maybe
#Maybe
data Maybe a
The Maybe
type is used to represent optional values and can be seen as
something like a type-safe null
, where Nothing
is null
and Just x
is the non-null value x
.
Constructors
Instances
Functor Maybe
The
Functor
instance allows functions to transform the contents of aJust
with the<$>
operator:f <$> Just x == Just (f x)
Nothing
values are left untouched:f <$> Nothing == Nothing
Apply Maybe
The
Apply
instance allows functions contained within aJust
to transform a value contained within aJust
using theapply
operator:Just f <*> Just x == Just (f x)
Nothing
values are left untouched:Just f <*> Nothing == Nothing Nothing <*> Just x == Nothing
Combining
Functor
's<$>
withApply
's<*>
can be used transform a pure function to takeMaybe
-typed arguments sof :: a -> b -> c
becomesf :: Maybe a -> Maybe b -> Maybe c
:f <$> Just x <*> Just y == Just (f x y)
The
Nothing
-preserving behaviour of both operators means the result of an expression like the above but where any one of the values isNothing
means the whole result becomesNothing
also:f <$> Nothing <*> Just y == Nothing f <$> Just x <*> Nothing == Nothing f <$> Nothing <*> Nothing == Nothing
Applicative Maybe
The
Applicative
instance enables lifting of values intoMaybe
with thepure
function:pure x :: Maybe _ == Just x
Combining
Functor
's<$>
withApply
's<*>
andApplicative
'spure
can be used to pass a mixture ofMaybe
and non-Maybe
typed values to a function that does not usually expect them, by usingpure
for any value that is not alreadyMaybe
typed:f <$> Just x <*> pure y == Just (f x y)
Even though
pure = Just
it is recommended to usepure
in situations like this as it allows the choice ofApplicative
to be changed later without having to go through and replaceJust
with a new constructor.Alt Maybe
The
Alt
instance allows for a choice to be made between twoMaybe
values with the<|>
operator, where the firstJust
encountered is taken.Just x <|> Just y == Just x Nothing <|> Just y == Just y Nothing <|> Nothing == Nothing
Plus Maybe
The
Plus
instance provides a defaultMaybe
value:empty :: Maybe _ == Nothing
Alternative Maybe
The
Alternative
instance guarantees that there are bothApplicative
andPlus
instances forMaybe
.Bind Maybe
The
Bind
instance allows sequencing ofMaybe
values and functions that return aMaybe
by using the>>=
operator:Just x >>= f = f x Nothing >>= f = Nothing
Monad Maybe
The
Monad
instance guarantees that there are bothApplicative
andBind
instances forMaybe
. This also enables thedo
syntactic sugar:do x' <- x y' <- y pure (f x' y')
Which is equivalent to:
x >>= (\x' -> y >>= (\y' -> pure (f x' y')))
Which is equivalent to:
case x of Nothing -> Nothing Just x' -> case y of Nothing -> Nothing Just y' -> Just (f x' y')
Extend Maybe
The
Extend
instance allows sequencing ofMaybe
values and functions that accept aMaybe a
and return a non-Maybe
result using the<<=
operator.f <<= Nothing = Nothing f <<= x = Just (f x)
Invariant Maybe
(Semigroup a) => Semigroup (Maybe a)
The
Semigroup
instance enables use of the operator<>
onMaybe
values whenever there is aSemigroup
instance for the type theMaybe
contains. The exact behaviour of<>
depends on the "inner"Semigroup
instance, but generally captures the notion of appending or combining things.Just x <> Just y = Just (x <> y) Just x <> Nothing = Just x Nothing <> Just y = Just y Nothing <> Nothing = Nothing
(Semigroup a) => Monoid (Maybe a)
(Semiring a) => Semiring (Maybe a)
(Eq a) => Eq (Maybe a)
The
Eq
instance allowsMaybe
values to be checked for equality with==
and inequality with/=
whenever there is anEq
instance for the type theMaybe
contains.Eq1 Maybe
(Ord a) => Ord (Maybe a)
The
Ord
instance allowsMaybe
values to be compared withcompare
,>
,>=
,<
and<=
whenever there is anOrd
instance for the type theMaybe
contains.Nothing
is considered to be less than anyJust
value.Ord1 Maybe
(Bounded a) => Bounded (Maybe a)
(Show a) => Show (Maybe a)
The
Show
instance allowsMaybe
values to be rendered as a string withshow
whenever there is anShow
instance for the type theMaybe
contains.Generic (Maybe a) _
#optional
optional :: forall f a. Alt f => Applicative f => f a -> f (Maybe a)
One or none.
optional empty = pure Nothing
The behaviour of optional (pure x)
depends on whether the Alt
instance
satisfy the left catch law (pure a <|> b = pure a
).
Either e
does:
optional (Right x) = Right (Just x)
But Array
does not:
optional [x] = [Just x, Nothing]
#maybe'
maybe' :: forall a b. (Unit -> b) -> (a -> b) -> Maybe a -> b
Similar to maybe
but for use in cases where the default value may be
expensive to compute. As PureScript is not lazy, the standard maybe
has
to evaluate the default value before returning the result, whereas here
the value is only computed when the Maybe
is known to be Nothing
.
maybe' (\_ -> x) f Nothing == x
maybe' (\_ -> x) f (Just y) == f y
#maybe
maybe :: forall a b. b -> (a -> b) -> Maybe a -> b
Takes a default value, a function, and a Maybe
value. If the Maybe
value is Nothing
the default value is returned, otherwise the function
is applied to the value inside the Just
and the result is returned.
maybe x f Nothing == x
maybe x f (Just y) == f y
#isJust
#fromMaybe'
fromMaybe' :: forall a. (Unit -> a) -> Maybe a -> a
Similar to fromMaybe
but for use in cases where the default value may be
expensive to compute. As PureScript is not lazy, the standard fromMaybe
has to evaluate the default value before returning the result, whereas here
the value is only computed when the Maybe
is known to be Nothing
.
fromMaybe' (\_ -> x) Nothing == x
fromMaybe' (\_ -> x) (Just y) == y
#fromMaybe
#fromJust
Re-exports from Data.Newtype
#Newtype
class (Coercible t a) <= Newtype t a | t -> a
A type class for newtype
s to enable convenient wrapping and unwrapping,
and the use of the other functions in this module.
The compiler can derive instances of Newtype
automatically:
newtype EmailAddress = EmailAddress String
derive instance newtypeEmailAddress :: Newtype EmailAddress _
Note that deriving for Newtype
instances requires that the type be
defined as newtype
rather than data
declaration (even if the data
structurally fits the rules of a newtype
), and the use of a wildcard for
the wrapped type.
Instances
#over
over :: forall t a s b. Newtype t a => Newtype s b => (a -> t) -> (a -> b) -> t -> s
Lifts a function operate over newtypes. This can be used to lift a
function to manipulate the contents of a single newtype, somewhat like
map
does for a Functor
:
newtype Label = Label String
derive instance newtypeLabel :: Newtype Label _
toUpperLabel :: Label -> Label
toUpperLabel = over Label String.toUpper
But the result newtype is polymorphic, meaning the result can be returned as an alternative newtype:
newtype UppercaseLabel = UppercaseLabel String
derive instance newtypeUppercaseLabel :: Newtype UppercaseLabel _
toUpperLabel' :: Label -> UppercaseLabel
toUpperLabel' = over Label String.toUpper
Re-exports from Data.Show.Generic
#genericShow
genericShow :: forall a rep. Generic a rep => GenericShow rep => a -> String
A Generic
implementation of the show
member from the Show
type class.
Re-exports from Data.Traversable
#Traversable
class Traversable :: (Type -> Type) -> Constraint
class (Functor t, Foldable t) <= Traversable t where
Traversable
represents data structures which can be traversed,
accumulating results and effects in some Applicative
functor.
traverse
runs an action for every element in a data structure, and accumulates the results.sequence
runs the actions contained in a data structure, and accumulates the results.
import Data.Traversable
import Data.Maybe
import Data.Int (fromNumber)
sequence [Just 1, Just 2, Just 3] == Just [1,2,3]
sequence [Nothing, Just 2, Just 3] == Nothing
traverse fromNumber [1.0, 2.0, 3.0] == Just [1,2,3]
traverse fromNumber [1.5, 2.0, 3.0] == Nothing
traverse logShow [1,2,3]
-- prints:
1
2
3
traverse (\x -> [x, 0]) [1,2,3] == [[1,2,3],[1,2,0],[1,0,3],[1,0,0],[0,2,3],[0,2,0],[0,0,3],[0,0,0]]
The traverse
and sequence
functions should be compatible in the
following sense:
traverse f xs = sequence (f <$> xs)
sequence = traverse identity
Traversable
instances should also be compatible with the corresponding
Foldable
instances, in the following sense:
foldMap f = runConst <<< traverse (Const <<< f)
Default implementations are provided by the following functions:
traverseDefault
sequenceDefault
Members
traverse :: forall a b m. Applicative m => (a -> m b) -> t a -> m (t b)
sequence :: forall a m. Applicative m => t (m a) -> m (t a)
Instances
Traversable Array
Traversable Maybe
Traversable First
Traversable Last
Traversable Additive
Traversable Dual
Traversable Conj
Traversable Disj
Traversable Multiplicative
Traversable (Either a)
Traversable (Tuple a)
Traversable Identity
Traversable (Const a)
(Traversable f, Traversable g) => Traversable (Product f g)
(Traversable f, Traversable g) => Traversable (Coproduct f g)
(Traversable f, Traversable g) => Traversable (Compose f g)
(Traversable f) => Traversable (App f)
#traverse_
traverse_ :: forall a b f m. Applicative m => Foldable f => (a -> m b) -> f a -> m Unit
Traverse a data structure, performing some effects encoded by an
Applicative
functor at each value, ignoring the final result.
For example:
traverse_ print [1, 2, 3]
#traverseDefault
traverseDefault :: forall t a b m. Traversable t => Applicative m => (a -> m b) -> t a -> m (t b)
A default implementation of traverse
using sequence
and map
.
#sequence_
sequence_ :: forall a f m. Applicative m => Foldable f => f (m a) -> m Unit
Perform all of the effects in some data structure in the order
given by the Foldable
instance, ignoring the final result.
For example:
sequence_ [ trace "Hello, ", trace " world!" ]
#sequenceDefault
sequenceDefault :: forall t a m. Traversable t => Applicative m => t (m a) -> m (t a)
A default implementation of sequence
using traverse
.
#scanr
scanr :: forall a b f. Traversable f => (a -> b -> b) -> b -> f a -> f b
Fold a data structure from the right, keeping all intermediate results
instead of only the final result. Note that the initial value does not
appear in the result (unlike Haskell's Prelude.scanr
).
scanr (+) 0 [1,2,3] = [6,5,3]
scanr (flip (-)) 10 [1,2,3] = [4,5,7]
#scanl
scanl :: forall a b f. Traversable f => (b -> a -> b) -> b -> f a -> f b
Fold a data structure from the left, keeping all intermediate results
instead of only the final result. Note that the initial value does not
appear in the result (unlike Haskell's Prelude.scanl
).
scanl (+) 0 [1,2,3] = [1,3,6]
scanl (-) 10 [1,2,3] = [9,7,4]
#mapAccumR
mapAccumR :: forall a b s f. Traversable f => (s -> a -> Accum s b) -> s -> f a -> Accum s (f b)
Fold a data structure from the right, keeping all intermediate results instead of only the final result.
Unlike scanr
, mapAccumR
allows the type of accumulator to differ
from the element type of the final data structure.
#mapAccumL
mapAccumL :: forall a b s f. Traversable f => (s -> a -> Accum s b) -> s -> f a -> Accum s (f b)
Fold a data structure from the left, keeping all intermediate results instead of only the final result.
Unlike scanl
, mapAccumL
allows the type of accumulator to differ
from the element type of the final data structure.
#for_
for_ :: forall a b f m. Applicative m => Foldable f => f a -> (a -> m b) -> m Unit
A version of traverse_
with its arguments flipped.
This can be useful when running an action written using do notation for every element in a data structure:
For example:
for_ [1, 2, 3] \n -> do
print n
trace "squared is"
print (n * n)
#for
for :: forall a b m t. Applicative m => Traversable t => t a -> (a -> m b) -> m (t b)
A version of traverse
with its arguments flipped.
This can be useful when running an action written using do notation for every element in a data structure:
For example:
for [1, 2, 3] \n -> do
print n
return (n * n)
Re-exports from Data.Tuple
#Tuple
data Tuple a b
A simple product type for wrapping a pair of component values.
Constructors
Tuple a b
Instances
(Show a, Show b) => Show (Tuple a b)
Allows
Tuple
s to be rendered as a string withshow
whenever there areShow
instances for both component types.(Eq a, Eq b) => Eq (Tuple a b)
Allows
Tuple
s to be checked for equality with==
and/=
whenever there areEq
instances for both component types.(Eq a) => Eq1 (Tuple a)
(Ord a, Ord b) => Ord (Tuple a b)
Allows
Tuple
s to be compared withcompare
,>
,>=
,<
and<=
whenever there areOrd
instances for both component types. To obtain the result, thefst
s arecompare
d, and if they areEQ
ual, thesnd
s arecompare
d.(Ord a) => Ord1 (Tuple a)
(Bounded a, Bounded b) => Bounded (Tuple a b)
Semigroupoid Tuple
(Semigroup a, Semigroup b) => Semigroup (Tuple a b)
The
Semigroup
instance enables use of the associative operator<>
onTuple
s whenever there areSemigroup
instances for the component types. The<>
operator is applied pairwise, so:(Tuple a1 b1) <> (Tuple a2 b2) = Tuple (a1 <> a2) (b1 <> b2)
(Monoid a, Monoid b) => Monoid (Tuple a b)
(Semiring a, Semiring b) => Semiring (Tuple a b)
(Ring a, Ring b) => Ring (Tuple a b)
(CommutativeRing a, CommutativeRing b) => CommutativeRing (Tuple a b)
(HeytingAlgebra a, HeytingAlgebra b) => HeytingAlgebra (Tuple a b)
(BooleanAlgebra a, BooleanAlgebra b) => BooleanAlgebra (Tuple a b)
Functor (Tuple a)
The
Functor
instance allows functions to transform the contents of aTuple
with the<$>
operator, applying the function to the second component, so:f <$> (Tuple x y) = Tuple x (f y)
Generic (Tuple a b) _
Invariant (Tuple a)
(Semigroup a) => Apply (Tuple a)
The
Apply
instance allows functions to transform the contents of aTuple
with the<*>
operator whenever there is aSemigroup
instance for thefst
component, so:(Tuple a1 f) <*> (Tuple a2 x) == Tuple (a1 <> a2) (f x)
(Monoid a) => Applicative (Tuple a)
(Semigroup a) => Bind (Tuple a)
(Monoid a) => Monad (Tuple a)
Extend (Tuple a)
Comonad (Tuple a)
(Lazy a, Lazy b) => Lazy (Tuple a b)
#uncurry
#swap
#curry
Re-exports from Data.Tuple.Nested
#uncurry9
#uncurry8
#uncurry7
#uncurry6
#uncurry5
#uncurry4
#uncurry3
#uncurry2
#uncurry10
#uncurry1
#tuple9
#tuple8
#tuple7
#tuple6
#tuple5
#tuple4
#tuple3
#tuple10
#over9
#over8
#over7
#over6
#over5
#over4
#over3
#over2
#over10
#over1
#get9
#get8
#get7
#get6
#get5
#get10
#curry9
#curry8
#curry7
#curry6
#curry5
#curry4
#curry3
#curry2
#curry10
#curry1
#(/\)
Operator alias for Data.Tuple.Tuple (right-associative / precedence 6)
Shorthand for constructing n-tuples as nested pairs.
a /\ b /\ c /\ d /\ unit
becomes Tuple a (Tuple b (Tuple c (Tuple d unit)))
#type (/\)
Operator alias for Data.Tuple.Tuple (right-associative / precedence 6)
Shorthand for constructing n-tuple types as nested pairs.
forall a b c d. a /\ b /\ c /\ d /\ Unit
becomes
forall a b c d. Tuple a (Tuple b (Tuple c (Tuple d Unit)))
Re-exports from Effect
#Effect
data Effect t0
A native effect. The type parameter denotes the return type of running the
effect, that is, an Effect Int
is a possibly-effectful computation which
eventually produces a value of the type Int
when it finishes.
Instances
Functor Effect
Apply Effect
Applicative Effect
Bind Effect
Monad Effect
(Semigroup a) => Semigroup (Effect a)
The
Semigroup
instance for effects allows you to run two effects, one after the other, and then combine their results using the result type'sSemigroup
instance.(Monoid a) => Monoid (Effect a)
If you have a
Monoid a
instance, thenmempty :: Effect a
is defined aspure mempty
.
Re-exports from Effect.Aff
#Aff
data Aff t0
An Aff a
is an asynchronous computation with effects. The
computation may either error with an exception, or produce a result of
type a
. Aff
effects are assembled from primitive Effect
effects using
makeAff
or liftEffect
.
Instances
Functor Aff
Apply Aff
Applicative Aff
Bind Aff
Monad Aff
(Semigroup a) => Semigroup (Aff a)
(Monoid a) => Monoid (Aff a)
Alt Aff
Plus Aff
MonadRec Aff
This instance is provided for compatibility.
Aff
is always stack-safe within a given fiber. This instance will just result in unnecessary bind overhead.MonadThrow Error Aff
MonadError Error Aff
MonadEffect Aff
Lazy (Aff a)
MonadST Global Aff
Parallel ParAff Aff
Re-exports from Effect.Aff.Class
Re-exports from Effect.Class
#liftEffect
liftEffect :: forall m a. MonadEffect m => Effect a -> m a
Re-exports from Effect.Class.Console
#log
log :: forall m. MonadEffect m => String -> m Unit
Re-exports from Prelude
#Void
newtype Void
An uninhabited data type. In other words, one can never create
a runtime value of type Void
because no such value exists.
Void
is useful to eliminate the possibility of a value being created.
For example, a value of type Either Void Boolean
can never have
a Left value created in PureScript.
This should not be confused with the keyword void
that commonly appears in
C-family languages, such as Java:
public class Foo {
void doSomething() { System.out.println("hello world!"); }
}
In PureScript, one often uses Unit
to achieve similar effects as
the void
of C-family languages above.
#Unit
data Unit
The Unit
type has a single inhabitant, called unit
. It represents
values with no computational content.
Unit
is often used, wrapped in a monadic type constructor, as the
return type of a computation where only the effects are important.
When returning a value of type Unit
from an FFI function, it is
recommended to use undefined
, or not return a value at all.
#Ordering
data Ordering
The Ordering
data type represents the three possible outcomes of
comparing two values:
LT
- The first value is less than the second.
GT
- The first value is greater than the second.
EQ
- The first value is equal to the second.
Constructors
Instances
#Applicative
class Applicative :: (Type -> Type) -> Constraint
class (Apply f) <= Applicative f where
The Applicative
type class extends the Apply
type class
with a pure
function, which can be used to create values of type f a
from values of type a
.
Where Apply
provides the ability to lift functions of two or
more arguments to functions whose arguments are wrapped using f
, and
Functor
provides the ability to lift functions of one
argument, pure
can be seen as the function which lifts functions of
zero arguments. That is, Applicative
functors support a lifting
operation for any number of function arguments.
Instances must satisfy the following laws in addition to the Apply
laws:
- Identity:
(pure identity) <*> v = v
- Composition:
pure (<<<) <*> f <*> g <*> h = f <*> (g <*> h)
- Homomorphism:
(pure f) <*> (pure x) = pure (f x)
- Interchange:
u <*> (pure y) = (pure (_ $ y)) <*> u
Members
pure :: forall a. a -> f a
Instances
#Apply
class Apply :: (Type -> Type) -> Constraint
class (Functor f) <= Apply f where
The Apply
class provides the (<*>)
which is used to apply a function
to an argument under a type constructor.
Apply
can be used to lift functions of two or more arguments to work on
values wrapped with the type constructor f
. It might also be understood
in terms of the lift2
function:
lift2 :: forall f a b c. Apply f => (a -> b -> c) -> f a -> f b -> f c
lift2 f a b = f <$> a <*> b
(<*>)
is recovered from lift2
as lift2 ($)
. That is, (<*>)
lifts
the function application operator ($)
to arguments wrapped with the
type constructor f
.
Put differently...
foo =
functionTakingNArguments <$> computationProducingArg1
<*> computationProducingArg2
<*> ...
<*> computationProducingArgN
Instances must satisfy the following law in addition to the Functor
laws:
- Associative composition:
(<<<) <$> f <*> g <*> h = f <*> (g <*> h)
Formally, Apply
represents a strong lax semi-monoidal endofunctor.
Members
apply :: forall a b. f (a -> b) -> f a -> f b
Instances
#Bind
class Bind :: (Type -> Type) -> Constraint
class (Apply m) <= Bind m where
The Bind
type class extends the Apply
type class with a
"bind" operation (>>=)
which composes computations in sequence, using
the return value of one computation to determine the next computation.
The >>=
operator can also be expressed using do
notation, as follows:
x >>= f = do y <- x
f y
where the function argument of f
is given the name y
.
Instances must satisfy the following laws in addition to the Apply
laws:
- Associativity:
(x >>= f) >>= g = x >>= (\k -> f k >>= g)
- Apply Superclass:
apply f x = f >>= \f’ -> map f’ x
Associativity tells us that we can regroup operations which use do
notation so that we can unambiguously write, for example:
do x <- m1
y <- m2 x
m3 x y
Members
bind :: forall a b. m a -> (a -> m b) -> m b
Instances
Bind (Function r)
Bind Array
The
bind
/>>=
function forArray
works by applying a function to each element in the array, and flattening the results into a single, new array.Array's
bind
/>>=
works like a nested for loop. Eachbind
adds another level of nesting in the loop. For example:foo :: Array String foo = ["a", "b"] >>= \eachElementInArray1 -> ["c", "d"] >>= \eachElementInArray2 pure (eachElementInArray1 <> eachElementInArray2) -- In other words... foo -- ... is the same as... [ ("a" <> "c"), ("a" <> "d"), ("b" <> "c"), ("b" <> "d") ] -- which simplifies to... [ "ac", "ad", "bc", "bd" ]
Bind Proxy
#BooleanAlgebra
class (HeytingAlgebra a) <= BooleanAlgebra a
The BooleanAlgebra
type class represents types that behave like boolean
values.
Instances should satisfy the following laws in addition to the
HeytingAlgebra
law:
- Excluded middle:
a || not a = tt
Instances
BooleanAlgebra Boolean
BooleanAlgebra Unit
(BooleanAlgebra b) => BooleanAlgebra (a -> b)
(RowToList row list, BooleanAlgebraRecord list row row) => BooleanAlgebra (Record row)
BooleanAlgebra (Proxy a)
#Bounded
class (Ord a) <= Bounded a where
The Bounded
type class represents totally ordered types that have an
upper and lower boundary.
Instances should satisfy the following law in addition to the Ord
laws:
- Bounded:
bottom <= a <= top
Members
Instances
Bounded Boolean
Bounded Int
The
Bounded
Int
instance hastop :: Int
equal to 2^31 - 1, andbottom :: Int
equal to -2^31, since these are the largest and smallest integers representable by twos-complement 32-bit integers, respectively.Bounded Char
Characters fall within the Unicode range.
Bounded Ordering
Bounded Unit
Bounded Number
Bounded (Proxy a)
(RowToList row list, BoundedRecord list row row) => Bounded (Record row)
#Category
class Category :: forall k. (k -> k -> Type) -> Constraint
class (Semigroupoid a) <= Category a where
Category
s consist of objects and composable morphisms between them, and
as such are Semigroupoids
, but unlike semigroupoids
must have an identity element.
Instances must satisfy the following law in addition to the
Semigroupoid
law:
- Identity:
identity <<< p = p <<< identity = p
Members
identity :: forall t. a t t
Instances
#CommutativeRing
class (Ring a) <= CommutativeRing a
The CommutativeRing
class is for rings where multiplication is
commutative.
Instances must satisfy the following law in addition to the Ring
laws:
- Commutative multiplication:
a * b = b * a
Instances
CommutativeRing Int
CommutativeRing Number
CommutativeRing Unit
(CommutativeRing b) => CommutativeRing (a -> b)
(RowToList row list, CommutativeRingRecord list row row) => CommutativeRing (Record row)
CommutativeRing (Proxy a)
#Discard
#DivisionRing
class (Ring a) <= DivisionRing a where
The DivisionRing
class is for non-zero rings in which every non-zero
element has a multiplicative inverse. Division rings are sometimes also
called skew fields.
Instances must satisfy the following laws in addition to the Ring
laws:
- Non-zero ring:
one /= zero
- Non-zero multiplicative inverse:
recip a * a = a * recip a = one
for all non-zeroa
The result of recip zero
is left undefined; individual instances may
choose how to handle this case.
If a type has both DivisionRing
and CommutativeRing
instances, then
it is a field and should have a Field
instance.
Members
recip :: a -> a
Instances
#Eq
class Eq a where
The Eq
type class represents types which support decidable equality.
Eq
instances should satisfy the following laws:
- Reflexivity:
x == x = true
- Symmetry:
x == y = y == x
- Transitivity: if
x == y
andy == z
thenx == z
Note: The Number
type is not an entirely law abiding member of this
class due to the presence of NaN
, since NaN /= NaN
. Additionally,
computing with Number
can result in a loss of precision, so sometimes
values that should be equivalent are not.
Members
Instances
#EuclideanRing
class (CommutativeRing a) <= EuclideanRing a where
The EuclideanRing
class is for commutative rings that support division.
The mathematical structure this class is based on is sometimes also called
a Euclidean domain.
Instances must satisfy the following laws in addition to the Ring
laws:
- Integral domain:
one /= zero
, and ifa
andb
are both nonzero then so is their producta * b
- Euclidean function
degree
:- Nonnegativity: For all nonzero
a
,degree a >= 0
- Quotient/remainder: For all
a
andb
, whereb
is nonzero, letq = a / b
andr = a `mod` b
; thena = q*b + r
, and also eitherr = zero
ordegree r < degree b
- Nonnegativity: For all nonzero
- Submultiplicative euclidean function:
- For all nonzero
a
andb
,degree a <= degree (a * b)
- For all nonzero
The behaviour of division by zero
is unconstrained by these laws,
meaning that individual instances are free to choose how to behave in this
case. Similarly, there are no restrictions on what the result of
degree zero
is; it doesn't make sense to ask for degree zero
in the
same way that it doesn't make sense to divide by zero
, so again,
individual instances may choose how to handle this case.
For any EuclideanRing
which is also a Field
, one valid choice
for degree
is simply const 1
. In fact, unless there's a specific
reason not to, Field
types should normally use this definition of
degree
.
The EuclideanRing Int
instance is one of the most commonly used
EuclideanRing
instances and deserves a little more discussion. In
particular, there are a few different sensible law-abiding implementations
to choose from, with slightly different behaviour in the presence of
negative dividends or divisors. The most common definitions are "truncating"
division, where the result of a / b
is rounded towards 0, and "Knuthian"
or "flooring" division, where the result of a / b
is rounded towards
negative infinity. A slightly less common, but arguably more useful, option
is "Euclidean" division, which is defined so as to ensure that a `mod` b
is always nonnegative. With Euclidean division, a / b
rounds towards
negative infinity if the divisor is positive, and towards positive infinity
if the divisor is negative. Note that all three definitions are identical if
we restrict our attention to nonnegative dividends and divisors.
In versions 1.x, 2.x, and 3.x of the Prelude, the EuclideanRing Int
instance used truncating division. As of 4.x, the EuclideanRing Int
instance uses Euclidean division. Additional functions quot
and rem
are
supplied if truncating division is desired.
Members
Instances
#Field
class (EuclideanRing a, DivisionRing a) <= Field a
The Field
class is for types that are (commutative) fields.
Mathematically, a field is a ring which is commutative and in which every
nonzero element has a multiplicative inverse; these conditions correspond
to the CommutativeRing
and DivisionRing
classes in PureScript
respectively. However, the Field
class has EuclideanRing
and
DivisionRing
as superclasses, which seems like a stronger requirement
(since CommutativeRing
is a superclass of EuclideanRing
). In fact, it
is not stronger, since any type which has law-abiding CommutativeRing
and DivisionRing
instances permits exactly one law-abiding
EuclideanRing
instance. We use a EuclideanRing
superclass here in
order to ensure that a Field
constraint on a function permits you to use
div
on that type, since div
is a member of EuclideanRing
.
This class has no laws or members of its own; it exists as a convenience, so a single constraint can be used when field-like behaviour is expected.
This module also defines a single Field
instance for any type which has
both EuclideanRing
and DivisionRing
instances. Any other instance
would overlap with this instance, so no other Field
instances should be
defined in libraries. Instead, simply define EuclideanRing
and
DivisionRing
instances, and this will permit your type to be used with a
Field
constraint.
Instances
(EuclideanRing a, DivisionRing a) => Field a
#Functor
class Functor :: (Type -> Type) -> Constraint
class Functor f where
A Functor
is a type constructor which supports a mapping operation
map
.
map
can be used to turn functions a -> b
into functions
f a -> f b
whose argument and return types use the type constructor f
to represent some computational context.
Instances must satisfy the following laws:
- Identity:
map identity = identity
- Composition:
map (f <<< g) = map f <<< map g
Members
map :: forall a b. (a -> b) -> f a -> f b
Instances
#HeytingAlgebra
class HeytingAlgebra a where
The HeytingAlgebra
type class represents types that are bounded lattices with
an implication operator such that the following laws hold:
- Associativity:
a || (b || c) = (a || b) || c
a && (b && c) = (a && b) && c
- Commutativity:
a || b = b || a
a && b = b && a
- Absorption:
a || (a && b) = a
a && (a || b) = a
- Idempotent:
a || a = a
a && a = a
- Identity:
a || ff = a
a && tt = a
- Implication:
a `implies` a = tt
a && (a `implies` b) = a && b
b && (a `implies` b) = b
a `implies` (b && c) = (a `implies` b) && (a `implies` c)
- Complemented:
not a = a `implies` ff
Members
Instances
HeytingAlgebra Boolean
HeytingAlgebra Unit
(HeytingAlgebra b) => HeytingAlgebra (a -> b)
HeytingAlgebra (Proxy a)
(RowToList row list, HeytingAlgebraRecord list row row) => HeytingAlgebra (Record row)
#Monad
class Monad :: (Type -> Type) -> Constraint
class (Applicative m, Bind m) <= Monad m
The Monad
type class combines the operations of the Bind
and
Applicative
type classes. Therefore, Monad
instances represent type
constructors which support sequential composition, and also lifting of
functions of arbitrary arity.
Instances must satisfy the following laws in addition to the
Applicative
and Bind
laws:
- Left Identity:
pure x >>= f = f x
- Right Identity:
x >>= pure = x
Instances
#Monoid
class (Semigroup m) <= Monoid m where
A Monoid
is a Semigroup
with a value mempty
, which is both a
left and right unit for the associative operation <>
:
- Left unit:
(mempty <> x) = x
- Right unit:
(x <> mempty) = x
Monoid
s are commonly used as the result of fold operations, where
<>
is used to combine individual results, and mempty
gives the result
of folding an empty collection of elements.
Newtypes for Monoid
Some types (e.g. Int
, Boolean
) can implement multiple law-abiding
instances for Monoid
. Let's use Int
as an example
<>
could be+
andmempty
could be0
<>
could be*
andmempty
could be1
.
To clarify these ambiguous situations, one should use the newtypes
defined in Data.Monoid.<NewtypeName>
modules.
In the above ambiguous situation, we could use Additive
for the first situation or Multiplicative
for the second one.
Members
mempty :: m
Instances
#Ord
class (Eq a) <= Ord a where
The Ord
type class represents types which support comparisons with a
total order.
Ord
instances should satisfy the laws of total orderings:
- Reflexivity:
a <= a
- Antisymmetry: if
a <= b
andb <= a
thena == b
- Transitivity: if
a <= b
andb <= c
thena <= c
Note: The Number
type is not an entirely law abiding member of this
class due to the presence of NaN
, since NaN <= NaN
evaluates to false
Members
Instances
#Ring
class (Semiring a) <= Ring a where
The Ring
class is for types that support addition, multiplication,
and subtraction operations.
Instances must satisfy the following laws in addition to the Semiring
laws:
- Additive inverse:
a - a = zero
- Compatibility of
sub
andnegate
:a - b = a + (zero - b)
Members
sub :: a -> a -> a
Instances
#Semigroup
class Semigroup a where
The Semigroup
type class identifies an associative operation on a type.
Instances are required to satisfy the following law:
- Associativity:
(x <> y) <> z = x <> (y <> z)
One example of a Semigroup
is String
, with (<>)
defined as string
concatenation. Another example is List a
, with (<>)
defined as
list concatenation.
Newtypes for Semigroup
There are two other ways to implement an instance for this type class regardless of which type is used. These instances can be used by wrapping the values in one of the two newtypes below:
First
- Use the first argument every time:append first _ = first
.Last
- Use the last argument every time:append _ last = last
.
Members
append :: a -> a -> a
Instances
#Semigroupoid
class Semigroupoid :: forall k. (k -> k -> Type) -> Constraint
class Semigroupoid a where
A Semigroupoid
is similar to a Category
but does not
require an identity element identity
, just composable morphisms.
Semigroupoid
s must satisfy the following law:
- Associativity:
p <<< (q <<< r) = (p <<< q) <<< r
One example of a Semigroupoid
is the function type constructor (->)
,
with (<<<)
defined as function composition.
Members
compose :: forall b c d. a c d -> a b c -> a b d
Instances
#Semiring
class Semiring a where
The Semiring
class is for types that support an addition and
multiplication operation.
Instances must satisfy the following laws:
- Commutative monoid under addition:
- Associativity:
(a + b) + c = a + (b + c)
- Identity:
zero + a = a + zero = a
- Commutative:
a + b = b + a
- Associativity:
- Monoid under multiplication:
- Associativity:
(a * b) * c = a * (b * c)
- Identity:
one * a = a * one = a
- Associativity:
- Multiplication distributes over addition:
- Left distributivity:
a * (b + c) = (a * b) + (a * c)
- Right distributivity:
(a + b) * c = (a * c) + (b * c)
- Left distributivity:
- Annihilation:
zero * a = a * zero = zero
Note: The Number
and Int
types are not fully law abiding
members of this class hierarchy due to the potential for arithmetic
overflows, and in the case of Number
, the presence of NaN
and
Infinity
values. The behaviour is unspecified in these cases.
Members
Instances
#Show
class Show a where
The Show
type class represents those types which can be converted into
a human-readable String
representation.
While not required, it is recommended that for any expression x
, the
string show x
be executable PureScript code which evaluates to the same
value as the expression x
.
Members
Instances
#whenM
#when
when :: forall m. Applicative m => Boolean -> m Unit -> m Unit
Perform an applicative action when a condition is true.
#void
void :: forall f a. Functor f => f a -> f Unit
The void
function is used to ignore the type wrapped by a
Functor
, replacing it with Unit
and keeping only the type
information provided by the type constructor itself.
void
is often useful when using do
notation to change the return type
of a monadic computation:
main = forE 1 10 \n -> void do
print n
print (n * n)
#unlessM
#unless
unless :: forall m. Applicative m => Boolean -> m Unit -> m Unit
Perform an applicative action unless a condition is true.
#otherwise
#notEq
#min
#max
#liftM1
liftM1 :: forall m a b. Monad m => (a -> b) -> m a -> m b
liftM1
provides a default implementation of (<$>)
for any
Monad
, without using (<$>)
as provided by the
Functor
-Monad
superclass relationship.
liftM1
can therefore be used to write Functor
instances
as follows:
instance functorF :: Functor F where
map = liftM1
#liftA1
liftA1 :: forall f a b. Applicative f => (a -> b) -> f a -> f b
liftA1
provides a default implementation of (<$>)
for any
Applicative
functor, without using (<$>)
as provided
by the Functor
-Applicative
superclass
relationship.
liftA1
can therefore be used to write Functor
instances
as follows:
instance functorF :: Functor F where
map = liftA1
#lcm
lcm :: forall a. Eq a => EuclideanRing a => a -> a -> a
The least common multiple of two values.
#join
#ifM
#gcd
gcd :: forall a. Eq a => EuclideanRing a => a -> a -> a
The greatest common divisor of two values.
#flip
flip :: forall a b c. (a -> b -> c) -> b -> a -> c
Given a function that takes two arguments, applies the arguments to the function in a swapped order.
flip append "1" "2" == append "2" "1" == "21"
const 1 "two" == 1
flip const 1 "two" == const "two" 1 == "two"
#flap
flap :: forall f a b. Functor f => f (a -> b) -> a -> f b
Apply a value in a computational context to a value in no context.
Generalizes flip
.
longEnough :: String -> Bool
hasSymbol :: String -> Bool
hasDigit :: String -> Bool
password :: String
validate :: String -> Array Bool
validate = flap [longEnough, hasSymbol, hasDigit]
flap (-) 3 4 == 1
threeve <$> Just 1 <@> 'a' <*> Just true == Just (threeve 1 'a' true)
#const
const :: forall a b. a -> b -> a
Returns its first argument and ignores its second.
const 1 "hello" = 1
It can also be thought of as creating a function that ignores its argument:
const 1 = \_ -> 1
#comparing
#clamp
#between
#ap
#absurd
#(||)
Operator alias for Data.HeytingAlgebra.disj (right-associative / precedence 2)
#(>>>)
Operator alias for Control.Semigroupoid.composeFlipped (right-associative / precedence 9)
#(>>=)
Operator alias for Control.Bind.bind (left-associative / precedence 1)
#(>=>)
Operator alias for Control.Bind.composeKleisli (right-associative / precedence 1)
#(>=)
Operator alias for Data.Ord.greaterThanOrEq (left-associative / precedence 4)
#(>)
Operator alias for Data.Ord.greaterThan (left-associative / precedence 4)
#(==)
Operator alias for Data.Eq.eq (non-associative / precedence 4)
#(=<<)
Operator alias for Control.Bind.bindFlipped (right-associative / precedence 1)
#(<@>)
Operator alias for Data.Functor.flap (left-associative / precedence 4)
#(<>)
Operator alias for Data.Semigroup.append (right-associative / precedence 5)
#(<=<)
Operator alias for Control.Bind.composeKleisliFlipped (right-associative / precedence 1)
#(<=)
Operator alias for Data.Ord.lessThanOrEq (left-associative / precedence 4)
#(<<<)
Operator alias for Control.Semigroupoid.compose (right-associative / precedence 9)
#(<*>)
Operator alias for Control.Apply.apply (left-associative / precedence 4)
#(<*)
Operator alias for Control.Apply.applyFirst (left-associative / precedence 4)
#(<$>)
Operator alias for Data.Functor.map (left-associative / precedence 4)
#(<$)
Operator alias for Data.Functor.voidRight (left-associative / precedence 4)
#(<#>)
Operator alias for Data.Functor.mapFlipped (left-associative / precedence 1)
#(<)
Operator alias for Data.Ord.lessThan (left-associative / precedence 4)
#(/=)
Operator alias for Data.Eq.notEq (non-associative / precedence 4)
#(/)
Operator alias for Data.EuclideanRing.div (left-associative / precedence 7)
#(-)
Operator alias for Data.Ring.sub (left-associative / precedence 6)
#(+)
Operator alias for Data.Semiring.add (left-associative / precedence 6)
#(*>)
Operator alias for Control.Apply.applySecond (left-associative / precedence 4)
#(*)
Operator alias for Data.Semiring.mul (left-associative / precedence 7)
#(&&)
Operator alias for Data.HeytingAlgebra.conj (right-associative / precedence 3)
#($>)
Operator alias for Data.Functor.voidLeft (left-associative / precedence 4)
#($)
Operator alias for Data.Function.apply (right-associative / precedence 0)
Applies a function to an argument: the reverse of (#)
.
length $ groupBy productCategory $ filter isInStock $ products
is equivalent to:
length (groupBy productCategory (filter isInStock products))
Or another alternative equivalent, applying chain of composed functions to a value:
length <<< groupBy productCategory <<< filter isInStock $ products
#(#)
Operator alias for Data.Function.applyFlipped (left-associative / precedence 1)
Applies an argument to a function: the reverse of ($)
.
products # filter isInStock # groupBy productCategory # length
is equivalent to:
length (groupBy productCategory (filter isInStock products))
Or another alternative equivalent, applying a value to a chain of composed functions:
products # filter isInStock >>> groupBy productCategory >>> length
#type (~>)
Operator alias for Data.NaturalTransformation.NaturalTransformation (right-associative / precedence 4)
Modules
- Aeson
- Affjax
- Affjax.RequestBody
- Affjax.RequestHeader
- Affjax.ResponseFormat
- Affjax.ResponseHeader
- Affjax.StatusCode
- Ansi.Codes
- Ansi.Output
- Cardano.AsCbor
- Cardano.Collateral.FakeOutput
- Cardano.Collateral.Select
- Cardano.Collateral.UtxoMinAda
- Cardano.FromData
- Cardano.FromMetadata
- Cardano.MessageSigning
- Cardano.Plutus.ApplyArgs
- Cardano.Plutus.DataSchema
- Cardano.Plutus.DataSchema.Indexed
- Cardano.Plutus.DataSchema.Nat
- Cardano.Plutus.DataSchema.RowList
- Cardano.Plutus.Types.Address
- Cardano.Plutus.Types.Credential
- Cardano.Plutus.Types.CurrencySymbol
- Cardano.Plutus.Types.Map
- Cardano.Plutus.Types.MintingPolicyHash
- Cardano.Plutus.Types.OutputDatum
- Cardano.Plutus.Types.PaymentPubKeyHash
- Cardano.Plutus.Types.PubKeyHash
- Cardano.Plutus.Types.StakePubKeyHash
- Cardano.Plutus.Types.StakingCredential
- Cardano.Plutus.Types.TokenName
- Cardano.Plutus.Types.TransactionOutput
- Cardano.Plutus.Types.TransactionOutputWithRefScript
- Cardano.Plutus.Types.TransactionUnspentOutput
- Cardano.Plutus.Types.UtxoMap
- Cardano.Plutus.Types.Validator
- Cardano.Plutus.Types.ValidatorHash
- Cardano.Plutus.Types.Value
- Cardano.Serialization.Lib
- Cardano.Serialization.Lib.Internal
- Cardano.ToData
- Cardano.ToMetadata
- Cardano.Transaction.Builder
- Cardano.Transaction.Edit
- Cardano.Types
- Cardano.Types.Address
- Cardano.Types.Anchor
- Cardano.Types.AnchorDataHash
- Cardano.Types.Asset
- Cardano.Types.AssetClass
- Cardano.Types.AssetName
- Cardano.Types.AuxiliaryData
- Cardano.Types.AuxiliaryDataHash
- Cardano.Types.Base58String
- Cardano.Types.BaseAddress
- Cardano.Types.Bech32String
- Cardano.Types.BigInt
- Cardano.Types.BigNum
- Cardano.Types.BootstrapWitness
- Cardano.Types.ByronAddress
- Cardano.Types.CborBytes
- Cardano.Types.Certificate
- Cardano.Types.Coin
- Cardano.Types.Committee
- Cardano.Types.Constitution
- Cardano.Types.CostModel
- Cardano.Types.Credential
- Cardano.Types.DRep
- Cardano.Types.DRepVotingThresholds
- Cardano.Types.DataHash
- Cardano.Types.Ed25519KeyHash
- Cardano.Types.Ed25519Signature
- Cardano.Types.EnterpriseAddress
- Cardano.Types.Epoch
- Cardano.Types.ExUnitPrices
- Cardano.Types.ExUnits
- Cardano.Types.GeneralTransactionMetadata
- Cardano.Types.GenesisHash
- Cardano.Types.GovernanceAction
- Cardano.Types.GovernanceActionId
- Cardano.Types.HardForkInitiationAction
- Cardano.Types.Int
- Cardano.Types.Internal.Helpers
- Cardano.Types.Ipv4
- Cardano.Types.Ipv6
- Cardano.Types.Language
- Cardano.Types.Mint
- Cardano.Types.MultiAsset
- Cardano.Types.NativeScript
- Cardano.Types.NetworkId
- Cardano.Types.NewConstitutionAction
- Cardano.Types.NoConfidenceAction
- Cardano.Types.OutputDatum
- Cardano.Types.ParameterChangeAction
- Cardano.Types.PaymentCredential
- Cardano.Types.PaymentPubKeyHash
- Cardano.Types.PlutusData
- Cardano.Types.PlutusScript
- Cardano.Types.PointerAddress
- Cardano.Types.PoolMetadata
- Cardano.Types.PoolMetadataHash
- Cardano.Types.PoolParams
- Cardano.Types.PoolPubKeyHash
- Cardano.Types.PoolVotingThresholds
- Cardano.Types.PrivateKey
- Cardano.Types.ProtocolParamUpdate
- Cardano.Types.ProtocolVersion
- Cardano.Types.PublicKey
- Cardano.Types.RawBytes
- Cardano.Types.Redeemer
- Cardano.Types.RedeemerDatum
- Cardano.Types.RedeemerTag
- Cardano.Types.Relay
- Cardano.Types.RewardAddress
- Cardano.Types.ScriptDataHash
- Cardano.Types.ScriptHash
- Cardano.Types.ScriptRef
- Cardano.Types.Slot
- Cardano.Types.StakeCredential
- Cardano.Types.StakePubKeyHash
- Cardano.Types.Transaction
- Cardano.Types.TransactionBody
- Cardano.Types.TransactionHash
- Cardano.Types.TransactionInput
- Cardano.Types.TransactionMetadatum
- Cardano.Types.TransactionOutput
- Cardano.Types.TransactionUnspentOutput
- Cardano.Types.TransactionWitnessSet
- Cardano.Types.TreasuryWithdrawalsAction
- Cardano.Types.URL
- Cardano.Types.UnitInterval
- Cardano.Types.UpdateCommitteeAction
- Cardano.Types.UtxoMap
- Cardano.Types.VRFKeyHash
- Cardano.Types.Value
- Cardano.Types.Vkey
- Cardano.Types.Vkeywitness
- Cardano.Types.Vote
- Cardano.Types.Voter
- Cardano.Types.VotingProcedure
- Cardano.Types.VotingProcedures
- Cardano.Types.VotingProposal
- Cardano.Wallet.Cip30
- Cardano.Wallet.Cip30.TypeSafe
- Cardano.Wallet.Cip30Mock
- Cardano.Wallet.Cip95
- Cardano.Wallet.Cip95.TypeSafe
- Cardano.Wallet.HD
- Cardano.Wallet.Key
- Contract.Address
- Contract.AuxiliaryData
- Contract.Backend.Ogmios
- Contract.Backend.Ogmios.Mempool
- Contract.BalanceTxConstraints
- Contract.CborBytes
- Contract.Chain
- Contract.ClientError
- Contract.Config
- Contract.Credential
- Contract.Crypto.Secp256k1
- Contract.Crypto.Secp256k1.ECDSA
- Contract.Crypto.Secp256k1.Schnorr
- Contract.Crypto.Secp256k1.Utils
- Contract.Hashing
- Contract.JsSdk
- Contract.Keys
- Contract.Log
- Contract.Metadata
- Contract.Monad
- Contract.Numeric.BigNum
- Contract.Numeric.Convert
- Contract.Numeric.Rational
- Contract.Plutarch.Types
- Contract.PlutusData
- Contract.Prelude
- Contract.Prim.ByteArray
- Contract.ProtocolParameters
- Contract.ScriptLookups
- Contract.Scripts
- Contract.Staking
- Contract.Sync
- Contract.Test
- Contract.Test.Assert
- Contract.Test.Blockfrost
- Contract.Test.Cip30Mock
- Contract.Test.E2E
- Contract.Test.Mote
- Contract.Test.Mote.ConsoleReporter
- Contract.Test.Testnet
- Contract.Test.Utils
- Contract.TextEnvelope
- Contract.Time
- Contract.Transaction
- Contract.TxConstraints
- Contract.UnbalancedTx
- Contract.Utxos
- Contract.Value
- Contract.Wallet
- Contract.Wallet.Key
- Contract.Wallet.KeyFile
- Control.Algebra.Properties
- Control.Alt
- Control.Alternative
- Control.Applicative
- Control.Apply
- Control.Biapplicative
- Control.Biapply
- Control.Bind
- Control.Category
- Control.Comonad
- Control.Comonad.Cofree
- Control.Comonad.Cofree.Class
- Control.Comonad.Cofree.Trans
- Control.Comonad.Env
- Control.Comonad.Env.Class
- Control.Comonad.Env.Trans
- Control.Comonad.Store
- Control.Comonad.Store.Class
- Control.Comonad.Store.Trans
- Control.Comonad.Traced
- Control.Comonad.Traced.Class
- Control.Comonad.Traced.Trans
- Control.Comonad.Trans.Class
- Control.Extend
- Control.Lazy
- Control.Monad
- Control.Monad.Cont
- Control.Monad.Cont.Class
- Control.Monad.Cont.Trans
- Control.Monad.Error.Class
- Control.Monad.Except
- Control.Monad.Except.Checked
- Control.Monad.Except.Trans
- Control.Monad.Fork.Class
- Control.Monad.Free
- Control.Monad.Free.Class
- Control.Monad.Free.Trans
- Control.Monad.Gen
- Control.Monad.Gen.Class
- Control.Monad.Gen.Common
- Control.Monad.Identity.Trans
- Control.Monad.List.Trans
- Control.Monad.Logger.Class
- Control.Monad.Logger.Trans
- Control.Monad.Maybe.Trans
- Control.Monad.Morph
- Control.Monad.RWS
- Control.Monad.RWS.Trans
- Control.Monad.Reader
- Control.Monad.Reader.Class
- Control.Monad.Reader.Trans
- Control.Monad.Rec.Class
- Control.Monad.ST
- Control.Monad.ST.Class
- Control.Monad.ST.Global
- Control.Monad.ST.Internal
- Control.Monad.ST.Ref
- Control.Monad.ST.Uncurried
- Control.Monad.State
- Control.Monad.State.Class
- Control.Monad.State.Trans
- Control.Monad.Trampoline
- Control.Monad.Trans.Class
- Control.Monad.Writer
- Control.Monad.Writer.Class
- Control.Monad.Writer.Trans
- Control.MonadPlus
- Control.Parallel
- Control.Parallel.Class
- Control.Plus
- Control.Promise
- Control.Safely
- Control.Semigroupoid
- Ctl.Examples.AdditionalUtxos
- Ctl.Examples.AlwaysMints
- Ctl.Examples.AlwaysSucceeds
- Ctl.Examples.AwaitTxConfirmedWithTimeout
- Ctl.Examples.BalanceTxConstraints
- Ctl.Examples.ByUrl
- Ctl.Examples.ChangeGeneration
- Ctl.Examples.Cip30
- Ctl.Examples.ContractTestUtils
- Ctl.Examples.Datums
- Ctl.Examples.DropTokens
- Ctl.Examples.ECDSA
- Ctl.Examples.ExUnits
- Ctl.Examples.Gov.DelegateVoteAbstain
- Ctl.Examples.Gov.Internal.Common
- Ctl.Examples.Gov.ManageDrep
- Ctl.Examples.Gov.ManageDrepScript
- Ctl.Examples.Gov.SubmitVote
- Ctl.Examples.Gov.SubmitVoteScript
- Ctl.Examples.Helpers
- Ctl.Examples.IncludeDatum
- Ctl.Examples.KeyWallet.Cip30
- Ctl.Examples.KeyWallet.DelegateVoteAbstain
- Ctl.Examples.KeyWallet.Internal.Cip30Contract
- Ctl.Examples.KeyWallet.Internal.Cip30HtmlForm
- Ctl.Examples.KeyWallet.Internal.Contract
- Ctl.Examples.KeyWallet.Internal.HtmlForm
- Ctl.Examples.KeyWallet.Internal.Pkh2PkhContract
- Ctl.Examples.KeyWallet.Internal.Pkh2PkhHtmlForm
- Ctl.Examples.KeyWallet.ManageDrep
- Ctl.Examples.KeyWallet.MintsAndSendsToken
- Ctl.Examples.KeyWallet.Pkh2Pkh
- Ctl.Examples.KeyWallet.SignMultiple
- Ctl.Examples.KeyWallet.SubmitVote
- Ctl.Examples.Lose7Ada
- Ctl.Examples.ManyAssets
- Ctl.Examples.MintsMultipleTokens
- Ctl.Examples.MultipleRedeemers
- Ctl.Examples.NativeScriptMints
- Ctl.Examples.OneShotMinting
- Ctl.Examples.PaysWithDatum
- Ctl.Examples.Pkh2Pkh
- Ctl.Examples.PlutusV2.AlwaysSucceeds
- Ctl.Examples.PlutusV2.InlineDatum
- Ctl.Examples.PlutusV2.OneShotMinting
- Ctl.Examples.PlutusV2.ReferenceInputsAndScripts
- Ctl.Examples.PlutusV2.Scripts.AlwaysMints
- Ctl.Examples.PlutusV2.Scripts.AlwaysSucceeds
- Ctl.Examples.PlutusV3.Scripts.AlwaysMints
- Ctl.Examples.Schnorr
- Ctl.Examples.SendsToken
- Ctl.Examples.SignData
- Ctl.Examples.SignMultiple
- Ctl.Examples.TxChaining
- Ctl.Examples.Utxos
- Ctl.Examples.Wallet
- Ctl.Internal.Affjax
- Ctl.Internal.BalanceTx
- Ctl.Internal.BalanceTx.CoinSelection
- Ctl.Internal.BalanceTx.Collateral
- Ctl.Internal.BalanceTx.Collateral.Select
- Ctl.Internal.BalanceTx.Constraints
- Ctl.Internal.BalanceTx.Error
- Ctl.Internal.BalanceTx.ExUnitsAndMinFee
- Ctl.Internal.BalanceTx.FakeOutput
- Ctl.Internal.BalanceTx.Sync
- Ctl.Internal.BalanceTx.Types
- Ctl.Internal.BalanceTx.UtxoMinAda
- Ctl.Internal.Cardano.TextEnvelope
- Ctl.Internal.CardanoCli
- Ctl.Internal.CoinSelection.UtxoIndex
- Ctl.Internal.Contract
- Ctl.Internal.Contract.AwaitTxConfirmed
- Ctl.Internal.Contract.Hooks
- Ctl.Internal.Contract.LogParams
- Ctl.Internal.Contract.MinFee
- Ctl.Internal.Contract.Monad
- Ctl.Internal.Contract.QueryBackend
- Ctl.Internal.Contract.QueryHandle
- Ctl.Internal.Contract.QueryHandle.Error
- Ctl.Internal.Contract.QueryHandle.Type
- Ctl.Internal.Contract.Sign
- Ctl.Internal.Contract.WaitUntilSlot
- Ctl.Internal.Contract.Wallet
- Ctl.Internal.Error
- Ctl.Internal.FfiHelpers
- Ctl.Internal.Helpers
- Ctl.Internal.Helpers.Formatter
- Ctl.Internal.IsData
- Ctl.Internal.JsWebSocket
- Ctl.Internal.Logging
- Ctl.Internal.Metadata.MetadataType
- Ctl.Internal.MinFee
- Ctl.Internal.NativeScripts
- Ctl.Internal.Partition
- Ctl.Internal.ProcessConstraints
- Ctl.Internal.ProcessConstraints.Error
- Ctl.Internal.ProcessConstraints.State
- Ctl.Internal.QueryM
- Ctl.Internal.QueryM.CurrentEpoch
- Ctl.Internal.QueryM.Dispatcher
- Ctl.Internal.QueryM.EraSummaries
- Ctl.Internal.QueryM.JsonRpc2
- Ctl.Internal.QueryM.Kupo
- Ctl.Internal.QueryM.Ogmios
- Ctl.Internal.QueryM.Pools
- Ctl.Internal.QueryM.UniqueId
- Ctl.Internal.ServerConfig
- Ctl.Internal.Service.Blockfrost
- Ctl.Internal.Service.Error
- Ctl.Internal.Service.Helpers
- Ctl.Internal.Spawn
- Ctl.Internal.Test.ConsoleReporter
- Ctl.Internal.Test.ContractTest
- Ctl.Internal.Test.E2E.Browser
- Ctl.Internal.Test.E2E.Feedback
- Ctl.Internal.Test.E2E.Feedback.Browser
- Ctl.Internal.Test.E2E.Feedback.Hooks
- Ctl.Internal.Test.E2E.Feedback.Node
- Ctl.Internal.Test.E2E.Options
- Ctl.Internal.Test.E2E.Route
- Ctl.Internal.Test.E2E.Runner
- Ctl.Internal.Test.E2E.Types
- Ctl.Internal.Test.E2E.Wallets
- Ctl.Internal.Test.KeyDir
- Ctl.Internal.Test.UtxoDistribution
- Ctl.Internal.Testnet.Contract
- Ctl.Internal.Testnet.DistributeFunds
- Ctl.Internal.Testnet.Server
- Ctl.Internal.Testnet.Types
- Ctl.Internal.Testnet.Utils
- Ctl.Internal.Transaction
- Ctl.Internal.TxOutput
- Ctl.Internal.Types.Cbor
- Ctl.Internal.Types.Chain
- Ctl.Internal.Types.DelegationsAndRewards
- Ctl.Internal.Types.EraSummaries
- Ctl.Internal.Types.Interval
- Ctl.Internal.Types.MetadataLabel
- Ctl.Internal.Types.ProtocolParameters
- Ctl.Internal.Types.Rational
- Ctl.Internal.Types.ScriptLookups
- Ctl.Internal.Types.StakeValidatorHash
- Ctl.Internal.Types.SystemStart
- Ctl.Internal.Types.TxConstraints
- Ctl.Internal.Types.UsedTxOuts
- Ctl.Internal.Types.Val
- Ctl.Internal.Wallet
- Ctl.Internal.Wallet.Cip30
- Ctl.Internal.Wallet.Cip30Mock
- Ctl.Internal.Wallet.KeyFile
- Ctl.Internal.Wallet.Spec
- Data.Align
- Data.Argonaut
- Data.Argonaut.Core
- Data.Argonaut.Decode
- Data.Argonaut.Decode.Class
- Data.Argonaut.Decode.Combinators
- Data.Argonaut.Decode.Decoders
- Data.Argonaut.Decode.Error
- Data.Argonaut.Decode.Parser
- Data.Argonaut.Encode
- Data.Argonaut.Encode.Class
- Data.Argonaut.Encode.Combinators
- Data.Argonaut.Encode.Encoders
- Data.Argonaut.Gen
- Data.Argonaut.JCursor
- Data.Argonaut.JCursor.Gen
- Data.Argonaut.Parser
- Data.Argonaut.Prisms
- Data.Argonaut.Traversals
- Data.Array
- Data.Array.NonEmpty
- Data.Array.NonEmpty.Internal
- Data.Array.Partial
- Data.Array.ST
- Data.Array.ST.Iterator
- Data.Array.ST.Partial
- Data.ArrayBuffer.Types
- Data.Bifoldable
- Data.Bifunctor
- Data.Bifunctor.Join
- Data.BigNumber
- Data.Bitraversable
- Data.Boolean
- Data.BooleanAlgebra
- Data.Bounded
- Data.Bounded.Generic
- Data.ByteArray
- Data.CatList
- Data.CatQueue
- Data.Char
- Data.Char.Gen
- Data.Char.Utils
- Data.CodePoint.Unicode
- Data.CodePoint.Unicode.Internal
- Data.CodePoint.Unicode.Internal.Casing
- Data.CommutativeRing
- Data.Comparison
- Data.Const
- Data.Coyoneda
- Data.Date
- Data.Date.Component
- Data.Date.Component.Gen
- Data.Date.Gen
- Data.DateTime
- Data.DateTime.Gen
- Data.DateTime.Instant
- Data.Decidable
- Data.Decide
- Data.Distributive
- Data.Divide
- Data.Divisible
- Data.DivisionRing
- Data.Either
- Data.Either.Inject
- Data.Either.Nested
- Data.Enum
- Data.Enum.Gen
- Data.Enum.Generic
- Data.Eq
- Data.Eq.Generic
- Data.Equivalence
- Data.EuclideanRing
- Data.Exists
- Data.Field
- Data.Foldable
- Data.FoldableWithIndex
- Data.FormURLEncoded
- Data.Formatter.DateTime
- Data.Formatter.Internal
- Data.Formatter.Interval
- Data.Formatter.Number
- Data.Formatter.Parser.Interval
- Data.Formatter.Parser.Number
- Data.Formatter.Parser.Utils
- Data.Function
- Data.Function.Memoize
- Data.Function.Uncurried
- Data.Functor
- Data.Functor.App
- Data.Functor.Clown
- Data.Functor.Compose
- Data.Functor.Contravariant
- Data.Functor.Coproduct
- Data.Functor.Coproduct.Inject
- Data.Functor.Coproduct.Nested
- Data.Functor.Costar
- Data.Functor.Flip
- Data.Functor.Invariant
- Data.Functor.Joker
- Data.Functor.Mu
- Data.Functor.Nu
- Data.Functor.Product
- Data.Functor.Product.Nested
- Data.Functor.Product2
- Data.Functor.Variant
- Data.FunctorWithIndex
- Data.Generic.Rep
- Data.HTTP.Method
- Data.HeytingAlgebra
- Data.HeytingAlgebra.Generic
- Data.Identity
- Data.Int
- Data.Int.Bits
- Data.Interval
- Data.Interval.Duration
- Data.Interval.Duration.Iso
- Data.JSDate
- Data.Lattice
- Data.Lattice.Verify
- Data.Lazy
- Data.Lens
- Data.Lens.AffineTraversal
- Data.Lens.At
- Data.Lens.Common
- Data.Lens.Fold
- Data.Lens.Fold.Partial
- Data.Lens.Getter
- Data.Lens.Grate
- Data.Lens.Index
- Data.Lens.Indexed
- Data.Lens.Internal.Bazaar
- Data.Lens.Internal.Exchange
- Data.Lens.Internal.Focusing
- Data.Lens.Internal.Forget
- Data.Lens.Internal.Grating
- Data.Lens.Internal.Indexed
- Data.Lens.Internal.Market
- Data.Lens.Internal.Re
- Data.Lens.Internal.Shop
- Data.Lens.Internal.Stall
- Data.Lens.Internal.Tagged
- Data.Lens.Internal.Wander
- Data.Lens.Internal.Zipping
- Data.Lens.Iso
- Data.Lens.Iso.Newtype
- Data.Lens.Lens
- Data.Lens.Lens.Product
- Data.Lens.Lens.Tuple
- Data.Lens.Lens.Unit
- Data.Lens.Lens.Void
- Data.Lens.Prism
- Data.Lens.Prism.Coproduct
- Data.Lens.Prism.Either
- Data.Lens.Prism.Maybe
- Data.Lens.Record
- Data.Lens.Setter
- Data.Lens.Traversal
- Data.Lens.Types
- Data.Lens.Zoom
- Data.List
- Data.List.Internal
- Data.List.Lazy
- Data.List.Lazy.NonEmpty
- Data.List.Lazy.Types
- Data.List.NonEmpty
- Data.List.Partial
- Data.List.Types
- Data.List.ZipList
- Data.Log.Filter
- Data.Log.Formatter.JSON
- Data.Log.Formatter.Pretty
- Data.Log.Level
- Data.Log.Message
- Data.Log.Tag
- Data.Map
- Data.Map.Gen
- Data.Map.Internal
- Data.Maybe
- Data.Maybe.First
- Data.Maybe.Last
- Data.MediaType
- Data.MediaType.Common
- Data.Monoid
- Data.Monoid.Additive
- Data.Monoid.Alternate
- Data.Monoid.Conj
- Data.Monoid.Disj
- Data.Monoid.Dual
- Data.Monoid.Endo
- Data.Monoid.Generic
- Data.Monoid.Multiplicative
- Data.NaturalTransformation
- Data.Newtype
- Data.NonEmpty
- Data.Nullable
- Data.Number
- Data.Number.Approximate
- Data.Number.Format
- Data.Op
- Data.Options
- Data.Ord
- Data.Ord.Down
- Data.Ord.Generic
- Data.Ord.Max
- Data.Ord.Min
- Data.Ordering
- Data.Posix
- Data.Posix.Signal
- Data.Predicate
- Data.Profunctor
- Data.Profunctor.Choice
- Data.Profunctor.Closed
- Data.Profunctor.Cochoice
- Data.Profunctor.Costrong
- Data.Profunctor.Join
- Data.Profunctor.Split
- Data.Profunctor.Star
- Data.Profunctor.Strong
- Data.Ratio
- Data.Rational
- Data.Reflectable
- Data.Ring
- Data.Ring.Generic
- Data.Semigroup
- Data.Semigroup.First
- Data.Semigroup.Foldable
- Data.Semigroup.Generic
- Data.Semigroup.Last
- Data.Semigroup.Traversable
- Data.Semiring
- Data.Semiring.Generic
- Data.Set
- Data.Set.NonEmpty
- Data.Show
- Data.Show.Generic
- Data.String
- Data.String.CaseInsensitive
- Data.String.CodePoints
- Data.String.CodeUnits
- Data.String.Common
- Data.String.Gen
- Data.String.NonEmpty
- Data.String.NonEmpty.CaseInsensitive
- Data.String.NonEmpty.CodePoints
- Data.String.NonEmpty.CodeUnits
- Data.String.NonEmpty.Internal
- Data.String.Pattern
- Data.String.Regex
- Data.String.Regex.Flags
- Data.String.Regex.Unsafe
- Data.String.Unicode
- Data.String.Unsafe
- Data.String.Utils
- Data.Symbol
- Data.TacitString
- Data.TextDecoder
- Data.TextEncoder
- Data.These
- Data.These.Gen
- Data.Time
- Data.Time.Component
- Data.Time.Component.Gen
- Data.Time.Duration
- Data.Time.Duration.Gen
- Data.Time.Gen
- Data.Traversable
- Data.Traversable.Accum
- Data.Traversable.Accum.Internal
- Data.TraversableWithIndex
- Data.Tuple
- Data.Tuple.Nested
- Data.Typelevel.Bool
- Data.Typelevel.Num
- Data.Typelevel.Num.Aliases
- Data.Typelevel.Num.Ops
- Data.Typelevel.Num.Reps
- Data.Typelevel.Num.Sets
- Data.Typelevel.Undefined
- Data.UInt
- Data.UInt.Gen
- Data.Unfoldable
- Data.Unfoldable1
- Data.Unit
- Data.Variant
- Data.Variant.Internal
- Data.Void
- Data.Yoneda
- Debug
- Effect
- Effect.AVar
- Effect.Aff
- Effect.Aff.AVar
- Effect.Aff.Class
- Effect.Aff.Compat
- Effect.Aff.Retry
- Effect.Class
- Effect.Class.Console
- Effect.Console
- Effect.Exception
- Effect.Exception.Unsafe
- Effect.Now
- Effect.Random
- Effect.Ref
- Effect.Uncurried
- Effect.Unsafe
- ExitCodes
- Foreign
- Foreign.Index
- Foreign.Keys
- Foreign.Object
- Foreign.Object.Gen
- Foreign.Object.ST
- Foreign.Object.ST.Unsafe
- Foreign.Object.Unsafe
- Heterogeneous.Folding
- Heterogeneous.Mapping
- Internal.CardanoCli.QueryHandle
- JS.BigInt
- JSURI
- Literals
- Literals.Boolean
- Literals.Int
- Literals.Literal
- Literals.Null
- Literals.Number
- Literals.String
- Literals.Undefined
- Mote
- Mote.Description
- Mote.Entry
- Mote.Monad
- Mote.Plan
- Mote.TestPlanM
- Noble.Secp256k1.ECDSA
- Noble.Secp256k1.Schnorr
- Noble.Secp256k1.Utils
- Node.Buffer
- Node.Buffer.Class
- Node.Buffer.Immutable
- Node.Buffer.Internal
- Node.Buffer.ST
- Node.Buffer.Types
- Node.ChildProcess
- Node.Crypto
- Node.Crypto.Cipher
- Node.Crypto.Decipher
- Node.Crypto.Hash
- Node.Crypto.Hmac
- Node.Encoding
- Node.FS
- Node.FS.Aff
- Node.FS.Async
- Node.FS.Perms
- Node.FS.Stats
- Node.FS.Stream
- Node.FS.Sync
- Node.HTTP
- Node.HTTP.Client
- Node.HTTP.Secure
- Node.Net
- Node.Net.Server
- Node.Net.Socket
- Node.Path
- Node.Platform
- Node.Process
- Node.ReadLine
- Node.Stream
- Node.Stream.Aff
- Node.Stream.Aff.Internal
- Node.URL
- Options.Applicative
- Options.Applicative.BashCompletion
- Options.Applicative.Builder
- Options.Applicative.Builder.Completer
- Options.Applicative.Builder.Internal
- Options.Applicative.Common
- Options.Applicative.Extra
- Options.Applicative.Help
- Options.Applicative.Help.Chunk
- Options.Applicative.Help.Core
- Options.Applicative.Help.Levenshtein
- Options.Applicative.Help.Pretty
- Options.Applicative.Help.Types
- Options.Applicative.Internal
- Options.Applicative.Internal.Utils
- Options.Applicative.Types
- PSCI.Support
- Parsing
- Parsing.Combinators
- Parsing.Combinators.Array
- Parsing.Expr
- Parsing.Indent
- Parsing.Language
- Parsing.String
- Parsing.String.Basic
- Parsing.String.Replace
- Parsing.Token
- Partial
- Partial.Unsafe
- Pipes
- Pipes.Core
- Pipes.Internal
- Pipes.ListT
- Pipes.Prelude
- Prelude
- Prim
- Prim.Boolean
- Prim.Coerce
- Prim.Int
- Prim.Ordering
- Prim.Row
- Prim.RowList
- Prim.Symbol
- Prim.TypeError
- Random.LCG
- Record
- Record.Builder
- Record.Unsafe
- Record.Unsafe.Union
- Safe.Coerce
- Scaffold
- Scaffold.Main
- Scaffold.Test.Blockfrost
- Scaffold.Test.E2E
- Scaffold.Test.E2E.Serve
- Test.Assert
- Test.Ctl.ApplyArgs
- Test.Ctl.BalanceTx.ChangeGeneration
- Test.Ctl.BalanceTx.Collateral
- Test.Ctl.BalanceTx.Time
- Test.Ctl.Blockfrost
- Test.Ctl.Blockfrost.Aeson.Suite
- Test.Ctl.Blockfrost.Contract
- Test.Ctl.Blockfrost.GenerateFixtures.ChainTip
- Test.Ctl.Blockfrost.GenerateFixtures.EraSummaries
- Test.Ctl.Blockfrost.GenerateFixtures.Helpers
- Test.Ctl.Blockfrost.GenerateFixtures.NativeScript
- Test.Ctl.Blockfrost.GenerateFixtures.ProtocolParameters
- Test.Ctl.Blockfrost.GenerateFixtures.ScriptInfo
- Test.Ctl.Blockfrost.GenerateFixtures.SystemStart
- Test.Ctl.CoinSelection
- Test.Ctl.CoinSelection.Arbitrary
- Test.Ctl.CoinSelection.RoundRobin
- Test.Ctl.CoinSelection.SelectionState
- Test.Ctl.CoinSelection.UtxoIndex
- Test.Ctl.CslGc
- Test.Ctl.Data
- Test.Ctl.Data.Interval
- Test.Ctl.E2E
- Test.Ctl.E2E.Route
- Test.Ctl.Fixtures
- Test.Ctl.Fixtures.CostModels
- Test.Ctl.Hashing
- Test.Ctl.Integration
- Test.Ctl.Internal.Hashing
- Test.Ctl.Internal.Plutus.Credential
- Test.Ctl.Internal.Plutus.Time
- Test.Ctl.Logging
- Test.Ctl.Main
- Test.Ctl.NativeScript
- Test.Ctl.Ogmios.Aeson
- Test.Ctl.Ogmios.EvaluateTx
- Test.Ctl.Ogmios.GenerateFixtures
- Test.Ctl.Partition
- Test.Ctl.PrivateKey
- Test.Ctl.ProtocolParameters
- Test.Ctl.QueryM.AffInterface
- Test.Ctl.Serialization
- Test.Ctl.Serialization.Hash
- Test.Ctl.Testnet
- Test.Ctl.Testnet.Common
- Test.Ctl.Testnet.Contract
- Test.Ctl.Testnet.Contract.Assert
- Test.Ctl.Testnet.Contract.Mnemonics
- Test.Ctl.Testnet.Contract.OgmiosMempool
- Test.Ctl.Testnet.DistributeFunds
- Test.Ctl.Testnet.ExUnits
- Test.Ctl.Testnet.Gov
- Test.Ctl.Testnet.Logging
- Test.Ctl.Testnet.SameWallets
- Test.Ctl.Testnet.Staking
- Test.Ctl.Testnet.Utils
- Test.Ctl.Testnet.UtxoDistribution
- Test.Ctl.Types.Interval
- Test.Ctl.Types.Ipv6
- Test.Ctl.Types.TokenName
- Test.Ctl.Types.Transaction
- Test.Ctl.Unit
- Test.Ctl.UsedTxOuts
- Test.Ctl.Utils
- Test.Ctl.Utils.DrainWallets
- Test.Ctl.Wallet.Bip32
- Test.QuickCheck
- Test.QuickCheck.Arbitrary
- Test.QuickCheck.Combinators
- Test.QuickCheck.Gen
- Test.QuickCheck.Laws
- Test.QuickCheck.Laws.Control
- Test.QuickCheck.Laws.Control.Align
- Test.QuickCheck.Laws.Control.Alignable
- Test.QuickCheck.Laws.Control.Alt
- Test.QuickCheck.Laws.Control.Alternative
- Test.QuickCheck.Laws.Control.Applicative
- Test.QuickCheck.Laws.Control.Apply
- Test.QuickCheck.Laws.Control.Bind
- Test.QuickCheck.Laws.Control.Category
- Test.QuickCheck.Laws.Control.Comonad
- Test.QuickCheck.Laws.Control.Crosswalk
- Test.QuickCheck.Laws.Control.Extend
- Test.QuickCheck.Laws.Control.Monad
- Test.QuickCheck.Laws.Control.MonadPlus
- Test.QuickCheck.Laws.Control.Plus
- Test.QuickCheck.Laws.Control.Semigroupoid
- Test.QuickCheck.Laws.Data
- Test.QuickCheck.Laws.Data.BooleanAlgebra
- Test.QuickCheck.Laws.Data.Bounded
- Test.QuickCheck.Laws.Data.BoundedEnum
- Test.QuickCheck.Laws.Data.CommutativeRing
- Test.QuickCheck.Laws.Data.DivisionRing
- Test.QuickCheck.Laws.Data.Enum
- Test.QuickCheck.Laws.Data.Eq
- Test.QuickCheck.Laws.Data.EuclideanRing
- Test.QuickCheck.Laws.Data.Field
- Test.QuickCheck.Laws.Data.Foldable
- Test.QuickCheck.Laws.Data.Functor
- Test.QuickCheck.Laws.Data.FunctorWithIndex
- Test.QuickCheck.Laws.Data.HeytingAlgebra
- Test.QuickCheck.Laws.Data.Monoid
- Test.QuickCheck.Laws.Data.Ord
- Test.QuickCheck.Laws.Data.Ring
- Test.QuickCheck.Laws.Data.Semigroup
- Test.QuickCheck.Laws.Data.Semiring
- Test.Scaffold.Main
- Test.Spec
- Test.Spec.Assertions
- Test.Spec.Assertions.String
- Test.Spec.Console
- Test.Spec.QuickCheck
- Test.Spec.Reporter
- Test.Spec.Reporter.Base
- Test.Spec.Reporter.Console
- Test.Spec.Reporter.ConsoleReporter
- Test.Spec.Reporter.Dot
- Test.Spec.Reporter.Spec
- Test.Spec.Reporter.Tap
- Test.Spec.Reporter.TeamCity
- Test.Spec.Result
- Test.Spec.Runner
- Test.Spec.Runner.Event
- Test.Spec.Speed
- Test.Spec.Style
- Test.Spec.Summary
- Test.Spec.Tree
- Text.PrettyPrint.Leijen
- Toppokki
- Type.Data.Boolean
- Type.Data.Ordering
- Type.Data.Symbol
- Type.Equality
- Type.Function
- Type.Prelude
- Type.Proxy
- Type.Row
- Type.Row.Homogeneous
- Type.RowList
- Unsafe.Coerce
- Untagged.Castable
- Untagged.TypeCheck
- Untagged.Union
- Web.DOM
- Web.DOM.CharacterData
- Web.DOM.ChildNode
- Web.DOM.Comment
- Web.DOM.DOMTokenList
- Web.DOM.Document
- Web.DOM.DocumentFragment
- Web.DOM.DocumentType
- Web.DOM.Element
- Web.DOM.HTMLCollection
- Web.DOM.Internal.Types
- Web.DOM.MutationObserver
- Web.DOM.MutationRecord
- Web.DOM.Node
- Web.DOM.NodeList
- Web.DOM.NodeType
- Web.DOM.NonDocumentTypeChildNode
- Web.DOM.NonElementParentNode
- Web.DOM.ParentNode
- Web.DOM.ProcessingInstruction
- Web.DOM.ShadowRoot
- Web.DOM.Text
- Web.Event.CustomEvent
- Web.Event.Event
- Web.Event.EventPhase
- Web.Event.EventTarget
- Web.Event.Internal.Types
- Web.File.Blob
- Web.File.File
- Web.File.FileList
- Web.File.FileReader
- Web.File.FileReader.ReadyState
- Web.File.Url
- Web.HTML
- Web.HTML.Common
- Web.HTML.Event.BeforeUnloadEvent
- Web.HTML.Event.BeforeUnloadEvent.EventTypes
- Web.HTML.Event.DataTransfer
- Web.HTML.Event.DataTransfer.DataTransferItem
- Web.HTML.Event.DragEvent
- Web.HTML.Event.DragEvent.EventTypes
- Web.HTML.Event.ErrorEvent
- Web.HTML.Event.EventTypes
- Web.HTML.Event.HashChangeEvent
- Web.HTML.Event.HashChangeEvent.EventTypes
- Web.HTML.Event.PageTransitionEvent
- Web.HTML.Event.PageTransitionEvent.EventTypes
- Web.HTML.Event.PopStateEvent
- Web.HTML.Event.PopStateEvent.EventTypes
- Web.HTML.Event.TrackEvent
- Web.HTML.Event.TrackEvent.EventTypes
- Web.HTML.HTMLAnchorElement
- Web.HTML.HTMLAreaElement
- Web.HTML.HTMLAudioElement
- Web.HTML.HTMLBRElement
- Web.HTML.HTMLBaseElement
- Web.HTML.HTMLBodyElement
- Web.HTML.HTMLButtonElement
- Web.HTML.HTMLCanvasElement
- Web.HTML.HTMLDListElement
- Web.HTML.HTMLDataElement
- Web.HTML.HTMLDataListElement
- Web.HTML.HTMLDivElement
- Web.HTML.HTMLDocument
- Web.HTML.HTMLDocument.ReadyState
- Web.HTML.HTMLDocument.VisibilityState
- Web.HTML.HTMLElement
- Web.HTML.HTMLEmbedElement
- Web.HTML.HTMLFieldSetElement
- Web.HTML.HTMLFormElement
- Web.HTML.HTMLHRElement
- Web.HTML.HTMLHeadElement
- Web.HTML.HTMLHeadingElement
- Web.HTML.HTMLHtmlElement
- Web.HTML.HTMLHyperlinkElementUtils
- Web.HTML.HTMLIFrameElement
- Web.HTML.HTMLImageElement
- Web.HTML.HTMLImageElement.CORSMode
- Web.HTML.HTMLImageElement.DecodingHint
- Web.HTML.HTMLImageElement.Laziness
- Web.HTML.HTMLInputElement
- Web.HTML.HTMLKeygenElement
- Web.HTML.HTMLLIElement
- Web.HTML.HTMLLabelElement
- Web.HTML.HTMLLegendElement
- Web.HTML.HTMLLinkElement
- Web.HTML.HTMLMapElement
- Web.HTML.HTMLMediaElement
- Web.HTML.HTMLMediaElement.CanPlayType
- Web.HTML.HTMLMediaElement.NetworkState
- Web.HTML.HTMLMediaElement.ReadyState
- Web.HTML.HTMLMetaElement
- Web.HTML.HTMLMeterElement
- Web.HTML.HTMLModElement
- Web.HTML.HTMLOListElement
- Web.HTML.HTMLObjectElement
- Web.HTML.HTMLOptGroupElement
- Web.HTML.HTMLOptionElement
- Web.HTML.HTMLOutputElement
- Web.HTML.HTMLParagraphElement
- Web.HTML.HTMLParamElement
- Web.HTML.HTMLPreElement
- Web.HTML.HTMLProgressElement
- Web.HTML.HTMLQuoteElement
- Web.HTML.HTMLScriptElement
- Web.HTML.HTMLSelectElement
- Web.HTML.HTMLSourceElement
- Web.HTML.HTMLSpanElement
- Web.HTML.HTMLStyleElement
- Web.HTML.HTMLTableCaptionElement
- Web.HTML.HTMLTableCellElement
- Web.HTML.HTMLTableColElement
- Web.HTML.HTMLTableDataCellElement
- Web.HTML.HTMLTableElement
- Web.HTML.HTMLTableHeaderCellElement
- Web.HTML.HTMLTableRowElement
- Web.HTML.HTMLTableSectionElement
- Web.HTML.HTMLTemplateElement
- Web.HTML.HTMLTextAreaElement
- Web.HTML.HTMLTimeElement
- Web.HTML.HTMLTitleElement
- Web.HTML.HTMLTrackElement
- Web.HTML.HTMLTrackElement.ReadyState
- Web.HTML.HTMLUListElement
- Web.HTML.HTMLVideoElement
- Web.HTML.History
- Web.HTML.Location
- Web.HTML.Navigator
- Web.HTML.SelectionMode
- Web.HTML.ValidityState
- Web.HTML.Window
- Web.Internal.FFI
- Web.Storage.Event.StorageEvent
- Web.Storage.Storage
- Web.XHR.EventTypes
- Web.XHR.FormData
- Web.XHR.ProgressEvent
- Web.XHR.ReadyState
- Web.XHR.ResponseType
- Web.XHR.XMLHttpRequest
- Web.XHR.XMLHttpRequestUpload
The
Functor
instance allows functions to transform the contents of aRight
with the<$>
operator:Left
values are untouched: