Skip to content

Clarify docs for flip #271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Bugfixes:

Other improvements:
- Changed `unit`'s FFI representation from `{}` to `undefined` (#267 by @JordanMartinez)
- Clarify docs for `flip` (#271 by @JordanMartinez)

## [v5.0.1](https://github.com/purescript/purescript-prelude/releases/tag/v5.0.1) - 2021-05-11

Expand Down
9 changes: 7 additions & 2 deletions src/Data/Function.purs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,15 @@ import Data.Boolean (otherwise)
import Data.Ord ((<=))
import Data.Ring ((-))

-- | Flips the order of the arguments to a function of two arguments.
-- | Given a function that takes two arguments, applies the arguments
-- | to the function in a swapped order.
-- |
-- | ```purescript
-- | flip const 1 2 = const 2 1 = 2
-- | flip append "1" "2" == append "2" "1" == "21"
-- |
-- | const 1 "two" == 1
-- |
-- | flip const 1 "two" == const "two" 1 == "two"
-- | ```
flip :: forall a b c. (a -> b -> c) -> b -> a -> c
flip f b a = f a b
Expand Down