Created
October 17, 2017 12:50
-
-
Save toretore/54606e935753cc34011c755161445785 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Customers exposing (Error, Customers, init, toLoading, toFailure, toSuccess) | |
type alias Error = String | |
type Customers | |
= NotAsked | |
| Loading (Maybe Error) (Maybe (List Customer)) | |
| Failure Error (Maybe (List Customer)) | |
| Success (List Customer) | |
init : Customers | |
init = NotAsked | |
toLoading : Customers -> Customers | |
toLoading current = | |
case current of | |
NotAsked -> Loading Nothing Nothing | |
Loading me ml -> Loading me ml | |
Failure e ml -> Loading (Just e) ml | |
Success l -> Loading Nothing (Just l) | |
toFailure : Error -> Customers -> Customers | |
toFailure error current = | |
case current of | |
NotAsked -> Failure error Nothing | |
Loading _ ml -> Failure error ml | |
Failure _ ml -> Failure error ml | |
Success l -> Failure error (Just l) | |
toSuccess : LIst Customer -> Customers -> Customers | |
toSuccess list current = | |
Success list |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment