Search results

catchEither :: forall r e' e. Either e r -> (e -> Either e' r) -> Either e' r

catchEither in the error monad corresponds to (>>=) in the success monad

flipSubst :: forall f t a c. Bound t => Monad f => t f a -> (a -> f c) -> t f c
defaultField :: forall a. Either JsonDecodeError (Maybe a) -> a -> Either JsonDecodeError a

Helper for use in combination with .:? to provide default values for optional Object Json fields.

Example usage:

newtype MyType = MyType
  { foo :: String
  , bar :: Maybe Int
  , baz :: Boolean
  }

instance decodeJsonMyType :: DecodeJson MyType where
  decodeJson json = do
    x <- decodeJson json
    foo <- x .: "foo" -- mandatory field
    bar <- x .:? "bar" -- optional field
    baz <- x .:? "baz" .!= false -- optional field with default value of `false`
    pure $ MyType { foo, bar, baz }
intercept :: forall a e g f. ErrorControl f g e => f a -> (e -> a) -> g a
suchThat :: forall m a. MonadRec m => MonadGen m => m a -> (a -> Boolean) -> m a

Creates a generator that repeatedly run another generator until its output matches a given predicate. This will never halt if the predicate always fails.

discard :: forall k a b c. Semigroupoid k => k a b -> (Unit -> k b c) -> k a c
shouldNotSatisfyM_ :: forall m a. MonadThrow Error m => Show a => m a -> (a -> Boolean) -> m Unit
shouldSatisfyM_ :: forall m a. MonadThrow Error m => Show a => m a -> (a -> Boolean) -> m Unit
mapFlipped :: forall f a b. Functor f => f a -> (a -> b) -> f b

mapFlipped is map with its arguments reversed. For example:

[1, 2, 3] <#> \n -> n * n
cmapFlipped :: forall a b f. Contravariant f => f a -> (b -> a) -> f b

cmapFlipped is cmap with its arguments reversed.

flippedMap :: forall f a b. Functor f => f a -> (a -> b) -> f b
map :: forall c f v1 v0. HasMap c f => ObjectOf c v0 => ObjectOf c v1 => c v0 v1 -> f v0 -> f v1
fmodify_ :: forall m r s. MonadEffect m => Refer s r => r -> (s -> s) -> m Unit
catchError :: forall e m a. MonadError e m => m a -> (e -> m a) -> m a
controlError :: forall f g e a. ErrorControl f g e => f a -> (e -> g a) -> g a
shouldNotSatisfy :: forall m t. MonadThrow Error m => Show t => t -> (t -> Boolean) -> m Unit
shouldSatisfy :: forall m t. MonadThrow Error m => Show t => t -> (t -> Boolean) -> m Unit
fmodify :: forall m r s. MonadEffect m => Refer s r => r -> (s -> s) -> m s
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
shouldNotSatisfy :: forall m t. MonadEffect m => Show t => t -> (t -> Boolean) -> m Unit
shouldSatisfy :: forall m t. MonadEffect m => Show t => t -> (t -> Boolean) -> m Unit
freads :: forall m r s a. MonadEffect m => Refer s r => r -> (s -> a) -> m a
modify :: forall v1 v0 s r1 r0 r p l1 l0 g f. Cons s v0 r r0 => Cons s v1 r r1 => RModify p f g s l0 r0 l1 r1 => RowToList r0 l0 => RowToList r1 l1 => g s -> (v0 -> v1) -> p (f r0) (f r1)
assure :: forall a e g f. ErrorControl f g e => Monad f => g a -> (a -> Maybe e) -> f a
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
extendFlipped :: forall b a w. Extend w => w a -> (w a -> b) -> w b

A version of extend with its arguments flipped.

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
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.

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

when :: forall b a m. MonadLogic m => m a -> (a -> m b) -> m b
for1_ :: forall t f a b. Foldable1 t => Apply f => t a -> (a -> f b) -> f Unit

A version of traverse1_ with its arguments flipped.

This can be useful when running an action written using do notation for every element in a data structure:

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_ :: forall f m a. Foldable f => MonadRec m => f a -> (a -> m Unit) -> m Unit

Safely traverse a foldable container.

forM_ :: forall f m a. MonadRec m => Foldable f => f a -> (a -> m Unit) -> m Unit
discard :: forall a f. Apply f => f Unit -> (Unit -> f a) -> f a
when :: forall a m. Monad m => m Boolean -> (Unit -> m a) -> m Unit

Run a given computation when a monadic boolean is true.

applyFirst :: forall a b f. Apply f => f a -> f b -> f a

Combine two effectful actions, keeping only the result of the first.

try :: forall e m a. MonadError e m => m a -> m (Either e a)

Return Right if the given action succeeds, Left if it throws.

sampleOnRight_ :: forall event a b. IsEvent event => event a -> event b -> event a

Create an Event which samples the latest values from the first event at the times when the second event fires, ignoring the values produced by the second event.

sampleOn_ :: forall b a event. IsEvent event => event a -> event b -> event a

Create an Event which samples the latest values from the first event at the times when the second event fires, ignoring the values produced by the second event.

applyFirst :: forall v1 v0 f c. HasApply c f => HasConst c => HasMap c f => ObjectOf c v0 => ObjectOf c v1 => ObjectOf c (c v1 v0) => f v0 -> f v1 -> f v0
bind :: forall a. Semigroup a => a -> (a -> a) -> a
trial :: forall a e g f. ErrorControl f g e => Monad f => f a -> g (Either e a)
applyFlipped :: forall a b. a -> (a -> b) -> b

Applies an argument to a function. This is primarily used as the (#) operator, which allows parentheses to be omitted in some cases, or as a natural way to apply a value to a chain of composed functions.

mulNat :: forall proxy a b c. ProductNat a b c => proxy a -> proxy b -> proxy c
plus :: forall proxy a b c. SumInt a b c => proxy a -> proxy b -> proxy c