Created
September 1, 2018 23:20
-
-
Save Chadtech/d8cd73ecbea57ed752c81c17917179fa to your computer and use it in GitHub Desktop.
This file contains hidden or 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
type alias Fields = | |
{ data1 : Maybe String | |
, data2 : Maybe Int | |
, data3 : Maybe Bool | |
} | |
type alias Submission = | |
{ data1 : String | |
, data2 : Int | |
, data3 : Bool | |
} | |
type Error | |
= Error | |
validate : Fields -> Result Error Submission | |
validate fields = | |
Submission | |
|> Ok | |
|> give fields.data1 | |
|> give fields.data2 | |
|> give fields.data3 | |
give : Maybe a -> Result Error (a -> b) -> Result Error b | |
give maybeValue result = | |
case maybeValue of | |
Just value -> | |
case result of | |
Ok ctor -> | |
Ok (ctor value) | |
Err err -> | |
Err err | |
Nothing -> | |
Err Error |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment