diff --git a/CHANGELOG.md b/CHANGELOG.md index 2eac9cf..9456098 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ The changelog is available [on GitHub][2]. Remove `ghc-prim` dependency. - [#488](https://github.com/kowainik/relude/pull/488): Add missing fixity declarations for `elem` and `notElem`. +- [#493](https://github.com/kowainik/relude/pull/493): + Introduce `(.#)`. ## 1.2.2.2 – Aug 5, 2025 diff --git a/src/Relude/Extra/Newtype.hs b/src/Relude/Extra/Newtype.hs index a22db8a..a71b224 100644 --- a/src/Relude/Extra/Newtype.hs +++ b/src/Relude/Extra/Newtype.hs @@ -20,6 +20,7 @@ module Relude.Extra.Newtype , under2 , underF2 , (#.) + , (.#) ) where import Relude @@ -100,11 +101,22 @@ underF2 :: forall n a . Coercible a (n a) => (n a -> n a -> n a) -> (a -> a -> a underF2 = coerce {-# INLINE underF2 #-} -{- | Coercible composition. This function allows to write more efficient -implementations of function compositions over @newtypes@. +{- | Coercible composition where the first argument is an identity function +up to representational equivalence. This function allows to write more +efficient implementations of function compositions over @newtypes@. @since 0.3.0 -} (#.) :: Coercible b c => (b -> c) -> (a -> b) -> (a -> c) (#.) _f = coerce {-# INLINE (#.) #-} + +{- | Coercible composition where the second argument is an identity function +up to representational equivalence. This function allows to write more +efficient implementations of function compositions over @newtypes@. + +@since 1.2.3.0 +-} +(.#) :: Coercible a b => (b -> c) -> (a -> b) -> (a -> c) +(.#) f _g = coerce f +{-# INLINE (.#) #-}