Skip to content

Commit 1270758

Browse files
Clarify docs for flip (#271)
* Clarify docs for `flip` * Keep previous but altered example
1 parent a0aa536 commit 1270758

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Bugfixes:
1212

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

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

src/Data/Function.purs

+7-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,15 @@ import Data.Boolean (otherwise)
1313
import Data.Ord ((<=))
1414
import Data.Ring ((-))
1515

16-
-- | Flips the order of the arguments to a function of two arguments.
16+
-- | Given a function that takes two arguments, applies the arguments
17+
-- | to the function in a swapped order.
1718
-- |
1819
-- | ```purescript
19-
-- | flip const 1 2 = const 2 1 = 2
20+
-- | flip append "1" "2" == append "2" "1" == "21"
21+
-- |
22+
-- | const 1 "two" == 1
23+
-- |
24+
-- | flip const 1 "two" == const "two" 1 == "two"
2025
-- | ```
2126
flip :: forall a b c. (a -> b -> c) -> b -> a -> c
2227
flip f b a = f a b

0 commit comments

Comments
 (0)