Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Synopsis
Documentation
class Newtype n o | n -> o where Source #
The FunctionalDependencies
version of Newtype
type-class.
Note: for actual newtypes the implementation can be
pack = coerce; unpack = coerce
. We don't have default implementation,
because Cabal
have to support older than base >= 4.7
compilers.
Also, Newtype
could witness a non-structural isomorphism.
Instances
Newtype FilePathNT String # | |
pack :: String -> FilePathNT Source # unpack :: FilePathNT -> String Source # | |
Newtype FreeText String # | |
Newtype Token' String # | |
Newtype Token String # | |
Newtype TestedWith (CompilerFlavor, VersionRange) # | |
pack :: (CompilerFlavor, VersionRange) -> TestedWith Source # unpack :: TestedWith -> (CompilerFlavor, VersionRange) Source # | |
Newtype SpecVersion (Either Version VersionRange) # | |
pack :: Either Version VersionRange -> SpecVersion Source # unpack :: SpecVersion -> Either Version VersionRange Source # | |
Newtype (Identity a) a # | |
Newtype (Sum a) a # | |
Newtype (Product a) a # | |
Newtype (MQuoted a) a # | |
Newtype (Endo a) (a -> a) # | |
Newtype (List sep wrapper a) [a] # | |
ala :: (Newtype n o, Newtype n' o') => (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