Module

Neon.Data

Package
purescript-neon
Repository
tfausak/purescript-neon

Data types and constructors.

#exception Source

exception :: String -> Error

Creates an exception with the given message.

exception "example"

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

    The Functor instance allows functions to transform the contents of a Just with the <$> operator:

    f <$> Just x == Just (f x)
    

    Nothing values are left untouched:

    f <$> Nothing == Nothing
    
  • Apply Maybe

    The Apply instance allows functions contained within a Just to transform a value contained within a Just using the apply operator:

    Just f <*> Just x == Just (f x)
    

    Nothing values are left untouched:

    Just f <*> Nothing == Nothing
    Nothing <*> Just x == Nothing
    

    Combining Functor's <$> with Apply's <*> can be used transform a pure function to take Maybe-typed arguments so f :: a -> b -> c becomes f :: 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 is Nothing means the whole result becomes Nothing also:

    f <$> Nothing <*> Just y == Nothing
    f <$> Just x <*> Nothing == Nothing
    f <$> Nothing <*> Nothing == Nothing
    
  • Applicative Maybe

    The Applicative instance enables lifting of values into Maybe with the pure or return function (return is an alias for pure):

    pure x :: Maybe _ == Just x
    return x :: Maybe _ == Just x
    

    Combining Functor's <$> with Apply's <*> and Applicative's pure can be used to pass a mixture of Maybe and non-Maybe typed values to a function that does not usually expect them, by using pure for any value that is not already Maybe typed:

    f <$> Just x <*> pure y == Just (f x y)
    

    Even though pure = Just it is recommended to use pure in situations like this as it allows the choice of Applicative to be changed later without having to go through and replace Just with a new constructor.

  • Alt Maybe

    The Alt instance allows for a choice to be made between two Maybe values with the <|> operator, where the first Just encountered is taken.

    Just x <|> Just y == Just x
    Nothing <|> Just y == Just y
    Nothing <|> Nothing == Nothing
    
  • Plus Maybe

    The Plus instance provides a default Maybe value:

    empty :: Maybe _ == Nothing
    
  • Alternative Maybe

    The Alternative instance guarantees that there are both Applicative and Plus instances for Maybe.

  • Bind Maybe

    The Bind instance allows sequencing of Maybe values and functions that return a Maybe by using the >>= operator:

    Just x >>= f = f x
    Nothing >>= f = Nothing
    
  • Monad Maybe

    The Monad instance guarantees that there are both Applicative and Bind instances for Maybe. This also enables the do 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 of Maybe values and functions that accept a Maybe 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 <> on Maybe values whenever there is a Semigroup instance for the type the Maybe 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 allows Maybe values to be rendered as a string with show whenever there is an Show instance for the type the Maybe contains.

Re-exports from Data.Tuple

#Tuple Source

data Tuple a b

A simple product type for wrapping a pair of component values.

Constructors

Instances

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