Skip to content

Instantly share code, notes, and snippets.

@marick
Created February 21, 2017 23:40
Show Gist options
  • Save marick/59466293a3f40052fab8c5e206d630a2 to your computer and use it in GitHub Desktop.
Save marick/59466293a3f40052fab8c5e206d630a2 to your computer and use it in GitHub Desktop.
{-! If there is an original animal to work with, partially apply the
given function to that animal. The given function is expected to
transform some value with that function. If there is no animal,
`identity` is used.
Typically used to make transformations of Model that mean nothing
if there's no original animal. (Very likely an "impossible" case.)
model |> Form.givenOriginalAnimal form upsertAnimal |> noCmd
-}
givenOriginalAnimal : Form -> (Animal -> anything -> anything)
-> (anything -> anything)
givenOriginalAnimal form f =
case form.originalAnimal of
Nothing -> identity
Just animal -> f animal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment