Unwraps value from newtype.
newtype Size = Size Int deriving Showun @Int (Size 5)5un (Size 5) == length ['a', 'x', 'b']False
:: a typeCtrl KGHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27
Modulerelude-1.2.0.0Haskell2010
SPDX-License-Identifier : MIT Maintainer : Kowainik xrom.xkov@gmail.com Stability : Stable Portability : Portable
Functions to ease work with newtypes.
Unwraps value from newtype.
newtype Size = Size Int deriving Showun @Int (Size 5)5un (Size 5) == length ['a', 'x', 'b']False
Wraps value to newtype. Behaves exactly as un but has more meaningful
name in case you need to convert some value to newtype.
newtype Flag = Flag Bool deriving (Show, Eq)wrap False == Flag TrueFalse
Applies function to the content of newtype. This function is not supposed
to be used on newtypes that are created with the help of smart constructors.
newtype Foo = Foo Bool deriving Showunder not (Foo True)Foo Falsenewtype Bar = Bar String deriving Showunder (filter (== 'a')) (Bar "abacaba")Bar "aaaa"
Lift binary function for newtypes to work over underlying newtype
representation.
under2 @(Sum Int) (<>) (3 :: Int) 47under2 @All (<>) True FalseFalse
Version of under2 that works on newtypes parametrized by their
representation. Provided for convenience.
underF2 @Sum (<>) (3 :: Int) 47underF2 @Max (<>) 'p' 't''t'
Coercible composition. This function allows to write more efficient
implementations of function compositions over newtypes.