Safe Haskell | None |
---|---|
Language | Haskell2010 |
Distribution.Compat.Newtype
Description
Synopsis
- class Newtype o n | n -> o where
- ala :: ( Newtype o n, Newtype o' n') => (o -> n) -> ((o -> n) -> b -> n') -> b -> o'
- alaf :: ( Newtype o n, Newtype o' n') => (o -> n) -> ((a -> n) -> b -> n') -> (a -> o) -> b -> o'
- pack' :: Newtype o n => (o -> n) -> o -> n
- unpack' :: Newtype o n => (o -> n) -> n -> o
Documentation
class Newtype o n | n -> o where Source #
The
FunctionalDependencies
version of
Newtype
type-class.
Since Cabal-3.0 class arguments are in a different order than in
newtype
package.
This change is to allow usage with
DeriveAnyClass
(and
DerivingStrategies
, in GHC-8.2).
Unfortunately one have to repeat inner type.
newtype New = New Old deriving anyclass (Newtype Old)
Another approach would be to use
TypeFamilies
(and possibly
compute inner type using
GHC.Generics
), but we think
FunctionalDependencies
version gives cleaner type signatures.
Minimal complete definition
Nothing
Methods
Instances
Newtype String FilePathNT Source # | |
Defined in Distribution.Parsec.Newtypes |
|
Newtype String Token' Source # | |
Newtype String Token Source # | |
Newtype a ( Product a) Source # | |
Newtype a ( Sum a) Source # | |
Newtype a ( Identity a) Source # | |
Newtype a ( MQuoted a) Source # | |
Newtype [a] ( List sep wrapper a) Source # | |
Newtype ( Set a) ( Set' sep wrapper a) Source # | |
Newtype ( Either Version VersionRange ) SpecVersion Source # | |
Defined in Distribution.Parsec.Newtypes Methods pack :: Either Version VersionRange -> SpecVersion Source # unpack :: SpecVersion -> Either Version VersionRange Source # |
|
Newtype ( Either License License ) SpecLicense Source # | |
Defined in Distribution.Parsec.Newtypes |
|
Newtype ( CompilerFlavor , VersionRange ) TestedWith Source # | |
Defined in Distribution.Parsec.Newtypes Methods pack :: ( CompilerFlavor , VersionRange ) -> TestedWith Source # unpack :: TestedWith -> ( CompilerFlavor , VersionRange ) Source # |
|
Newtype (a -> a) ( Endo a) Source # | |
ala :: ( Newtype o n, Newtype o' n') => (o -> n) -> ((o -> n) -> b -> n') -> b -> o' Source #
>>>
ala Sum foldMap [1, 2, 3, 4 :: Int]
10
Note: the user supplied function for the newtype is ignored .
>>>
ala (Sum . (+1)) foldMap [1, 2, 3, 4 :: Int]
10