Skip to content

Instantly share code, notes, and snippets.

@jinjor
Created December 2, 2018 12:45
Show Gist options
  • Save jinjor/4c18236f89c555a64041a81af3355cd8 to your computer and use it in GitHub Desktop.
Save jinjor/4c18236f89c555a64041a81af3355cd8 to your computer and use it in GitHub Desktop.
type alias OriginalFoo =
{ barText : Maybe String
, mustNum : Int
}
type alias Foo =
{ barText : String
, mustNum : Int
}
type alias Xxx =
{ barText : String
}
getFoo : Task x Foo
getFoo =
getOriginalFoo
|> Task.andThen
(\{ barText, mustNum } ->
case barText of
Just t ->
Task.succeed (Foo t mustNum)
Nothing ->
getXxx
|> Task.map
(\x ->
Foo x.barText mustNum
)
)
getOriginalFoo : Task x OriginalFoo
getOriginalFoo =
Debug.todo ""
getXxx : Task x Xxx
getXxx =
Debug.todo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment