implement and test Elm inspired foldp