summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libraries/base/Data/Function.hs7
-rw-r--r--libraries/base/changelog.md3
-rw-r--r--libraries/base/tests/T18561.hs8
-rw-r--r--libraries/base/tests/all.T1
4 files changed, 17 insertions, 2 deletions
diff --git a/libraries/base/Data/Function.hs b/libraries/base/Data/Function.hs
index b2dc5adbd2..90f5bbc17b 100644
--- a/libraries/base/Data/Function.hs
+++ b/libraries/base/Data/Function.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE ExplicitForAll #-}
+{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE NoImplicitPrelude #-}
@@ -25,7 +27,8 @@ module Data.Function
, on
) where
-import GHC.Base ( ($), (.), id, const, flip )
+import GHC.Base ( ($), (.), id, const, flip, RuntimeRep )
+import GHC.Prim ( TYPE )
infixl 0 `on`
infixl 1 &
@@ -116,7 +119,7 @@ on :: (b -> b -> c) -> (a -> b) -> a -> a -> c
-- "6"
--
-- @since 4.8.0.0
-(&) :: a -> (a -> b) -> b
+(&) :: forall {rep :: RuntimeRep} a (b :: TYPE rep). a -> (a -> b) -> b
x & f = f x
-- $setup
diff --git a/libraries/base/changelog.md b/libraries/base/changelog.md
index 7ba14bf36b..ceec011537 100644
--- a/libraries/base/changelog.md
+++ b/libraries/base/changelog.md
@@ -18,6 +18,9 @@
* Add `Eq1`, `Read1` and `Show1` instance for `Complex`;
add `Eq1/2`, `Ord1/2`, `Show1/2` and `Read1/2` instances for 3 and 4-tuples.
+ * `(Data.Function.&)` is now levity-polymorphic in the function result
+ type, just like `($)`.
+
## 4.15.0.0 *TBA*
* `openFile` now calls the `open` system call with an `interruptible` FFI
diff --git a/libraries/base/tests/T18561.hs b/libraries/base/tests/T18561.hs
new file mode 100644
index 0000000000..505a451136
--- /dev/null
+++ b/libraries/base/tests/T18561.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE MagicHash #-}
+module T18561 where
+
+import GHC.Exts
+import Data.Function
+
+x :: Int
+x = I# ("" & error)
diff --git a/libraries/base/tests/all.T b/libraries/base/tests/all.T
index da828cb2c2..57955e02af 100644
--- a/libraries/base/tests/all.T
+++ b/libraries/base/tests/all.T
@@ -262,3 +262,4 @@ test('T16643', normal, compile_and_run, [''])
test('clamp', normal, compile_and_run, [''])
test('T18642', extra_run_opts('+RTS -T -RTS'), compile_and_run, ['-O2'])
test('T19288', exit_code(1), compile_and_run, [''])
+test('T18561', normal, compile, [''])