do : Maybe a -> (a -> Maybe b) -> Maybe b
do mb continuation =
Maybe.andThen continuation mb
getSomething acc key dict = -- acc: accumulator
do (Dict.get key dict) <| \value1 ->
do (Dict.get value1 dict) <| \value3 ->
(dict, Just value3 :: acc)
getSomethingElse acc key dict =
do (Dict.get key dict) <| \ values ->
do (Dict.get value1 dict) <| \value2 ->
(dict, Just value2 :: acc])
do (getSomething [] "Lisa" dict) <| \(dict, acc) -> getSomethingElse acc "Tom" dict -- return (dict, [ Just value2, Just value3])
In another way how can I make it composable?
Is the code above making sense?
Is there a better way?