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
plusNat :: forall proxy a b c. SumNat a b c => proxy a -> proxy b -> proxy c
powNat :: forall proxy a b c. ExponentiationNat a b c => proxy a -> proxy b -> proxy c
> powNat d2 d3
8 -- : NProxy D8

a raised to the power of b a^b = c

prod :: forall proxy a b c. ProductInt a b c => proxy a -> proxy b -> proxy c
concat :: forall xs ys zs lproxy. Concat xs ys zs => lproxy xs -> lproxy ys -> lproxy zs
drop :: forall n xs ys lproxy iproxy. Drop n xs ys => iproxy n -> lproxy xs -> lproxy ys
map :: forall f xs ys fproxy kproxy lproxy. Map f xs ys => fproxy f -> kproxy xs -> lproxy ys
take :: forall n xs ys lproxy iproxy. Take n xs ys => iproxy n -> lproxy xs -> lproxy ys
zip :: forall x y z lproxy. Zip x y z => lproxy x -> lproxy y -> lproxy z
getOrAlt :: forall v s r' r l h g f. Alternative h => Cons s v r' r => RowToList r l => RGetOrAlt f g s l r => g s -> f r -> h v
_call :: forall b a. a -> (a -> b) -> b
applyFirst :: forall a d. Syntax d => d a -> d Unit -> d a

This variant of <*> ignores its right result. In contrast to its counterpart derived from the Apply class, the ignored parts have type d Unit rather than d b because otherwise information relevant for pretty-printing would be lost.

extract :: forall r x a. TypeEquals r x => r -> (x -> a) -> a
nmapFlipped :: forall b a fb fa. NestedFunctor fa fb a b => fa -> (a -> b) -> fb

t

t :: forall b a. a -> (a -> b) -> b

Reverse application which is probably exist inside Lens module

t

t :: forall b a. a -> (a -> b) -> b
thrush :: forall b a. a -> (a -> b) -> b

T combinator - thrush

CI

Λ a b . a → (a → b) → b

λ x f . f x

trace :: forall a b. DebugWarning => a -> (Unit -> b) -> b

Log any PureScript value to the console for debugging purposes and then return a value. This will log the value's underlying representation for low-level debugging, so it may be desireable to show the value first.

The return value is thunked so it is not evaluated until after the message has been printed, to preserve a predictable console output.

For example:

doSomething = trace "Hello" \_ -> ... some value or computation ...
delay :: forall m a b. Delay m => a -> (a -> m b) -> m b
bindFlipped :: forall v1 v0 m c. HasBind c m => ObjectOf c v0 => ObjectOf c (m v1) => c v0 (m v1) -> m v0 -> m v1
applyTuple :: forall f a b. Apply f => f a -> f b -> f (a /\ b)
bind :: forall f a. Alt f => f a -> (f a -> f a) -> f a
bind :: forall f m a. Parallel f m => Alt f => m a -> (m a -> m a) -> m a
discard :: forall a. Semigroup a => a -> (Unit -> a) -> a
sbind :: forall a. Semigroup a => a -> (Unit -> a) -> a

Utility function so you can define formats with do notation. For example:

myFormat = do
  ifNegative $ literal "("
  currencyCode
  literal space
  amount
  ifNegative $ literal ")"
  where discard = sbind
alt :: forall f a. Alt f => f a -> f a -> f a
choose :: forall m a. MonadGen m => m a -> m a -> m a

Creates a generator that outputs a value chosen from one of two existing existing generators with even probability.

untilM_ :: forall a m. Monad m => m a -> m Boolean -> m Unit

Execute an action repeatedly until the condition expression returns true. The condition is evaluated after the loop body. Ignores the results of loop body execution.

untilM_ :: forall m a. MonadRec m => m a -> m Boolean -> m Unit

Execute an action repeatedly until the condition expression returns true. The condition is evaluated after the loop body. Ignores the results of loop body execution.

whileM_ :: forall m a. Monad m => m Boolean -> m a -> m Unit

Execute an action repeatedly as long as the given boolean expression returns true. The condition is evaluated before the loop body. Ignores the results of loop body execution.

whileM_ :: forall m a. MonadRec m => m Boolean -> m a -> m Unit

Execute an action repeatedly as long as the given boolean expression returns true. The condition is evaluated before the loop body. Ignores the results of loop body execution.

addU :: forall repr u. UnitArith repr => repr u -> repr u -> repr u

Add two values with the same unit

addUnitOp :: forall repr u. UnitArith repr => repr u -> repr u -> repr u
subU :: forall repr u. UnitArith repr => repr u -> repr u -> repr u

Subtract two values with the same unit

subUnitOp :: forall repr u. UnitArith repr => repr u -> repr u -> repr u
max1 :: forall f a. Ord1 f => f a -> f a -> f a
min1 :: forall f a. Ord1 f => f a -> f a -> f a
onIntegrityError :: forall m a. MonadError PGError m => m a -> m a -> m a
add :: forall f a. Additive f => Semiring a => f a -> f a -> f a

Vector addition

alt :: forall f a. Alternative f => f a -> f a -> f a
dappend :: forall cnt a. Diff cnt => cnt a -> cnt a -> cnt a
diff :: forall p d a. Affine p d => Ring a => p a -> p a -> d a

The vector from the first point to the second.

fromFoldableL :: forall a c f. Foldable f => Consable c => c a -> f a -> c a

Conversion from Foldable to Consable using foldl.

fromFoldableL [] [1,2,3,4]  == [4,3,2,1]
fromFoldableL [0] [1,2,3,4] == [4,3,2,1,0]
fromFoldableR :: forall a c f. Foldable f => Consable c => c a -> f a -> c a

Conversion from Foldable to Consable using foldr.

fromFoldableR [] [1,2,3,4]  == [1,2,3,4]
fromFoldableR [5] [1,2,3,4] == [1,2,3,4,5]
interleave :: forall m a. MonadLogic m => m a -> m a -> m a
moveBy :: forall p d a. Affine p d => Semiring a => p a -> d a -> p a

Add a vector to a point.

moveByNeg :: forall p d a. Affine p d => Ring a => p a -> d a -> p a

Subtract a vector from a point.

shouldNotSatisfyM :: forall m a. MonadThrow Error m => Show a => a -> (a -> m Boolean) -> m Unit
shouldSatisfyM :: forall m a. MonadThrow Error m => Show a => a -> (a -> m Boolean) -> m Unit
sub :: forall f a. Additive f => Ring a => f a -> f a -> f a

Vector subtraction

yup :: forall m a. MonadNope m => m a -> m a -> m a
applySecond :: forall a b f. Apply f => f a -> f b -> f b

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

lfor :: forall t b c a f. Bitraversable t => Applicative f => t a b -> (a -> f c) -> f (t c b)
sampleOnLeft_ :: forall event a b. IsEvent event => event a -> event b -> event b
applySecond :: forall v1 v0 f c. HasApply c f => HasConst c => HasIdentity c => HasMap c f => ObjectOf c v0 => ObjectOf c v1 => ObjectOf c (c v1 v1) => ObjectOf c (c v0 (c v1 v1)) => ObjectOf c (c (c v1 v1) (c v0 (c v1 v1))) => f v0 -> f v1 -> f v1
forkAction :: forall m a b. MonadEffect m => MonadAff m => Plus m => m a -> (m a -> m b) -> m b

A common pattern - running a long running action and keeping the GUI responsive Because the action can't be restarted on every gui event, we must fork it off in the beginning

mmapFlipped :: forall a b f g. Functor f => Functor g => f (g a) -> (a -> b) -> f (g b)
whileJust_ :: forall m b a. Monad m => m (Maybe a) -> (a -> m b) -> m Unit

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

whileJust_ :: forall m b a. MonadRec m => m (Maybe a) -> (a -> m b) -> m Unit

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

gate :: forall a event. IsEvent event => event Boolean -> event a -> event a

Sample the events that are fired while a boolean event is true. Note that, until the boolean event fires, it will be assumed to be false, and events will be blocked.

gate :: forall event a. IsEvent event => event Boolean -> event a -> event a

Sample the events that are fired while a boolean event is true. Note that, until the boolean event fires, it will be assumed to be false, and events will be blocked.

addClassesM :: forall m n f. MonadEffect m => ElementOp n => Foldable f => f String -> m n -> m n
applySecond :: forall a d. Syntax d => d Unit -> d a -> d a

This variant of <*> ignores its left result. In contrast to its counterpart derived from the Apply class, the ignored parts have type d Unit rather than d b because otherwise information relevant for pretty-printing would be lost.

bind :: forall k a b c. Semigroupoid k => k a b -> (k a b -> k b c) -> k a c
chainM :: forall m a. Testable m => m Element -> m a -> m a

Used in its operator form >>, this function chains two DOM operations together, taking the output of the first operation and making it context of the second one. For example:

buttonInsideDiv <- find "div" >> find "button"
inputValue <- find "input" >> attr "value"
rmCssM :: forall m n f. MonadEffect m => HTMLElementOp n => Foldable f => f String -> m n -> m n
setAttrsM :: forall e f m. Foldable f => ElementOp e => MonadEffect m => f (String /\ String) -> m e -> m e

Sets the attributes of an element. Existing attributes of the same names are overwritten. New names create new attributes. The element is returned.

setCssM :: forall m n f. MonadEffect m => HTMLElementOp n => Foldable f => f (String /\ String) -> m n -> m n
bindMaybe :: forall m a b. Bind m => Compactable m => m a -> (a -> m (Maybe b)) -> m b
andM :: forall m. Monad m => m Boolean -> m Boolean -> m Boolean
orM :: forall m. Monad m => m Boolean -> m Boolean -> m Boolean
add :: forall repr. NumExpr repr => repr Number -> repr Number -> repr Number
add :: forall repr. DataDSL repr => repr Number -> repr Number -> repr Number

Arithmetic operations (from NumExpr)

addOp :: forall repr. NumExpr repr => repr Number -> repr Number -> repr Number
addOp :: forall repr. DataDSL repr => repr Number -> repr Number -> repr Number
and :: forall repr. BoolExpr repr => repr Boolean -> repr Boolean -> repr Boolean
and :: forall repr. DataDSL repr => repr Boolean -> repr Boolean -> repr Boolean

Boolean operations (from BoolExpr)

and_ :: forall repr. BoolExpr repr => repr Boolean -> repr Boolean -> repr Boolean

Boolean AND (use underscore to avoid keyword conflict)

append :: forall repr. StringExpr repr => repr String -> repr String -> repr String

Concatenate strings

label = _name `append` text ": " `append` _value
atan2 :: forall repr. TrigExpr repr => repr Number -> repr Number -> repr Number
atan2 :: forall repr. TrigExpr repr => repr Number -> repr Number -> repr Number
atan2 :: forall repr. TrigDSL repr => repr Number -> repr Number -> repr Number
concat :: forall repr. StringExpr repr => repr String -> repr String -> repr String
concat :: forall repr. DataDSL repr => repr String -> repr String -> repr String

String operations (from StringExpr)

concatOp :: forall repr. StringExpr repr => repr String -> repr String -> repr String
concatOp :: forall repr. DataDSL repr => repr String -> repr String -> repr String
div :: forall repr. NumExpr repr => repr Number -> repr Number -> repr Number
div :: forall repr. DataDSL repr => repr Number -> repr Number -> repr Number
dividedBy :: forall repr. NumExpr repr => repr Number -> repr Number -> repr Number

Divide expressions

divOp :: forall repr. NumExpr repr => repr Number -> repr Number -> repr Number
divOp :: forall repr. DataDSL repr => repr Number -> repr Number -> repr Number
minus :: forall repr. NumExpr repr => repr Number -> repr Number -> repr Number

Subtract expressions

mul :: forall repr. NumExpr repr => repr Number -> repr Number -> repr Number
mul :: forall repr. DataDSL repr => repr Number -> repr Number -> repr Number
mulOp :: forall repr. NumExpr repr => repr Number -> repr Number -> repr Number
mulOp :: forall repr. DataDSL repr => repr Number -> repr Number -> repr Number
or :: forall repr. BoolExpr repr => repr Boolean -> repr Boolean -> repr Boolean
or :: forall repr. DataDSL repr => repr Boolean -> repr Boolean -> repr Boolean
or_ :: forall repr. BoolExpr repr => repr Boolean -> repr Boolean -> repr Boolean

Boolean OR

plus :: forall repr. NumExpr repr => repr Number -> repr Number -> repr Number

Add two expressions

total = _x `plus` _y
offset = _index `times` num 40.0 `plus` num 50.0
sub :: forall repr. NumExpr repr => repr Number -> repr Number -> repr Number