Neon.Data
- Package
- purescript-neon
- Repository
- tfausak/purescript-neon
Data types and constructors.
Re-exports from Control.Monad.Eff.Exception
#Error
data Error :: Type
The type of JavaScript errors
Instances
Show Error
Re-exports from Data.List
#List
data List a
Constructors
Nil
Cons a (List a)
Instances
(Show a) => Show (List a)
(Eq a) => Eq (List a)
Eq1 List
(Ord a) => Ord (List a)
Ord1 List
Semigroup (List a)
Monoid (List a)
Functor List
FunctorWithIndex Int List
Foldable List
FoldableWithIndex Int List
Unfoldable List
Traversable List
TraversableWithIndex Int List
Apply List
Applicative List
Bind List
Monad List
Alt List
Plus List
Alternative List
MonadZero List
MonadPlus List
Extend List
Re-exports from Data.Maybe
#Maybe Source
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
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
orreturn
function (return
is an alias forpure
):pure x :: Maybe _ == Just x return 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')))
MonadZero Maybe
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 <<= Just 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)
(Eq a) => Eq (Maybe a)
Eq1 Maybe
(Ord a) => Ord (Maybe a)
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.
Re-exports from Data.Tuple
#Tuple Source
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)
(Eq a) => Eq1 (Tuple a)
(Ord a, Ord b) => Ord (Tuple a b)
(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)
Invariant (Tuple a)
Bifunctor Tuple
(Semigroup a) => Apply (Tuple a)
The
Functor
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)
Biapply Tuple
(Monoid a) => Applicative (Tuple a)
Biapplicative Tuple
(Semigroup a) => Bind (Tuple a)
(Monoid a) => Monad (Tuple a)
Extend (Tuple a)
Comonad (Tuple a)
(Lazy a, Lazy b) => Lazy (Tuple a b)
Foldable (Tuple a)
Bifoldable Tuple
Traversable (Tuple a)
Bitraversable Tuple
(TypeEquals a Unit) => Distributive (Tuple a)
Re-exports from Prelude
#Unit
data Unit :: Type
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.
Instances
Show Unit
#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
LT
GT
EQ
Instances
Eq Ordering
Semigroup Ordering
Show Ordering
#unit
unit :: Unit
unit
is the sole inhabitant of the Unit
type.
Re-exports from Type.Proxy
- Modules
- Neon
- Neon.
Class - Neon.
Class. HasAdd - Neon.
Class. HasAnd - Neon.
Class. HasApply - Neon.
Class. HasBottom - Neon.
Class. HasChain - Neon.
Class. HasCompare - Neon.
Class. HasDivide - Neon.
Class. HasEqual - Neon.
Class. HasFilter - Neon.
Class. HasFromArray - Neon.
Class. HasFromInt - Neon.
Class. HasGreater - Neon.
Class. HasInspect - Neon.
Class. HasLess - Neon.
Class. HasMap - Neon.
Class. HasMultiply - Neon.
Class. HasNot - Neon.
Class. HasOne - Neon.
Class. HasOr - Neon.
Class. HasPower - Neon.
Class. HasPure - Neon.
Class. HasReduce - Neon.
Class. HasRemainder - Neon.
Class. HasSubtract - Neon.
Class. HasToArray - Neon.
Class. HasToInt - Neon.
Class. HasTop - Neon.
Class. HasTraverse - Neon.
Class. HasZero - Neon.
Data - Neon.
Effect - Neon.
Helper - Neon.
Operator - Neon.
Primitive - Neon.
Primitive. Char - Neon.
Primitive. Function - Neon.
Primitive. Int - Neon.
Primitive. Number
The
Functor
instance allows functions to transform the contents of aJust
with the<$>
operator:Nothing
values are left untouched: