Network.RemoteData
- Package
- purescript-remotedata
- Repository
- krisajenkins/purescript-remotedata
#RemoteData Source
data RemoteData e a
A datatype representing fetched data.
If you find yourself continually using Maybe (Either e a)
to
represent data loaded from an external source, or you have a
habit of shuffling errors away to where they can be quietly
ignored, consider using this. It makes it easier to represent the
real state of a remote data fetch and handle it properly.
For more on the motivation, take a look at the blog post How Elm Slays A UI Antipattern. This is a port of that original Elm module.
Constructors
Instances
Generic (RemoteData e a) _
(Eq e, Eq a) => Eq (RemoteData e a)
Functor (RemoteData e)
(Show e, Show a) => Show (RemoteData e a)
Bifunctor RemoteData
Apply (RemoteData e)
If both values are
Success
, the function is applied. If both areFailure
, the first failure is returned.Bind (RemoteData e)
Applicative (RemoteData e)
Monad (RemoteData e)
MonadThrow e (RemoteData e)
MonadError e (RemoteData e)
Foldable (RemoteData e)
Traversable (RemoteData e)
Bifoldable RemoteData
Bitraversable RemoteData
#toMaybe Source
toMaybe :: forall e a. RemoteData e a -> Maybe a
Convert a RemoteData
to a Maybe
.
#fromMaybe Source
fromMaybe :: forall e a. Maybe a -> RemoteData e a
Convert a Maybe
to RemoteData
.
#fromEither Source
fromEither :: forall e a. Either e a -> RemoteData e a
Convert an Either
to RemoteData
#maybe Source
maybe :: forall e a b. b -> (a -> b) -> RemoteData e a -> b
Takes a default value, a function, and a RemoteData
value. If
the data is Success
, apply the function to the value, otherwise
return the default.
See also withDefault
.
#withDefault Source
withDefault :: forall e a. a -> RemoteData e a -> a
If the RemoteData
has been successfully loaded, return that,
otherwise return a default value.
#_Failure Source
_Failure :: forall a e. Prism' (RemoteData e a) e
#_Success Source
_Success :: forall a e. Prism' (RemoteData e a) a
#isNotAsked Source
isNotAsked :: forall e a. RemoteData e a -> Boolean
Simple predicate.
#isLoading Source
isLoading :: forall e a. RemoteData e a -> Boolean
Simple predicate.
#isFailure Source
isFailure :: forall e a. RemoteData e a -> Boolean
Simple predicate.
#isSuccess Source
isSuccess :: forall e a. RemoteData e a -> Boolean
Simple predicate.
- Modules
- Network.
RemoteData
Maps functions to the
Failure
andSuccess
values.