Network.RemoteData
- Package
- purescript-remotedata
- Repository
- krisajenkins/purescript-remotedata
#RemoteData Source
data RemoteData e aA 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 RemoteDataApply (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 RemoteDataBitraversable RemoteData
#toMaybe Source
toMaybe :: forall a e. RemoteData e a -> Maybe aConvert a RemoteData to a Maybe.
#fromMaybe Source
fromMaybe :: forall a e. Maybe a -> RemoteData e aConvert a Maybe to RemoteData.
#fromEither Source
fromEither :: forall a e. Either e a -> RemoteData e aConvert an Either to RemoteData
#maybe Source
maybe :: forall b a e. b -> (a -> b) -> RemoteData e a -> bTakes 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 a e. a -> RemoteData e a -> aIf the RemoteData has been successfully loaded, return that,
otherwise return a default value.
#_Failure Source
_Failure :: forall e a. Prism' (RemoteData e a) e#_Success Source
_Success :: forall e a. Prism' (RemoteData e a) a#isNotAsked Source
isNotAsked :: forall a e. RemoteData e a -> BooleanSimple predicate.
#isLoading Source
isLoading :: forall a e. RemoteData e a -> BooleanSimple predicate.
#isFailure Source
isFailure :: forall a e. RemoteData e a -> BooleanSimple predicate.
#isSuccess Source
isSuccess :: forall a e. RemoteData e a -> BooleanSimple predicate.
- Modules
- Network.
RemoteData
Maps functions to the
FailureandSuccessvalues.