Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
This module reexports the six necessary type classes that every Rule
type must support.
You can use this module to define new rules without depending on the binary
, deepseq
and hashable
packages.
Documentation
Conversion of values to readable String
s.
Derived instances of Show
have the following properties, which
are compatible with derived instances of Read
:
- The result of
show
is a syntactically correct Haskell expression containing only constants, given the fixity declarations in force at the point where the type is declared. It contains only the constructor names defined in the data type, parentheses, and spaces. When labelled constructor fields are used, braces, commas, field names, and equal signs are also used. - If the constructor is defined to be an infix operator, then
showsPrec
will produce infix applications of the constructor. - the representation will be enclosed in parentheses if the
precedence of the top-level constructor in
x
is less thand
(associativity is ignored). Thus, ifd
is0
then the result is never surrounded in parentheses; ifd
is11
it is always surrounded in parentheses, unless it is an atomic expression. - If the constructor is defined using record syntax, then
show
will produce the record-syntax form, with the fields given in the same order as the original declaration.
For example, given the declarations
infixr 5 :^: data Tree a = Leaf a | Tree a :^: Tree a
the derived instance of Show
is equivalent to
instance (Show a) => Show (Tree a) where showsPrec d (Leaf m) = showParen (d > app_prec) $ showString "Leaf " . showsPrec (app_prec+1) m where app_prec = 10 showsPrec d (u :^: v) = showParen (d > up_prec) $ showsPrec (up_prec+1) u . showString " :^: " . showsPrec (up_prec+1) v where up_prec = 5
Note that right-associativity of :^:
is ignored. For example,
produces the stringshow
(Leaf 1 :^: Leaf 2 :^: Leaf 3)"Leaf 1 :^: (Leaf 2 :^: Leaf 3)"
.
:: Int | the operator precedence of the enclosing
context (a number from |
-> a | the value to be converted to a |
-> ShowS |
Convert a value to a readable String
.
showsPrec
should satisfy the law
showsPrec d x r ++ s == showsPrec d x (r ++ s)
Derived instances of Read
and Show
satisfy the following:
That is, readsPrec
parses the string produced by
showsPrec
, and delivers the value that showsPrec
started with.
Show Bool | |
Show Char | Since: 2.1 |
Show Int | Since: 2.1 |
Show Int8 | Since: 2.1 |
Show Int16 | Since: 2.1 |
Show Int32 | Since: 2.1 |
Show Int64 | Since: 2.1 |
Show Integer | Since: 2.1 |
Show Natural | Since: 4.8.0.0 |
Show Ordering | |
Show Word | Since: 2.1 |
Show Word8 | Since: 2.1 |
Show Word16 | Since: 2.1 |
Show Word32 | Since: 2.1 |
Show Word64 | Since: 2.1 |
Show CallStack | Since: 4.9.0.0 |
Show SomeTypeRep | Since: 4.10.0.0 |
Show () | |
Show TyCon | Since: 2.1 |
Show Module | Since: 4.9.0.0 |
Show TrName | Since: 4.9.0.0 |
Show Handle | Since: 4.1.0.0 |
Show HandleType | Since: 4.1.0.0 |
Show Void | Since: 4.8.0.0 |
Show DataType | |
Show Constr | Since: 4.0.0.0 |
Show DataRep | |
Show ConstrRep | |
Show Fixity | |
Show Version | |
Show HandlePosn | Since: 4.1.0.0 |
Show PatternMatchFail | Since: 4.0 |
Show RecSelError | Since: 4.0 |
Show RecConError | Since: 4.0 |
Show RecUpdError | Since: 4.0 |
Show NoMethodError | Since: 4.0 |
Show TypeError | Since: 4.9.0.0 |
Show NonTermination | Since: 4.0 |
Show NestedAtomically | Since: 4.0 |
Show ThreadId | Since: 4.2.0.0 |
Show BlockReason | |
Show ThreadStatus | |
Show Dynamic | Since: 2.1 |
Show CDev | |
Show CIno | |
Show CMode | |
Show COff | |
Show CPid | |
Show CSsize | |
Show CGid | |
Show CNlink | |
Show CUid | |
Show CCc | |
Show CSpeed | |
Show CTcflag | |
Show CRLim | |
Show CBlkSize | |
Show CBlkCnt | |
Show CClockId | |
Show CFsBlkCnt | |
Show CFsFilCnt | |
Show CId | |
Show CKey | |
Show CTimer | |
Show Fd | |
Show BlockedIndefinitelyOnMVar | Since: 4.1.0.0 |
Show BlockedIndefinitelyOnSTM | Since: 4.1.0.0 |
Show Deadlock | Since: 4.1.0.0 |
Show AllocationLimitExceeded | Since: 4.7.1.0 |
Show CompactionFailed | Since: 4.10.0.0 |
Show AssertionFailed | Since: 4.1.0.0 |
Show SomeAsyncException | Since: 4.7.0.0 |
Show AsyncException | Since: 4.1.0.0 |
Show ArrayException | Since: 4.1.0.0 |
Show ExitCode | |
Show IOErrorType | Since: 4.1.0.0 |
Show BufferMode | |
Show Newline | |
Show NewlineMode | |
Show SeekMode | |
Show MaskingState | |
Show IOException | Since: 4.1.0.0 |
Show ErrorCall | Since: 4.0.0.0 |
Show ArithException | Since: 4.0.0.0 |
Show All | |
Show Any | |
Show Fixity | |
Show Associativity | |
Show SourceUnpackedness | |
Show SourceStrictness | |
Show DecidedStrictness | |
Show CChar | |
Show CSChar | |
Show CUChar | |
Show CShort | |
Show CUShort | |
Show CInt | |
Show CUInt | |
Show CLong | |
Show CULong | |
Show CLLong | |
Show CULLong | |
Show CBool | |
Show CFloat | |
Show CDouble | |
Show CPtrdiff | |
Show CSize | |
Show CWchar | |
Show CSigAtomic | |
Show CClock | |
Show CTime | |
Show CUSeconds | |
Show CSUSeconds | |
Show CIntPtr | |
Show CUIntPtr | |
Show CIntMax | |
Show CUIntMax | |
Show WordPtr | |
Show IntPtr | |
Show IOMode | |
Show Fingerprint | Since: 4.7.0.0 |
Show Lexeme | |
Show Number | |
Show GeneralCategory | |
Show SomeException | Since: 3.0 |
Show SrcLoc | |
Show ShortByteString | |
Show ByteString | |
Show ByteString | |
Show Clock | |
Show TimeSpec | |
Show IntSet | |
Show DirectoryType | |
Show Permissions | |
Show XdgDirectory | |
Show Timeout | |
Show StdStream | |
Show CmdSpec | |
Show CreateProcess | |
Show Color | |
Show Flot | |
Show StdGen | |
Show Padding | |
Show DateFormatSpec | |
Show ZonedTime | |
Show LocalTime | |
Show TimeOfDay | |
Show TimeZone | |
Show NominalDiffTime | |
Show CmdOption # | |
Show ShakeException # | |
Show Resource # | |
Show Progress # | |
Show Verbosity # | |
Show ShakeOptions # | |
Show Change # | |
Show Lint # | |
Show Rebuild # | |
Show RunChanged # | |
Show CmdArgument # | |
Show a => Show [a] | Since: 2.1 |
Show a => Show (Maybe a) | |
Show a => Show (Ratio a) | Since: 2.0.1 |
Show (Ptr a) | Since: 2.1 |
Show (FunPtr a) | Since: 2.1 |
Show p => Show (Par1 p) | |
Show a => Show (Complex a) | |
HasResolution a => Show (Fixed a) | Since: 2.1 |
Show a => Show (Min a) | |
Show a => Show (Max a) | |
Show a => Show (First a) | |
Show a => Show (Last a) | |
Show m => Show (WrappedMonoid m) | |
Show a => Show (Option a) | |
Show a => Show (NonEmpty a) | |
Show a => Show (ZipList a) | |
Show a => Show (Identity a) | This instance would be equivalent to the derived instances of the
Since: 4.8.0.0 |
Show a => Show (Dual a) | |
Show a => Show (Sum a) | |
Show a => Show (Product a) | |
Show a => Show (First a) | |
Show a => Show (Last a) | |
Show a => Show (Down a) | |
Show a => Show (Decoder a) | |
Show a => Show (IntMap a) | |
Show a => Show (Tree a) | |
Show a => Show (Seq a) | |
Show a => Show (ViewL a) | |
Show a => Show (ViewR a) | |
Show a => Show (Set a) | |
Show a => Show (RB a) | |
Show a => Show (Hashed a) | |
Show a => Show (Array a) | |
Show a => Show (HashSet a) | |
Show a => Show (UserRule a) # | |
(Show b, Show a) => Show (Either a b) | |
Show (V1 k p) | |
Show (U1 k p) | Since: 4.9.0.0 |
Show (TypeRep k a) | |
(Show a, Show b) => Show (a, b) | Since: 2.1 |
Show (ST s a) | Since: 2.1 |
(Ix ix, Show ix, Show e, IArray UArray e) => Show (UArray ix e) | |
(Ix a, Show a, Show b) => Show (Array a b) | Since: 2.1 |
(Show b, Show a) => Show (Arg a b) | |
Show (Proxy k s) | Since: 4.7.0.0 |
(Show k, Show a) => Show (Map k a) | |
(Show1 m, Show a) => Show (MaybeT m a) | |
(Show1 m, Show a) => Show (ListT m a) | |
(Show k, Show v) => Show (HashMap k v) | |
Show (f p) => Show (Rec1 k f p) | |
Show (URec k Char p) | |
Show (URec k Double p) | |
Show (URec k Float p) | |
Show (URec k Int p) | |
Show (URec k Word p) | |
(Show a, Show b, Show c) => Show (a, b, c) | Since: 2.1 |
Show a => Show (Const k a b) | This instance would be equivalent to the derived instances of the
Since: 4.8.0.0 |
Show (f a) => Show (Alt k f a) | |
Show ((:~:) k a b) | |
(Show w, Show1 m, Show a) => Show (WriterT w m a) | |
(Show w, Show1 m, Show a) => Show (WriterT w m a) | |
(Show1 f, Show a) => Show (IdentityT * f a) | |
(Show e, Show1 m, Show a) => Show (ExceptT e m a) | |
(Show e, Show1 m, Show a) => Show (ErrorT e m a) | |
Show c => Show (K1 k i c p) | |
(Show (g p), Show (f p)) => Show ((:+:) k f g p) | |
(Show (g p), Show (f p)) => Show ((:*:) k f g p) | |
(Show a, Show b, Show c, Show d) => Show (a, b, c, d) | Since: 2.1 |
(Show1 f, Show1 g, Show a) => Show (Product * f g a) | Since: 4.9.0.0 |
(Show1 f, Show1 g, Show a) => Show (Sum * f g a) | Since: 4.9.0.0 |
Show ((:~~:) k1 k2 a b) | Since: 4.10.0.0 |
Show (f p) => Show (M1 k i c f p) | |
Show (f (g p)) => Show ((:.:) k2 k1 f g p) | |
(Show a, Show b, Show c, Show d, Show e) => Show (a, b, c, d, e) | Since: 2.1 |
(Show1 f, Show1 g, Show a) => Show (Compose * * f g a) | Since: 4.9.0.0 |
(Show a, Show b, Show c, Show d, Show e, Show f) => Show (a, b, c, d, e, f) | Since: 2.1 |
(Show a, Show b, Show c, Show d, Show e, Show f, Show g) => Show (a, b, c, d, e, f, g) | Since: 2.1 |
(Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h) => Show (a, b, c, d, e, f, g, h) | Since: 2.1 |
(Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i) => Show (a, b, c, d, e, f, g, h, i) | Since: 2.1 |
(Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j) => Show (a, b, c, d, e, f, g, h, i, j) | Since: 2.1 |
(Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k) => Show (a, b, c, d, e, f, g, h, i, j, k) | Since: 2.1 |
(Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k, Show l) => Show (a, b, c, d, e, f, g, h, i, j, k, l) | Since: 2.1 |
(Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k, Show l, Show m) => Show (a, b, c, d, e, f, g, h, i, j, k, l, m) | Since: 2.1 |
(Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k, Show l, Show m, Show n) => Show (a, b, c, d, e, f, g, h, i, j, k, l, m, n) | Since: 2.1 |
(Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k, Show l, Show m, Show n, Show o) => Show (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) | Since: 2.1 |
The class Typeable
allows a concrete representation of a type to
be calculated.
typeRep#
The Eq
class defines equality (==
) and inequality (/=
).
All the basic datatypes exported by the Prelude are instances of Eq
,
and Eq
may be derived for any datatype whose constituents are also
instances of Eq
.
Eq Bool | |
Eq Char | |
Eq Double | |
Eq Float | |
Eq Int | |
Eq Int8 | Since: 2.1 |
Eq Int16 | Since: 2.1 |
Eq Int32 | Since: 2.1 |
Eq Int64 | Since: 2.1 |
Eq Integer | |
Eq Natural | |
Eq Ordering | |
Eq Word | |
Eq Word8 | Since: 2.1 |
Eq Word16 | Since: 2.1 |
Eq Word32 | Since: 2.1 |
Eq Word64 | Since: 2.1 |
Eq SomeTypeRep | |
Eq () | |
Eq TyCon | |
Eq Module | |
Eq TrName | |
Eq Handle | Since: 4.1.0.0 |
Eq BigNat | |
Eq Void | Since: 4.8.0.0 |
Eq SpecConstrAnnotation | |
Eq Constr | Equality of constructors Since: 4.0.0.0 |
Eq DataRep | |
Eq ConstrRep | |
Eq Fixity | |
Eq Unique | |
Eq Version | Since: 2.1 |
Eq HandlePosn | Since: 4.1.0.0 |
Eq ThreadId | Since: 4.2.0.0 |
Eq BlockReason | |
Eq ThreadStatus | |
Eq CDev | |
Eq CIno | |
Eq CMode | |
Eq COff | |
Eq CPid | |
Eq CSsize | |
Eq CGid | |
Eq CNlink | |
Eq CUid | |
Eq CCc | |
Eq CSpeed | |
Eq CTcflag | |
Eq CRLim | |
Eq CBlkSize | |
Eq CBlkCnt | |
Eq CClockId | |
Eq CFsBlkCnt | |
Eq CFsFilCnt | |
Eq CId | |
Eq CKey | |
Eq CTimer | |
Eq Fd | |
Eq Errno | Since: 2.1 |
Eq AsyncException | |
Eq ArrayException | |
Eq ExitCode | |
Eq IOErrorType | Since: 4.1.0.0 |
Eq BufferMode | |
Eq Newline | |
Eq NewlineMode | |
Eq IODeviceType | |
Eq SeekMode | |
Eq MaskingState | |
Eq IOException | Since: 4.1.0.0 |
Eq ErrorCall | |
Eq ArithException | |
Eq All | |
Eq Any | |
Eq Fixity | |
Eq Associativity | |
Eq SourceUnpackedness | |
Eq SourceStrictness | |
Eq DecidedStrictness | |
Eq CChar | |
Eq CSChar | |
Eq CUChar | |
Eq CShort | |
Eq CUShort | |
Eq CInt | |
Eq CUInt | |
Eq CLong | |
Eq CULong | |
Eq CLLong | |
Eq CULLong | |
Eq CBool | |
Eq CFloat | |
Eq CDouble | |
Eq CPtrdiff | |
Eq CSize | |
Eq CWchar | |
Eq CSigAtomic | |
Eq CClock | |
Eq CTime | |
Eq CUSeconds | |
Eq CSUSeconds | |
Eq CIntPtr | |
Eq CUIntPtr | |
Eq CIntMax | |
Eq CUIntMax | |
Eq WordPtr | |
Eq IntPtr | |
Eq IOMode | |
Eq Fingerprint | |
Eq Lexeme | |
Eq Number | |
Eq GeneralCategory | |
Eq SrcLoc | |
Eq ShortByteString | |
Eq ByteString | |
Eq ByteString | |
Eq Clock | |
Eq TimeSpec | |
Eq IntSet | |
Eq DirectoryType | |
Eq Permissions | |
Eq XdgDirectory | |
Eq Timeout | |
Eq StdStream | |
Eq CmdSpec | |
Eq CreateProcess | |
Eq Flot | |
Eq LocalTime | |
Eq TimeOfDay | |
Eq TimeZone | |
Eq UniversalTime | |
Eq UTCTime | |
Eq NominalDiffTime | |
Eq Day | |
Eq CmdOption # | |
Eq Resource # | |
Eq Progress # | |
Eq Verbosity # | |
Eq Change # | |
Eq Lint # | |
Eq Rebuild # | |
Eq RunChanged # | |
Eq CmdArgument # | |
Eq a => Eq [a] | |
Eq a => Eq (Maybe a) | |
Eq a => Eq (Ratio a) | |
Eq (StablePtr a) | Since: 2.1 |
Eq (Ptr a) | |
Eq (FunPtr a) | |
Eq p => Eq (Par1 p) | |
Eq a => Eq (Complex a) | |
Eq (Fixed a) | |
Eq a => Eq (Min a) | |
Eq a => Eq (Max a) | |
Eq a => Eq (First a) | |
Eq a => Eq (Last a) | |
Eq m => Eq (WrappedMonoid m) | |
Eq a => Eq (Option a) | |
Eq a => Eq (NonEmpty a) | |
Eq (Chan a) | |
Eq (StableName a) | Since: 2.1 |
Eq a => Eq (ZipList a) | |
Eq a => Eq (Identity a) | |
Eq (TVar a) | Since: 4.8.0.0 |
Eq (IORef a) | Since: 4.1.0.0 |
Eq a => Eq (Dual a) | |
Eq a => Eq (Sum a) | |
Eq a => Eq (Product a) | |
Eq a => Eq (First a) | |
Eq a => Eq (Last a) | |
Eq a => Eq (Down a) | |
Eq (MVar a) | Since: 4.1.0.0 |
Eq a => Eq (IntMap a) | |
Eq a => Eq (Tree a) | |
Eq a => Eq (Seq a) | |
Eq a => Eq (ViewL a) | |
Eq a => Eq (ViewR a) | |
Eq a => Eq (Set a) | |
Eq a => Eq (Hashed a) | Uses precomputed hash to detect inequality faster |
Eq a => Eq (Array a) | |
Eq a => Eq (HashSet a) | |
Eq a => Eq (UserRule a) # | |
(Eq b, Eq a) => Eq (Either a b) | |
Eq (V1 k p) | |
Eq (U1 k p) | Since: 4.9.0.0 |
Eq (TypeRep k a) | Since: 2.1 |
(Eq a, Eq b) => Eq (a, b) | |
(Ix ix, Eq e, IArray UArray e) => Eq (UArray ix e) | |
(Ix i, Eq e) => Eq (Array i e) | Since: 2.1 |
Eq a => Eq (Arg a b) | Since: 4.9.0.0 |
Eq (Proxy k s) | Since: 4.7.0.0 |
Eq (STRef s a) | Since: 2.1 |
(Eq k, Eq a) => Eq (Map k a) | |
Eq (MutableArray s a) | |
(Eq1 m, Eq a) => Eq (MaybeT m a) | |
(Eq1 m, Eq a) => Eq (ListT m a) | |
(Eq v, Eq k) => Eq (Leaf k v) | |
(Eq k, Eq v) => Eq (HashMap k v) | |
Eq (f p) => Eq (Rec1 k f p) | |
Eq (URec k (Ptr ()) p) | |
Eq (URec k Char p) | |
Eq (URec k Double p) | |
Eq (URec k Float p) | |
Eq (URec k Int p) | |
Eq (URec k Word p) | |
(Eq a, Eq b, Eq c) => Eq (a, b, c) | |
Eq (STUArray s i e) | |
Eq (STArray s i e) | Since: 2.1 |
Eq a => Eq (Const k a b) | |
Eq (f a) => Eq (Alt k f a) | |
Eq ((:~:) k a b) | |
(Eq w, Eq1 m, Eq a) => Eq (WriterT w m a) | |
(Eq w, Eq1 m, Eq a) => Eq (WriterT w m a) | |
(Eq1 f, Eq a) => Eq (IdentityT * f a) | |
(Eq e, Eq1 m, Eq a) => Eq (ExceptT e m a) | |
(Eq e, Eq1 m, Eq a) => Eq (ErrorT e m a) | |
Eq c => Eq (K1 k i c p) | |
(Eq (g p), Eq (f p)) => Eq ((:+:) k f g p) | |
(Eq (g p), Eq (f p)) => Eq ((:*:) k f g p) | |
(Eq a, Eq b, Eq c, Eq d) => Eq (a, b, c, d) | |
(Eq1 f, Eq1 g, Eq a) => Eq (Product * f g a) | Since: 4.9.0.0 |
(Eq1 f, Eq1 g, Eq a) => Eq (Sum * f g a) | Since: 4.9.0.0 |
Eq ((:~~:) k1 k2 a b) | Since: 4.10.0.0 |
Eq (f p) => Eq (M1 k i c f p) | |
Eq (f (g p)) => Eq ((:.:) k2 k1 f g p) | |
(Eq a, Eq b, Eq c, Eq d, Eq e) => Eq (a, b, c, d, e) | |
(Eq1 f, Eq1 g, Eq a) => Eq (Compose * * f g a) | Since: 4.9.0.0 |
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f) => Eq (a, b, c, d, e, f) | |
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g) => Eq (a, b, c, d, e, f, g) | |
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h) => Eq (a, b, c, d, e, f, g, h) | |
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i) => Eq (a, b, c, d, e, f, g, h, i) | |
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j) => Eq (a, b, c, d, e, f, g, h, i, j) | |
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k) => Eq (a, b, c, d, e, f, g, h, i, j, k) | |
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k, Eq l) => Eq (a, b, c, d, e, f, g, h, i, j, k, l) | |
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k, Eq l, Eq m) => Eq (a, b, c, d, e, f, g, h, i, j, k, l, m) | |
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k, Eq l, Eq m, Eq n) => Eq (a, b, c, d, e, f, g, h, i, j, k, l, m, n) | |
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k, Eq l, Eq m, Eq n, Eq o) => Eq (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) | |
The class of types that can be converted to a hash value.
Minimal implementation: hashWithSalt
.
hashWithSalt :: Int -> a -> Int infixl 0 #
Return a hash value for the argument, using the given salt.
The general contract of hashWithSalt
is:
- If two values are equal according to the
==
method, then applying thehashWithSalt
method on each of the two values must produce the same integer result if the same salt is used in each case. - It is not required that if two values are unequal
according to the
==
method, then applying thehashWithSalt
method on each of the two values must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal values may improve the performance of hashing-based data structures. - This method can be used to compute different hash values for
the same input by providing a different salt in each
application of the method. This implies that any instance
that defines
hashWithSalt
must make use of the salt in its implementation.
Like hashWithSalt
, but no salt is used. The default
implementation uses hashWithSalt
with some default salt.
Instances might want to implement this method to provide a more
efficient implementation than the default implementation.
The Binary
class provides put
and get
, methods to encode and
decode a Haskell value to a lazy ByteString
. It mirrors the Read
and
Show
classes for textual representation of Haskell types, and is
suitable for serialising Haskell values to disk, over the network.
For decoding and generating simple external binary formats (e.g. C
structures), Binary may be used, but in general is not suitable
for complex protocols. Instead use the Put
and Get
primitives
directly.
Instances of Binary should satisfy the following property:
decode . encode == id
That is, the get
and put
methods should be the inverse of each
other. A range of instances are provided for basic Haskell types.
Encode a value in the Put monad.
Decode a value in the Get monad
Encode a list of values in the Put monad. The default implementation may be overridden to be more efficient but must still have the same encoding format.
A class of types that can be fully evaluated.
Since: 1.1.0.0
rnf
should reduce its argument to normal form (that is, fully
evaluate all sub-components), and then return '()'.
Generic
NFData
deriving
Starting with GHC 7.2, you can automatically derive instances
for types possessing a Generic
instance.
Note: Generic1
can be auto-derived starting with GHC 7.4
{-# LANGUAGE DeriveGeneric #-} import GHC.Generics (Generic, Generic1) import Control.DeepSeq data Foo a = Foo a String deriving (Eq, Generic, Generic1) instance NFData a => NFData (Foo a) instance NFData1 Foo data Colour = Red | Green | Blue deriving Generic instance NFData Colour
Starting with GHC 7.10, the example above can be written more
concisely by enabling the new DeriveAnyClass
extension:
{-# LANGUAGE DeriveGeneric, DeriveAnyClass #-} import GHC.Generics (Generic) import Control.DeepSeq data Foo a = Foo a String deriving (Eq, Generic, Generic1, NFData, NFData1) data Colour = Red | Green | Blue deriving (Generic, NFData)
Compatibility with previous deepseq
versions
Prior to version 1.4.0.0, the default implementation of the rnf
method was defined as
rnf
a =seq
a ()
However, starting with deepseq-1.4.0.0
, the default
implementation is based on DefaultSignatures
allowing for
more accurate auto-derived NFData
instances. If you need the
previously used exact default rnf
method implementation
semantics, use
instance NFData Colour where rnf x = seq x ()
or alternatively
instance NFData Colour where rnf = rwhnf
or
{-# LANGUAGE BangPatterns #-} instance NFData Colour where rnf !_ = ()
NFData Bool | |
NFData Char | |
NFData Double | |
NFData Float | |
NFData Int | |
NFData Int8 | |
NFData Int16 | |
NFData Int32 | |
NFData Int64 | |
NFData Integer | |
NFData Natural | Since: 1.4.0.0 |
NFData Ordering | |
NFData Word | |
NFData Word8 | |
NFData Word16 | |
NFData Word32 | |
NFData Word64 | |
NFData CallStack | Since: 1.4.2.0 |
NFData () | |
NFData TyCon | NOTE: Only defined for Since: 1.4.0.0 |
NFData Void | Since: 1.4.0.0 |
NFData Unique | Since: 1.4.0.0 |
NFData Version | Since: 1.3.0.0 |
NFData ThreadId | Since: 1.4.0.0 |
NFData ExitCode | Since: 1.4.2.0 |
NFData TypeRep | NOTE: Only defined for Since: 1.4.0.0 |
NFData All | Since: 1.4.0.0 |
NFData Any | Since: 1.4.0.0 |
NFData CChar | Since: 1.4.0.0 |
NFData CSChar | Since: 1.4.0.0 |
NFData CUChar | Since: 1.4.0.0 |
NFData CShort | Since: 1.4.0.0 |
NFData CUShort | Since: 1.4.0.0 |
NFData CInt | Since: 1.4.0.0 |
NFData CUInt | Since: 1.4.0.0 |
NFData CLong | Since: 1.4.0.0 |
NFData CULong | Since: 1.4.0.0 |
NFData CLLong | Since: 1.4.0.0 |
NFData CULLong | Since: 1.4.0.0 |
NFData CBool | Since: 1.4.3.0 |
NFData CFloat | Since: 1.4.0.0 |
NFData CDouble | Since: 1.4.0.0 |
NFData CPtrdiff | Since: 1.4.0.0 |
NFData CSize | Since: 1.4.0.0 |
NFData CWchar | Since: 1.4.0.0 |
NFData CSigAtomic | Since: 1.4.0.0 |
NFData CClock | Since: 1.4.0.0 |
NFData CTime | Since: 1.4.0.0 |
NFData CUSeconds | Since: 1.4.0.0 |
NFData CSUSeconds | Since: 1.4.0.0 |
NFData CFile | Since: 1.4.0.0 |
NFData CFpos | Since: 1.4.0.0 |
NFData CJmpBuf | Since: 1.4.0.0 |
NFData CIntPtr | Since: 1.4.0.0 |
NFData CUIntPtr | Since: 1.4.0.0 |
NFData CIntMax | Since: 1.4.0.0 |
NFData CUIntMax | Since: 1.4.0.0 |
NFData Fingerprint | Since: 1.4.0.0 |
NFData SrcLoc | Since: 1.4.2.0 |
NFData ShortByteString | |
NFData ByteString | |
NFData ByteString | |
NFData IntSet | |
NFData ZonedTime | |
NFData LocalTime | |
NFData TimeOfDay | |
NFData TimeZone | |
NFData UniversalTime | |
NFData UTCTime | |
NFData NominalDiffTime | |
NFData Day | |
NFData RunChanged # | |
NFData a => NFData [a] | |
NFData a => NFData (Maybe a) | |
NFData a => NFData (Ratio a) | |
NFData (Ptr a) | Since: 1.4.2.0 |
NFData (FunPtr a) | Since: 1.4.2.0 |
NFData a => NFData (Complex a) | |
NFData (Fixed a) | Since: 1.3.0.0 |
NFData a => NFData (Min a) | Since: 1.4.2.0 |
NFData a => NFData (Max a) | Since: 1.4.2.0 |
NFData a => NFData (First a) | Since: 1.4.2.0 |
NFData a => NFData (Last a) | Since: 1.4.2.0 |
NFData m => NFData (WrappedMonoid m) | Since: 1.4.2.0 |
NFData a => NFData (Option a) | Since: 1.4.2.0 |
NFData a => NFData (NonEmpty a) | Since: 1.4.2.0 |
NFData (StableName a) | Since: 1.4.0.0 |
NFData a => NFData (ZipList a) | Since: 1.4.0.0 |
NFData a => NFData (Identity a) | Since: 1.4.0.0 |
NFData (IORef a) | NOTE: Only strict in the reference and not the referenced value. Since: 1.4.2.0 |
NFData a => NFData (Dual a) | Since: 1.4.0.0 |
NFData a => NFData (Sum a) | Since: 1.4.0.0 |
NFData a => NFData (Product a) | Since: 1.4.0.0 |
NFData a => NFData (First a) | Since: 1.4.0.0 |
NFData a => NFData (Last a) | Since: 1.4.0.0 |
NFData a => NFData (Down a) | Since: 1.4.0.0 |
NFData (MVar a) | NOTE: Only strict in the reference and not the referenced value. Since: 1.4.2.0 |
NFData a => NFData (IntMap a) | |
NFData a => NFData (Tree a) | |
NFData a => NFData (Seq a) | |
NFData a => NFData (FingerTree a) | |
NFData a => NFData (Digit a) | |
NFData a => NFData (Node a) | |
NFData a => NFData (Elem a) | |
NFData a => NFData (Set a) | |
NFData a => NFData (Hashed a) | |
NFData a => NFData (HashSet a) | |
NFData value => NFData (RunResult value) # | |
NFData (a -> b) | This instance is for convenience and consistency with Since: 1.3.0.0 |
(NFData a, NFData b) => NFData (Either a b) | |
(NFData a, NFData b) => NFData (a, b) | |
(NFData a, NFData b) => NFData (Array a b) | |
(NFData a, NFData b) => NFData (Arg a b) | Since: 1.4.2.0 |
NFData (Proxy k a) | Since: 1.4.0.0 |
NFData (STRef s a) | NOTE: Only strict in the reference and not the referenced value. Since: 1.4.2.0 |
(NFData k, NFData a) => NFData (Map k a) | |
(NFData k, NFData v) => NFData (Leaf k v) | |
(NFData k, NFData v) => NFData (HashMap k v) | |
(NFData a1, NFData a2, NFData a3) => NFData (a1, a2, a3) | |
NFData a => NFData (Const k a b) | Since: 1.4.0.0 |
NFData ((:~:) k a b) | Since: 1.4.3.0 |
(NFData a1, NFData a2, NFData a3, NFData a4) => NFData (a1, a2, a3, a4) | |
(NFData1 f, NFData1 g, NFData a) => NFData (Product * f g a) | Since: 1.4.3.0 |
(NFData1 f, NFData1 g, NFData a) => NFData (Sum * f g a) | Since: 1.4.3.0 |
NFData ((:~~:) k1 k2 a b) | Since: 1.4.3.0 |
(NFData a1, NFData a2, NFData a3, NFData a4, NFData a5) => NFData (a1, a2, a3, a4, a5) | |
(NFData1 f, NFData1 g, NFData a) => NFData (Compose * * f g a) | Since: 1.4.3.0 |
(NFData a1, NFData a2, NFData a3, NFData a4, NFData a5, NFData a6) => NFData (a1, a2, a3, a4, a5, a6) | |
(NFData a1, NFData a2, NFData a3, NFData a4, NFData a5, NFData a6, NFData a7) => NFData (a1, a2, a3, a4, a5, a6, a7) | |
(NFData a1, NFData a2, NFData a3, NFData a4, NFData a5, NFData a6, NFData a7, NFData a8) => NFData (a1, a2, a3, a4, a5, a6, a7, a8) | |
(NFData a1, NFData a2, NFData a3, NFData a4, NFData a5, NFData a6, NFData a7, NFData a8, NFData a9) => NFData (a1, a2, a3, a4, a5, a6, a7, a8, a9) | |