-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Basic examples and functions for generics-sop -- @package basic-sop @version 0.1.0.4 -- | Generic reduction to normal form. -- -- This module contains a generic function that reduces a value to normal -- form, defined using generics-sop. module Generics.SOP.NFData -- | Generic reduction to normal form. -- -- This function is a generic implementation of the rnf function -- that can be used to instantiate the NFData class in -- deepseq. -- -- Assuming you have a Generic instance for your datatype -- T, you can use grnf as follows: -- --
--   instance NFData T where
--     rnf = grnf
--   
grnf :: (Generic a, All2 NFData (Code a)) => a -> () -- | Generic computation of a skeleton. -- -- $skeleton module Generics.SOP.Skeleton -- | Generic computation of a skeleton. -- -- A skeleton for a record type has a defined "spine" but is undefined -- everywhere else. For instance, a skeleton for pairs would be -- --
--   (undefined, undefined)
--   
-- -- We introduce a type class for this purpose because the skeleton for -- nested records would look like -- --
--   (undefined, (undefined, undefined))
--   
-- -- The default instance of skeleton applies to record types; for -- everything else, use undefined (or error): -- --
--   instance Skeleton SomeRecordType -- no where clause
--   
-- -- or -- --
--   instance Skeleton SomeNonRecordType where skeleton = undefined
--   
-- -- This is an example of how SOP-style generic functions can be used with -- DefaultSignatures. -- -- Furthermore, metadata is used in order to produce better error -- messages. For the undefined components of a record, an error is -- triggered that mentions the name of the field. class Skeleton a where skeleton = gskeleton skeleton :: Skeleton a => a instance Typeable Skeleton instance Skeleton Text instance Skeleton Bool instance Skeleton Rational instance Skeleton Double instance Skeleton Int instance Skeleton (Maybe a) instance Skeleton [a] -- | Generic show. -- -- This module contains a generic show function defined using -- generics-sop. module Generics.SOP.Show -- | Generic show. -- -- This function is a proof-of-concept implementation of a function that -- is similar to the show function you get by using 'deriving -- Show'. -- -- It serves as an example of an SOP-style generic function that makes -- use of metadata. However, it does currently not handle parentheses -- correctly, and is therefore not really usable as a replacement. -- -- If you want to use it anyway on a datatype T for which you -- have a Generic instance, you can use gshow as follows: -- --
--   instance Show T where
--     show = gshow
--   
gshow :: (Generic a, HasDatatypeInfo a, All2 Show (Code a)) => a -> String -- | Generic generation of random test cases. -- -- This module contains a generic version of arbitrary from the -- Test.Quickcheck library, using generics-sop. module Generics.SOP.Arbitrary -- | Generic generation of random test cases. -- -- This function is a proof-of-concept implementation of a generic -- arbitrary that can be used to instantiate the Arbitrary -- class in QuickCheck. -- -- If you want to use it on a datatype T for which you have a -- Generic instance, you can say: -- --
--   instance Arbitrary T where
--     arbitrary = garbitrary
--   
-- -- Note that currently no attempts are being made to generate arbitrary -- values of a particular size, and it is possible that this function -- diverges for recursive structures. garbitrary :: (Generic a, All2 Arbitrary (Code a)) => Gen a -- | Random generation and shrinking of values. class Arbitrary a arbitrary :: Arbitrary a => Gen a shrink :: Arbitrary a => a -> [a] -- | Generic equality. -- -- This module contains a generic equality function defined using -- generics-sop. module Generics.SOP.Eq -- | Generic equality. -- -- This function reimplements the built-in generic equality that you get -- by using deriving Eq. -- -- Assuming you have a Generic instance for a datatype T, -- you can use geq as follows: -- --
--   instance Eq T where
--     (==) = geq
--   
geq :: (Generic a, All2 Eq (Code a)) => a -> a -> Bool