Search results

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
P prelude M Control.Applicative
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
P prelude M Control.Monad
applyFirst :: forall a b f. Apply f => f a -> f b -> f a

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

P prelude M Control.Apply
applySecond :: forall a b f. Apply f => f a -> f b -> f b

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

P prelude M Control.Apply
voidRight :: forall f a b. Functor f => a -> f b -> f a

Ignore the return value of a computation, using the specified return value instead.

P prelude M Data.Functor
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.

P prelude M Data.Function
op :: forall t a. Newtype t a => (a -> t) -> t -> a

Deprecated previous name of un.

P newtype M Data.Newtype
un :: forall t a. Newtype t a => (a -> t) -> t -> a

Given a constructor for a Newtype, this returns the appropriate unwrap function.

P newtype M Data.Newtype
voidLeft :: forall f a b. Functor f => f a -> b -> f b

A version of voidRight with its arguments flipped.

P prelude M Data.Functor
duplicate :: forall a w. Extend w => w a -> w (w a)

Duplicate a comonadic context.

duplicate is dual to Control.Bind.join.

P control M Control.Extend
fix :: forall l. Lazy l => (l -> l) -> l

fix defines a value as the fixed point of a function.

The Lazy instance allows us to generate the result lazily.

P control M Control.Lazy
const :: forall a b. a -> b -> a

Returns its first argument and ignores its second.

const 1 "hello" = 1
P prelude M Data.Function
gcd :: forall a. Eq a => EuclideanRing a => a -> a -> a

The greatest common divisor of two values.

P prelude M Data.EuclideanRing
lcm :: forall a. Eq a => EuclideanRing a => a -> a -> a

The least common multiple of two values.

P prelude M Data.EuclideanRing
leftDiv :: forall a. DivisionRing a => a -> a -> a

Left division, defined as leftDiv a b = recip b * a. Left and right division are distinct in this module because a DivisionRing is not necessarily commutative.

If the type a is also a EuclideanRing, then this function is equivalent to div from the EuclideanRing class. When working abstractly, div should generally be preferred, unless you know that you need your code to work with noncommutative rings.

P prelude M Data.DivisionRing
max :: forall a. Ord a => a -> a -> a

Take the maximum of two values. If they are considered equal, the first argument is chosen.

P prelude M Data.Ord
min :: forall a. Ord a => a -> a -> a

Take the minimum of two values. If they are considered equal, the first argument is chosen.

P prelude M Data.Ord
rightDiv :: forall a. DivisionRing a => a -> a -> a

Right division, defined as rightDiv a b = a * recip b. Left and right division are distinct in this module because a DivisionRing is not necessarily commutative.

If the type a is also a EuclideanRing, then this function is equivalent to div from the EuclideanRing class. When working abstractly, div should generally be preferred, unless you know that you need your code to work with noncommutative rings.

P prelude M Data.DivisionRing
abs :: forall a. Ord a => Ring a => a -> a

The absolute value function. abs x is defined as if x >= zero then x else negate x.

P prelude M Data.Ord
negate :: forall a. Ring a => a -> a

negate x can be used as a shorthand for zero - x.

P prelude M Data.Ring
signum :: forall a. Ord a => Ring a => a -> a

The sign function; always evaluates to either one or negate one. For any x, we should have signum x * abs x == x.

P prelude M Data.Ord
unsafeCoerce :: forall a b. a -> b

A highly unsafe function, which can be used to persuade the type system that any type is the same as any other type. When using this function, it is your (that is, the caller's) responsibility to ensure that the underlying representation for both types is the same.

One application for this function is to avoid doing work that you know is a no-op because of newtypes. For example, if you have an Array (Conj a) and you want an Array (Disj a), you could do Data.Array.map (runConj >>> Disj), but this performs an unnecessary traversal. unsafeCoerce accomplishes the same for free.

It is highly recommended to define specializations of this function rather than using it as-is. For example:

mapConjToDisj :: forall a. Array (Conj a) -> Array (Disj a)
mapConjToDisj = unsafeCoerce

This way, you won't have any nasty surprises due to the inferred type being different to what you expected.

P unsafe-coerce M Unsafe.Coerce
unsafePartial :: forall a. (Partial => a) -> a

Discharge a partiality constraint, unsafely.

P partial M Partial.Unsafe
crash :: forall a. Partial => a

A partial function which crashes on any input with a default message.

P partial M Partial