elm-community / maybe-extra

Convenience functions for working with Maybe.

Home Page:http://package.elm-lang.org/packages/elm-community/maybe-extra/latest

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Proposal for a flipped infix version of map

wild-lotus opened this issue · comments

What do you think of a convenience flipped infix version of map?

(?>) : Maybe a -> (a -> b) -> Maybe b
(?>) maybe f =
    Maybe.map f maybe

I find it useful for example to query maybe records :

maybeRecord : Maybe { a : a }
maybeRecord = ...
maybeRecord ?> .a

I think it seems pretty reasonable. Any other opinions?

In any case, it's worth making a PR.

Whats the use case where this would be useful?

Seems like as easily as you would write maybeRecord ?> .id you could write Maybe.map .id maybeRecord

No longer possible with 0.19's restrictions on infix functions.