Skip to content

Instantly share code, notes, and snippets.

@jjant
Created August 22, 2018 23:41
Show Gist options
  • Select an option

  • Save jjant/231cf8990573d1f8774543c39d7ffb59 to your computer and use it in GitHub Desktop.

Select an option

Save jjant/231cf8990573d1f8774543c39d7ffb59 to your computer and use it in GitHub Desktop.
type alias Table =
List EmployeeFromDb
lookUpEmployee : Id -> Table -> Maybe EmployeeApp
lookUpEmployee id table =
let
maybePerson =
List.find (\(Employee employee _) -> employee.id == id) table
employees =
table
|> List.filter (\(Employee _ employerId) -> employerId == id)
|> List.map (\e -> replace () e)
in
Maybe.map (\employeeFromDb -> replace employees employeeFromDb) maybePerson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment