Search results
compose2 :: forall a b x y. (a -> b) -> (x -> y -> a) -> x -> y -> b
\f g x y -> f (g x y)
distributive :: forall a. Eq a => (a -> a) -> (a -> a -> a) -> a -> a -> Boolean
f (g x y) == g (f x) (f y)?
composeSecondFlipped :: forall a b x y. (y -> b) -> (x -> b -> a) -> x -> y -> a
over2 :: forall t a s b. Newtype t a => Newtype s b => (a -> t) -> (a -> a -> b) -> t -> t -> s
Lifts a binary function to operate over newtypes.
newtype Meter = Meter Int
derive newtype instance newtypeMeter :: Newtype Meter _
newtype SquareMeter = SquareMeter Int
derive newtype instance newtypeSquareMeter :: Newtype SquareMeter _
area :: Meter -> Meter -> SquareMeter
area = over2 Meter (*)
The above example also demonstrates that the return type is polymorphic here too.
under2 :: forall t a s b. Newtype t a => Newtype s b => (a -> t) -> (t -> t -> s) -> a -> a -> b
The opposite of over2: lowers a binary function that operates on Newtyped
values to operate on the wrapped value instead.
absorbtion :: forall a. Eq a => (a -> a -> a) -> (a -> a -> a) -> a -> a -> Boolean
absorbtion :: forall a. Eq a => (a -> a -> a) -> (a -> a -> a) -> a -> a -> Boolean
mapCopyAll :: forall a b p q. (String -> String) -> (a -> b) -> p -> q -> p
dimap :: forall a b. (a -> Number) -> (Number -> b) -> ContinuousScale -> (a -> b)
Transform both input and output (profunctor-like)
transformed = scale # dimap preprocess postprocess
insertByWith :: forall a. (a -> Boolean) -> (a -> a -> Ordering) -> a -> Array a -> Maybe (Array a)
Insert the element into a sorted array but only if the element can not be found by the predicate.
insertByWith (_ == 2) (\a b -> compare a b) 2 [1,3] == Just [1,2,3]
compose3 :: forall a b x y z. (a -> b) -> (x -> y -> z -> a) -> x -> y -> z -> b
\f g x y z -> f (g x y z)
composeThirdFlipped :: forall a b x y z. (z -> b) -> (x -> y -> b -> a) -> x -> y -> z -> a
splay2 :: forall a b c d. (a -> b -> c -> d) -> (a -> b -> c) -> a -> b -> d
traverse :: forall f t a. Coercible (f a) (f t) => Newtype t a => (a -> t) -> (a -> f a) -> t -> f t
Similar to the function from the Traversable class, but operating within
a newtype instead.
iterateUntilM :: forall a m. Monad m => (a -> Boolean) -> (a -> m a) -> a -> m a
Yields the result of applying f until p holds.
iterateUntilM :: forall m a. MonadRec m => (a -> Boolean) -> (a -> m a) -> a -> m a
Yields the result of applying f until p holds.
compose2SecondFlipped :: forall a b x y z. (y -> z -> b) -> (x -> b -> a) -> x -> y -> z -> a
retryUntilLoop :: forall m a. Monad m => (a -> Boolean) -> (a -> m a) -> a -> m a
Repeat a computation until the value satisfies a predicate, looping in the previous value
distributive :: forall a. Eq a => (a -> a -> a) -> (a -> a -> a) -> a -> a -> a -> Boolean
leftDistributive :: forall a. Eq a => (a -> a -> a) -> (a -> a -> a) -> a -> a -> a -> Boolean
rightDistributive :: forall a. Eq a => (a -> a -> a) -> (a -> a -> a) -> a -> a -> a -> Boolean
distributive :: forall a. Eq a => (a -> a -> a) -> (a -> a -> a) -> a -> a -> a -> Boolean
leftDistributive :: forall a. Eq a => (a -> a -> a) -> (a -> a -> a) -> a -> a -> a -> Boolean
rightDistributive :: forall a. Eq a => (a -> a -> a) -> (a -> a -> a) -> a -> a -> a -> Boolean
discard :: forall m a b c. Bind m => (a -> m b) -> (Unit -> (b -> m c)) -> (a -> m c)
bifoldl :: forall p a b c. Bifoldable p => (c -> a -> c) -> (c -> b -> c) -> c -> p a b -> c
bifoldlDefault :: forall p a b c. Bifoldable p => (c -> a -> c) -> (c -> b -> c) -> c -> p a b -> c
A default implementation of bifoldl using bifoldMap.
Note: when defining a Bifoldable instance, this function is unsafe to
use in combination with bifoldMapDefaultL.
applyThirdFlipped :: forall x y z a. x -> (y -> z -> x -> a) -> y -> z -> a
composeKleisliFlipped :: forall a b c m. Bind m => (b -> m c) -> (a -> m b) -> a -> m c
Backwards Kleisli composition.
compose2Second :: forall a b x y z. (x -> b -> a) -> (y -> z -> b) -> x -> y -> z -> a
\f g x y z -> f x (g y z)
becard :: forall d c b a. (c -> d) -> (b -> c) -> (a -> b) -> a -> d
B3 combinator - becard
B(BB)B
Λ a b c d . (c → d) → (b → c) → (a → b) → a → d
λ f g h x . f (g (h x))
on :: forall a b c. (b -> b -> c) -> (a -> b) -> a -> a -> c
The on function is used to change the domain of a binary operator.
For example, we can create a function which compares two records based on the values of their x properties:
compareX :: forall r. { x :: Number | r } -> { x :: Number | r } -> Ordering
compareX = compare `on` _.x
bifoldr :: forall p a b c. Bifoldable p => (a -> c -> c) -> (b -> c -> c) -> c -> p a b -> c
bifoldrDefault :: forall p a b c. Bifoldable p => (a -> c -> c) -> (b -> c -> c) -> c -> p a b -> c
A default implementation of bifoldr using bifoldMap.
Note: when defining a Bifoldable instance, this function is unsafe to
use in combination with bifoldMapDefaultR.
goldfinch :: forall d c b a. (b -> c -> d) -> (a -> c) -> a -> b -> d
G combinator - goldfinch
BBC
Λ a b c d . (b → c → d) → (a → c) → a → b → d
λ f g x y . f y (g x)
on :: forall c b a. (b -> b -> c) -> (a -> b) -> a -> a -> c
Psi combinator - psi bird - on
Λ a b . (b → b → c) → (a → b) → a → a → c
λ f g . λ x y . f (g x) (g y)
on :: forall c b a. (a -> a -> b) -> (c -> a) -> c -> c -> b
psi :: forall c b a. (a -> a -> b) -> (c -> a) -> (c -> c -> b)
compose2Flipped :: forall a b x y. (x -> y -> a) -> (a -> b) -> x -> y -> b
composeSecond :: forall a b x y. (x -> b -> a) -> (y -> b) -> x -> y -> a
\f g x y -> f x (g y)
composeKleisli :: forall a b c m. Bind m => (a -> m b) -> (b -> m c) -> a -> m c
Forwards Kleisli composition.
For example:
import Data.Array (head, tail)
third = tail >=> tail >=> head
applySecondFlipped :: forall x y a. x -> (y -> x -> a) -> y -> a
compose :: forall c b a. (b -> c) -> (a -> b) -> (a -> c)
Returns a new function that calls the first function with the result of calling the second.
let addTwo x = x + 2
let double x = x * 2
let addTwoThenDouble x = addTwo :compose double
addTwoThenDouble 3 -- 10
This is function composition.
finch :: forall c b a. a -> (c -> a -> b) -> c -> b
F combinator - finch
ETTET
Λ a b c . a → b → (b → a → c) → c
λ x y f . f y x
modifyOrCons :: forall a. (a -> Boolean) -> (a -> a) -> a -> Array a -> Array a
Modify an element when it was found by the predicate or push a new element to the front of the array.
modifyOrCons (_ == 2) (* 3) 11 [1,2,3] == Just [1,6,3]
modifyOrCons (_ == 4) (* 3) 11 [1,2,3] == Just [11,1,2,3]
modifyOrCons :: forall a. (a -> Boolean) -> (a -> a) -> a -> Array a -> Array a
Modify an element when it was found by the predicate or push a new element to the front of the array.
modifyOrCons (_ == 2) (* 3) 11 [1,2,3] == Just [1,6,3]
modifyOrCons (_ == 4) (* 3) 11 [1,2,3] == Just [11,1,2,3]
robin :: forall c b a. a -> (b -> a -> c) -> b -> c
R combinator - robin
BBT
Λ a b c . a → (b → a → c) → b → c
λ x f y . f y x
on :: forall @sym f1 f2 a b r1 r2. Newtype f2 (Variant r2) => Newtype f1 (Variant r1) => Cons sym a r1 r2 => IsSymbol sym => (a -> b) -> (f1 -> b) -> f2 -> b
unsafeOptField_helper :: forall r val obj. r -> (val -> r) -> String -> obj -> r
caseDeposit :: forall a d. Deposit d => (Source -> a) -> (Mineral -> a) -> d -> a
fromKillSignal' :: forall r. (Int -> r) -> (String -> r) -> KillSignal -> r
modifyOrSnoc :: forall a. (a -> Boolean) -> (a -> a) -> Array a -> a -> Array a
Modify an element when it was found by the predicate or append a new element to the end of the array.
modifyOrSnoc (_ == 2) (* 3) [1,2,3] 11 == Just [1,6,3]
modifyOrSnoc (_ == 4) (* 3) [1,2,3] 11 == Just [1,2,3,11]
modifyOrSnoc :: forall a. (a -> Boolean) -> (a -> a) -> Array a -> a -> Array a
Modify an element when it was found by the predicate or append a new element to the end of the array.
modifyOrSnoc (_ == 2) (* 3) [1,2,3] 11 == Just [1,6,3]
modifyOrSnoc (_ == 4) (* 3) [1,2,3] 11 == Just [1,2,3,11]
while :: forall a. (a -> Boolean) -> (a -> a) -> a -> a
Keeps calling the function while the predicate is true.
1 :while (_ < 3) (_ + 1) -- 3
9 :while (_ < 3) (_ + 1) -- 9
alaF :: forall f g t a s b. Coercible (f t) (f a) => Coercible (g s) (g b) => Newtype t a => Newtype s b => (a -> t) -> (f t -> g s) -> f a -> g b
Similar to ala but useful for cases where you want to use an additional
projection with the higher order function:
alaF Additive foldMap String.length ["hello", "world"] -- 10
alaF Multiplicative foldMap Math.abs [1.0, -2.0, 3.0, -4.0] -- 24.0
The type admits other possibilities due to the polymorphic Functor
constraints, but the case described above works because ((->) a) is a
Functor.
overF :: forall f g t a s b. Coercible (f a) (f t) => Coercible (g b) (g s) => Newtype t a => Newtype s b => (a -> t) -> (f a -> g b) -> f t -> g s
Much like over, but where the lifted function operates on values in a
Functor:
findLabel :: String -> Array Label -> Maybe Label
findLabel s = overF Label (Foldable.find (_ == s))
The above example also demonstrates that the functor type is polymorphic
here too, the input is an Array but the result is a Maybe.
underF :: forall f g t a s b. Coercible (f t) (f a) => Coercible (g s) (g b) => Newtype t a => Newtype s b => (a -> t) -> (f t -> g s) -> f a -> g b
Much like under, but where the lifted function operates on values in a
Functor:
newtype EmailAddress = EmailAddress String
derive instance newtypeEmailAddress :: Newtype EmailAddress _
isValid :: EmailAddress -> Boolean
isValid x = false -- imagine a slightly less strict predicate here
findValidEmailString :: Array String -> Maybe String
findValidEmailString = underF EmailAddress (Foldable.find isValid)
The above example also demonstrates that the functor type is polymorphic
here too, the input is an Array but the result is a Maybe.
imap :: forall f a b. Invariant f => (a -> b) -> (b -> a) -> f a -> f b
imapF :: forall f a b. Functor f => (a -> b) -> (b -> a) -> f a -> f b
As all Functors are also trivially Invariant, this function can be
used as the imap implementation for any types that has an existing
Functor instance.
imapC :: forall f a b. Contravariant f => (a -> b) -> (b -> a) -> f a -> f b
As all Contravariant functors are also trivially Invariant, this function can be used as the imap implementation for any types that have an existing Contravariant instance.
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
under :: forall t a s b. Newtype t a => Newtype s b => (a -> t) -> (t -> s) -> a -> b
The opposite of over: lowers a function that operates on Newtyped
values to operate on the wrapped value instead.
newtype Degrees = Degrees Number
derive instance newtypeDegrees :: Newtype Degrees _
newtype NormalDegrees = NormalDegrees Number
derive instance newtypeNormalDegrees :: Newtype NormalDegrees _
normaliseDegrees :: Degrees -> NormalDegrees
normaliseDegrees (Degrees deg) = NormalDegrees (deg % 360.0)
asNormalDegrees :: Number -> Number
asNormalDegrees = under Degrees normaliseDegrees
As with over the Newtype is polymorphic, as illustrated in the example
above - both Degrees and NormalDegrees are instances of Newtype,
so even though normaliseDegrees changes the result type we can still put
a Number in and get a Number out via under.
uncons' :: forall r. r -> (SourceToken -> TokenList -> r) -> TokenList -> r
memoCompose :: forall a b c. (a -> b) -> (b -> c) -> a -> c
Memoize the composition of two functions
subscriptionEventOpts :: forall opts c. SubscriptionClient c opts => (opts -> opts) -> c -> String -> Json -> Emitter Json
watchQueryEventOpts :: forall opts c. WatchQueryClient c opts => (opts -> opts) -> c -> String -> Json -> Emitter Json
verifyScannable :: forall b a f. Eq (f b) => Functor f => Foldable f => Scannable f => (b -> a -> b) -> (a -> b) -> b -> f a -> Boolean
jacobiIdentity :: forall a. Eq a => (a -> a -> a) -> (a -> a -> a) -> a -> a -> a -> a -> Boolean
jacobiIdentity :: forall a. Eq a => (a -> a -> a) -> (a -> a -> a) -> a -> a -> a -> a -> Boolean
distributive' :: forall b a. Eq b => (a -> b) -> (a -> a -> a) -> (b -> b -> b) -> a -> a -> Boolean
f (g x y) == g' (f x) (f y)?
handle :: forall a' a p t s. RowCons t (Action t p) a a' => IsSymbol t => (s -> Action t p -> s) -> (Variant a -> s -> s) -> Variant a' -> s -> s
Converts a single action handler into an "action handler set"
handlers = handle logIn. This "action handler set" can be combined
with other action handlers using combine or >>=>>.
surroundMapWithIndex :: forall i f a m. FoldableWithIndex i f => Semigroup m => m -> (i -> a -> m) -> f a -> m
foldMapWithIndex but with each element surrounded by some fixed value.
For example:
> surroundMapWithIndex "*" (\i x -> show i <> x) []
= "*"
> surroundMapWithIndex "*" (\i x -> show i <> x) ["a"]
= "*0a*"
> surroundMapWithIndex "*" (\i x -> show i <> x) ["a", "b"]
= "*0a*1b*"
> surroundMapWithIndex "*" (\i x -> show i <> x) ["a", "b", "c"]
= "*0a*1b*2c*"
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
expectNotSatisfyM :: forall m a. MonadThrow Error m => Show a => a -> (a -> m Boolean) -> String -> m Unit
expectSatisfyM :: forall m a. MonadThrow Error m => Show a => a -> (a -> m Boolean) -> String -> m Unit
iterateN :: forall f a. Unfoldable1 f => (a -> a) -> a -> Int -> f a
forWithIndex :: forall i a b m t. Applicative m => TraversableWithIndex i t => t a -> (i -> a -> m b) -> m (t b)
A version of traverseWithIndex 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] \i x -> do
logShow i
pure (x * x)
overF2 :: forall f g t a s b. Coercible (f a) (f t) => Coercible (g b) (g s) => Newtype t a => Newtype s b => (a -> t) -> (f a -> f a -> g b) -> f t -> f t -> g s
Much like over2, but where the lifted binary function operates on
values in a Functor.
underF2 :: forall f g t a s b. Coercible (f t) (f a) => Coercible (g s) (g b) => Newtype t a => Newtype s b => (a -> t) -> (f t -> f t -> g s) -> f a -> f a -> g b
Much like under2, but where the lifted binary function operates on
values in a Functor.
bitraverse_ :: forall t f a b c d. Bifoldable t => Applicative f => (a -> f c) -> (b -> f d) -> t a b -> f Unit
Traverse a data structure, accumulating effects using an Applicative functor,
ignoring the final result.
onemore :: forall t24 t25 t27 t28. (t25 -> t27 -> t28) -> (t24 -> t25) -> (t24 -> t27) -> t24 -> t28
antitransitive :: forall b a. HeytingAlgebra b => (a -> a -> b) -> a -> a -> a -> b
intransitive :: forall b a. HeytingAlgebra b => (a -> a -> b) -> a -> a -> a -> b
transitive :: forall b a. HeytingAlgebra b => (a -> a -> b) -> a -> a -> a -> b
antitransitive :: forall b a. HeytingAlgebra b => (a -> a -> b) -> a -> a -> a -> b
intransitive :: forall b a. HeytingAlgebra b => (a -> a -> b) -> a -> a -> a -> b
transitive :: forall b a. HeytingAlgebra b => (a -> a -> b) -> a -> a -> a -> b
jay :: forall b a. (a -> b -> b) -> a -> b -> a -> b
J combinator - Jay
B(BC)(W(BC(B(BBB))))
Λ a b c d . (a → b → b) → a → b → a → b
λ f x y z . f x (f z y)
switchFoldOp :: forall s' s. Game s => GameBoot s' => (Input -> s -> s) -> (Input -> s' -> s') -> Input -> GameWithBoot s s' -> GameWithBoot s s'
associative :: forall a. Eq a => (a -> a -> a) -> a -> a -> a -> Boolean
cancellative :: forall a. Eq a => (a -> a -> a) -> a -> a -> a -> Boolean
leftCancellative :: forall a. Eq a => (a -> a -> a) -> a -> a -> a -> Boolean
leftUnar :: forall a. Eq a => (a -> a -> a) -> a -> a -> a -> Boolean
rightCancellative :: forall a. Eq a => (a -> a -> a) -> a -> a -> a -> Boolean
rightUnar :: forall a. Eq a => (a -> a -> a) -> a -> a -> a -> Boolean
associative :: forall a. Eq a => (a -> a -> a) -> a -> a -> a -> Boolean
cancellative :: forall a. Eq a => (a -> a -> a) -> a -> a -> a -> Boolean
leftCancellative :: forall a. Eq a => (a -> a -> a) -> a -> a -> a -> Boolean
leftUnar :: forall a. Eq a => (a -> a -> a) -> a -> a -> a -> Boolean
rightCancellative :: forall a. Eq a => (a -> a -> a) -> a -> a -> a -> Boolean
rightUnar :: forall a. Eq a => (a -> a -> a) -> a -> a -> a -> Boolean
verifySemilattice :: forall a. Eq a => (a -> a -> a) -> a -> a -> a -> Boolean
associative :: forall a. Eq a => (a -> a -> a) -> a -> a -> a -> Boolean
f (f x y) z == f x (f y z)?
verifySemilattice :: forall a. Eq a => (a -> a -> a) -> a -> a -> a -> Boolean
bind :: forall m a b c. Bind m => (a -> m b) -> ((a -> m b) -> (b -> m c)) -> (a -> m c)
ifte :: forall b a m. MonadLogic m => m a -> (a -> m b) -> m b -> m b
memoCompose2 :: forall a b c d. (a -> b) -> (a -> c) -> (b -> c -> d) -> a -> d
foldingWithIndex :: forall f i x y z. FoldingWithIndex f i x y z => f -> i -> x -> y -> z
mapmap :: forall f g a b. Functor f => Functor g => (a -> b) -> f (g a) -> f (g b)
mmap :: forall a b f g. Functor f => Functor g => (a -> b) -> f (g a) -> f (g b)
foldingWithIndex :: forall f i x y z. FoldingWithIndex f i x y z => f -> i -> x -> y -> z
new3 :: forall b a3 a2 a1 o. o -> a1 -> a2 -> a3 -> b
args4 :: forall a b c d. a -> b -> c -> d -> PseudoArray
returns 4 arguments as a PseudoArray
monotonic :: forall a. HeytingAlgebra a => Eq a => (a -> a -> a) -> a -> a -> a -> a
monotonic :: forall a. HeytingAlgebra a => Eq a => (a -> a -> a) -> a -> a -> a -> a
curry3 :: forall d c b a. (Tuple3 a b c -> d) -> a -> b -> c -> d
cubicBezier :: forall x1 y1 x2 y2. ToNumber x1 => ToNumber y1 => ToNumber x2 => ToNumber y2 => x1 -> y1 -> x2 -> y2 -> EasingFunction
newMargin :: forall b l r t. b -> l -> r -> t -> Margin_
newSpot :: forall x y offx offy. x -> y -> offx -> offy -> Spot_
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
either2 :: forall r a b. (a -> r) -> (b -> r) -> Either2 a b -> r
biall :: forall t a b c. Bifoldable t => BooleanAlgebra c => (a -> c) -> (b -> c) -> t a b -> c
Test whether a predicate holds at all positions in a data structure.
biany :: forall t a b c. Bifoldable t => BooleanAlgebra c => (a -> c) -> (b -> c) -> t a b -> c
Test whether a predicate holds at any position in a data structure.
bifoldMap :: forall p m a b. Bifoldable p => Monoid m => (a -> m) -> (b -> m) -> p a b -> m
bifoldMapDefaultL :: forall p m a b. Bifoldable p => Monoid m => (a -> m) -> (b -> m) -> p a b -> m
A default implementation of bifoldMap using bifoldl.
Note: when defining a Bifoldable instance, this function is unsafe to
use in combination with bifoldlDefault.
bifoldMapDefaultR :: forall p m a b. Bifoldable p => Monoid m => (a -> m) -> (b -> m) -> p a b -> m
A default implementation of bifoldMap using bifoldr.
Note: when defining a Bifoldable instance, this function is unsafe to
use in combination with bifoldrDefault.
foldlVariantRowList :: forall f x rl r b proxy. FoldlVariant f x rl r b => proxy rl -> f -> x -> Variant r -> b
validation :: forall err result r. (err -> r) -> (result -> r) -> V err result -> r
Takes two functions an a V value, if the validation failed the error is
applied to the first function, if the validation succeeded the inner value
is applied to the second function.
validation :: forall err result r. (err -> r) -> (result -> r) -> V err result -> r
Takes two functions an a V value, if the validation failed the error is
applied to the first function, if the validation succeeded the inner value
is applied to the second function.
regroup :: forall a k. Ord k => (a -> Boolean) -> (a -> k) -> (k -> a) -> Tree a -> Tree a
If the value in the node matches the first function, keep the value intact, but iterate
everything :: forall a r. Data a => (r -> r -> r) -> (forall b. Data b => b -> r) -> a -> r
Summarise all nodes in top-down, left-to-right
findAndModifyOrNew :: forall a. (a -> Boolean) -> (a -> a) -> (Unit -> a) -> Array a -> Array a
result :: forall c b a. (a -> c) -> (b -> c) -> Result a b -> c
Takes two functions and an Result value, if the value is a Error the
inner value is applied to the first function, if the value is a Ok
the inner value is applied to the second function.
Result f g (Error x) == f x
Result f g (Ok y) == g y
smash :: forall c b a. c -> (a -> b -> c) -> Smash a b -> c
Smash catamorphism (fold). Takes an input for each possible constructor and
translates it to c.
For example, we can go from some s :: Smash a b to a
Maybe (Tuple a b) using:
> smash Nothing (\a b -> Just (Tuple a b)) (Non :: Smash String Int)
Nothing
> smash Nothing (\a b -> Just (Tuple a b)) (Two "hello" 43 :: Smash String Int)
Just (Tuple "hello" 42)
collect :: forall f t a. Coercible (f a) (f t) => Newtype t a => (a -> t) -> (f a -> a) -> f t -> t
Similar to the function from the Distributive class, but operating within
a newtype instead.
either3 :: forall r a b c. (a -> r) -> (b -> r) -> (c -> r) -> Either3 a b c -> r
contractWith :: forall gt lt proxy1 proxy2 f a. Contractable gt lt => Alternative f => proxy1 gt -> proxy2 lt -> String -> a -> f a
worbler :: forall b a. b -> (b -> b -> a) -> a
W1 combinator - converse warbler
CW
Λ a b . a → (a → a → b) → b
λ x f = f x x
compose4 :: forall a b w x y z. (a -> b) -> (w -> x -> y -> z -> a) -> w -> x -> y -> z -> b
\f g w x y z -> f (g w x y z)
composeFourthFlipped :: forall a b w x y z. (z -> b) -> (w -> x -> y -> b -> a) -> w -> x -> y -> z -> a
splay1 :: forall a b c. (a -> b -> c) -> (a -> b) -> a -> c
s :: forall c b a. (a -> b -> c) -> (a -> b) -> (a -> c)
compose2ThirdFlipped :: forall a b w x y z. (y -> z -> b) -> (w -> x -> b -> a) -> w -> x -> y -> z -> a
iterateN' :: forall f a. Unfoldable1 f => (a -> Maybe a) -> a -> Int -> f a
processSmartQualifiedName :: forall a. (a -> Import -> Boolean) -> (a -> Import -> Import) -> (a -> Import) -> SmartQualifiedName a -> App (QualifiedName a)
traverseScope_ :: forall a b c d f m. Foldable f => Applicative m => (b -> m d) -> (a -> m c) -> Scope b f a -> m Unit
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)
chainl :: forall a m. Alternative m => m a -> m (a -> a -> a) -> a -> m a
chainr :: forall a m. Alternative m => m a -> m (a -> a -> a) -> a -> m a
Parse phrases delimited by a right-associative operator.
bilift2 :: forall w a b c d e f. Biapply w => (a -> b -> c) -> (d -> e -> f) -> w a d -> w b e -> w c f
Lift a function of two arguments.
compose3SecondFlipped :: forall a b w x y z. (x -> y -> z -> b) -> (w -> b -> a) -> w -> x -> y -> z -> a
forkActionState :: forall m s. Plus m => MonadAff m => m (s -> s) -> (s -> m s) -> (s -> m s)
Another common variant on the forkAction pattern.
The action m (s->s) may take a while (should not be restarted) and returns a state modification function
The gui s -> m s takes in the current state, and modifies it on events
Note that forkActionState axn has the shape (s -> m s) -> (s -> m s). So it can be "stacked" to fork multiple actions.
e.g. forkActionState axn1 $ forkActionState axn2 $ forkActionState axn3 $ render initialState.
splat :: forall a b c f. Monad f => (a -> f c) -> (b -> f c) -> Scope b f a -> f c
compose2Third :: forall a b w x y z. (w -> x -> b -> a) -> (y -> z -> b) -> w -> x -> y -> z -> a
\f g w x y z -> f w x (g y z)
memoCompose' :: forall a b c. (a -> Record b) -> (Record b -> c) -> a -> c
everythingM :: forall r a m. Monad m => Monoid r => (Block a -> m r) -> (Inline a -> m r) -> SlamDownP a -> m r
curry :: forall a b. (Pair a -> b) -> a -> a -> b
Turn a function that expects a pair into a function of two arguments.
log4 :: forall a b c d. a -> b -> c -> d -> Effect Unit
mkQ :: forall a b r. Typeable a => Typeable b => r -> (b -> r) -> a -> r
unchanged :: forall a b. (Change a -> b) -> a -> a -> b
Adapt a change function to a positional function. new first.
at1 :: forall r a z. r -> (a -> r) -> a \/ z -> r
at10 :: forall r a b c d e f g h i j z. r -> (j -> r) -> a \/ b \/ c \/ d \/ e \/ f \/ g \/ h \/ i \/ j \/ z -> r
at2 :: forall r a b z. r -> (b -> r) -> a \/ b \/ z -> r
at3 :: forall r a b c z. r -> (c -> r) -> a \/ b \/ c \/ z -> r
at4 :: forall r a b c d z. r -> (d -> r) -> a \/ b \/ c \/ d \/ z -> r
at5 :: forall r a b c d e z. r -> (e -> r) -> a \/ b \/ c \/ d \/ e \/ z -> r
at6 :: forall r a b c d e f z. r -> (f -> r) -> a \/ b \/ c \/ d \/ e \/ f \/ z -> r
at7 :: forall r a b c d e f g z. r -> (g -> r) -> a \/ b \/ c \/ d \/ e \/ f \/ g \/ z -> r
at8 :: forall r a b c d e f g h z. r -> (h -> r) -> a \/ b \/ c \/ d \/ e \/ f \/ g \/ h \/ z -> r
at9 :: forall r a b c d e f g h i z. r -> (i -> r) -> a \/ b \/ c \/ d \/ e \/ f \/ g \/ h \/ i \/ z -> r
curry2 :: forall a b r z. z -> (T3 a b z -> r) -> a -> b -> r
Given a function that accepts at least a 2-tuple, returns a function of 2 arguments.
foldlVariantFRowList :: forall f x rl r z y proxy. FoldlVariantF f x rl r z y => proxy rl -> f -> x -> VariantF r z -> y
memoize3 :: forall a b c d. Tabulate a => Tabulate b => Tabulate c => (a -> b -> c -> d) -> a -> b -> c -> d
Memoize a function of three arguments
applyFourthFlipped :: forall w x y z a. w -> (x -> y -> z -> w -> a) -> x -> y -> z -> a
memoize3 :: forall d c b a. Tabulate a => Tabulate b => Tabulate c => (a -> b -> c -> d) -> a -> b -> c -> d
Memoize a function of three arguments
rotate3d :: forall x y z t. ToNumber x => ToNumber y => ToNumber z => AngleTag t => x -> y -> z -> Measure t -> TransformFunction
foldMapScope :: forall a b m f. Foldable f => Monoid m => (b -> m) -> (a -> m) -> Scope b f a -> m
linkVertexes_ :: forall _l n e v. LayoutNetwork _l n e v => v -> v -> Link_ -> n -> Effect e
setNoTargetPortProperties_ :: forall n g t. IsLinkingBaseTool t => IsNode n => IsGraphObject g => n -> g -> Boolean -> t -> Effect Unit
bind :: forall m a b. Bind m => m a -> (a -> m b) -> m b
discard :: forall a f b. Discard a => Bind f => f a -> (a -> f b) -> f b
composeCoKleisliFlipped :: forall b a w c. Extend w => (w b -> c) -> (w a -> b) -> w a -> c
Backwards co-Kleisli composition.
catchError :: forall e m a. MonadError e m => m a -> (e -> m a) -> m a
caseJsonBoolean :: forall a. a -> (Boolean -> a) -> Json -> a
A simpler version of caseJson which accepts a callback for when the
Json argument was a Boolean, and a default value for all other cases.
caseJsonNull :: forall a. a -> (Unit -> a) -> Json -> a
A simpler version of caseJson which accepts a callback for when the
Json argument was null, and a default value for all other cases.
caseJsonNumber :: forall a. a -> (Number -> a) -> Json -> a
A simpler version of caseJson which accepts a callback for when the
Json argument was a Number, and a default value for all other cases.
caseJsonString :: forall a. a -> (String -> a) -> Json -> a
A simpler version of caseJson which accepts a callback for when the
Json argument was a String, and a default value for all other cases.
these :: forall a b c. (a -> c) -> (b -> c) -> (a -> b -> c) -> These a b -> c
Given functions to handle each constructor, collapse a These value
into single value.
applyOp :: forall event a b. Applicative event => event a -> event (a -> b) -> event b
sampleOnLeft :: forall event a b. IsEvent event => event a -> event (a -> b) -> event b
sampleOnRight :: forall event a b. IsEvent event => event a -> event (a -> b) -> event b
apApplyFlipped :: forall f b a. Apply f => f a -> f (a -> b) -> f b
compose3Second :: forall a b w x y z. (w -> b -> a) -> (x -> y -> z -> b) -> w -> x -> y -> z -> a
\f g w x y z -> f w (g x y z)
handlerWithExtraData :: forall server ex. Servable ex server => ex -> server -> (Request -> Response -> Effect Unit)
sampleOn :: forall event b a. IsEvent event => event a -> event (a -> b) -> event b
bind' :: forall v1 v0 m c. HasBind c m => ObjectOf c v0 => ObjectOf c (m v1) => Restrictable Function c => m v0 -> (v0 -> (m v1)) -> m v1
_foldM :: forall k v m z. (m -> (z -> m) -> m) -> (z -> k -> v -> m) -> m -> Map k v -> m
randomRs :: forall a. RandomR a => a -> a -> Int -> Seed -> Array a
rmatch :: forall f g v l0 r0 l1 r1 h. RMatch f g v l0 r0 l1 r1 => RLProxying h l0 => RLProxying h l1 => h l0 -> h l1 -> f r0 -> g r1 -> v
veither :: forall errorRows a b. (Variant errorRows -> b) -> (a -> b) -> Veither errorRows a -> b
Convert a Veither into a value by defining how to handle each possible value.
Below is an example of the typical usage.
consume :: Veither (a :: Int, b :: String, c :: Boolean) Number -> String
consume v = veither handleError handleSuccess v
where
handleError :: Variant (a :: Int, b :: String, c :: Boolean)
handleError =
case_
# on (Proxy :: Proxy "a") show
# on (Proxy :: Proxy "b") show
# on (Proxy :: Proxy "c") show
handleSuccess :: Number -> String
handleSuccess = show
bind :: forall c b a. HasChain a => a b -> (b -> a c) -> a c
A version of chain with the arguments flipped. This is provided only to
support desugaring do notation. It is not recommended to use explicitly.
controlError :: forall f g e a. ErrorControl f g e => f a -> (e -> g a) -> g a
fairConjunction :: forall b a m. MonadLogic m => m a -> (a -> m b) -> m b
hummingbird :: forall m b a. Bind m => m a -> (a -> m b) -> m b
H combinator - hummingbird
BW(BC)
Λ a b c (a → b → a → c) → a → b → c
λ f x y . f x y x
moveToObject :: forall a b. GameObject a => GameObject b => a -> b -> Number -> PhaserPhysicsPlugin -> Effect PhaserPhysicsPlugin
when :: forall b a m. MonadLogic m => m a -> (a -> m b) -> m b
foldDirOrFile :: forall f b r. IsDirOrFile b => (f Dir -> r) -> (f File -> r) -> f b -> r
Folds over a value that uses DirOrFile to produce a new result.
everything :: forall a r. Monoid r => (Block a -> r) -> (Inline a -> r) -> SlamDownP a -> r
makeRect :: forall a. a -> a -> a -> a -> Rect a
Constructs a Rect from four values
vec4 :: forall a. a -> a -> a -> a -> Vec4 a
on :: forall s r1 r0 l1 l0 g f b a. Cons s a r0 r1 => ROn f g s l0 r0 l1 r1 => RowToList r0 l0 => RowToList r1 l1 => g s -> (a -> b) -> (f r0 -> b) -> f r1 -> b
vfromLeft' :: forall errorRows a b. (Unit -> b) -> (Variant errorRows -> b) -> Veither errorRows a -> b
Same as vfromLeft but the default value is lazy.
alt :: forall f a. Alt f => f a -> (Unit -> f a) -> f a
discard :: forall f a. Alt f => f a -> (Unit -> f a) -> f a
discard :: forall f m a. Parallel f m => Alt f => m a -> (Unit -> m a) -> m a
M2 :: forall a. a -> a -> a -> a -> M2 a
maybeEmpty' :: forall f a b. (Unit -> b) -> (f a -> b) -> MaybeEmpty f a -> b
Quaternion :: forall a. a -> a -> a -> a -> Quaternion a
V4 :: forall a. a -> a -> a -> a -> V4 a
Vector4 :: forall a. a -> a -> a -> a -> Vector4 a
ala :: forall f t a s b. Coercible (f t) (f a) => Newtype t a => Newtype s b => (a -> t) -> ((b -> s) -> f t) -> f a
This combinator is for when you have a higher order function that you want
to use in the context of some newtype - foldMap being a common example:
ala Additive foldMap [1,2,3,4] -- 10
ala Multiplicative foldMap [1,2,3,4] -- 24
ala Conj foldMap [true, false] -- false
ala Disj foldMap [true, false] -- true
whileJust' :: forall b f a m. Monad m => Applicative f => Monoid (f b) => m (Maybe a) -> (a -> m b) -> m (f b)
As long as the supplied Maybe expression returns Just, the loop
body will be called and passed the value contained in the Just.
Results are collected into an arbitrary Applicative monoidal structure.
whileJust' :: forall m f b a. MonadRec m => Applicative f => Monoid (f b) => m (Maybe a) -> (a -> m b) -> m (f b)
As long as the supplied "Maybe" expression returns "Just _", the loop body will be called and passed the value contained in the 'Just'. Results are collected into an arbitrary MonadPlus container.
applyThird :: forall x y z a. (y -> z -> x -> a) -> x -> y -> z -> a
\f x y z -> f y z x
fold :: forall event b a. IsEvent event => (a -> b -> b) -> event a -> b -> event b
discard :: forall a f. Apply f => f Unit -> (Unit -> f a) -> f a
robinstar :: forall d c b a. (b -> c -> a -> d) -> a -> b -> c -> d
R* combinator - robin once removed
CC
Λ a b c d . (b → c → a → d) → a → b → c → d
λ f x y z . f y z x
bitraverse :: forall t f a b c d. Bitraversable t => Applicative f => (a -> f c) -> (b -> f d) -> t a b -> f (t c d)
bitraverseDefault :: forall t f a b c d. Bitraversable t => Applicative f => (a -> f c) -> (b -> f d) -> t a b -> f (t c d)
A default implementation of bitraverse using bisequence and bimap.
Move :: forall a. a -> a -> Int -> Int -> Operation a
fetchImpl :: forall m. MonadUnliftAff m => (Request -> m Response) -> m (WebRequest -> Bun -> Effect (Promise WebResponse))
composeCoKleisli :: forall b a w c. Extend w => (w a -> b) -> (w b -> c) -> w a -> c
Forwards co-Kleisli composition.
withResource :: forall e m r a. MonadError e m => m r -> (r -> m Unit) -> (r -> m a) -> m a
Make sure that a resource is cleaned up in the event of an exception. The release action is called regardless of whether the body action throws or returns.
compose3Flipped :: forall a b x y z. (x -> y -> z -> a) -> (a -> b) -> x -> y -> z -> b
composeThird :: forall a b x y z. (x -> y -> b -> a) -> (z -> b) -> x -> y -> z -> a
\f g x y z -> f x y (g z)
withResource :: forall m r a. MonadNope m => m r -> (r -> m Unit) -> (r -> m a) -> m a
Make sure that a resource is cleaned up in the event of a nope. The release action is called regardless of whether the body action nopes or returns.
mIf :: forall a m. Bind m => m Boolean -> (Unit -> m a) -> (Unit -> m a) -> m a
Given a monadic boolean, run either the first thunked computation or the second.
leftSemimedial :: forall a. Eq a => (a -> a -> a) -> a -> a -> a -> a -> Boolean
medial :: forall a. Eq a => (a -> a -> a) -> a -> a -> a -> a -> Boolean
rightSemimedial :: forall a. Eq a => (a -> a -> a) -> a -> a -> a -> a -> Boolean
semimedial :: forall a. Eq a => (a -> a -> a) -> a -> a -> a -> a -> Boolean
leftSemimedial :: forall a. Eq a => (a -> a -> a) -> a -> a -> a -> a -> Boolean
medial :: forall a. Eq a => (a -> a -> a) -> a -> a -> a -> a -> Boolean
rightSemimedial :: forall a. Eq a => (a -> a -> a) -> a -> a -> a -> a -> Boolean
semimedial :: forall a. Eq a => (a -> a -> a) -> a -> a -> a -> a -> Boolean
apply :: forall a b. (a -> b) -> a -> b
Applies a function to an argument. This is primarily used as the operator
($) which allows parentheses to be omitted in some cases, or as a
natural way to apply a chain of composed functions to a value.
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
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
map :: forall f a b. Functor f => (a -> b) -> f a -> f b
un :: forall t a. Newtype t a => (a -> t) -> t -> a
Given a constructor for a Newtype, this returns the appropriate unwrap
function.
No further results.