-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Boring and Absurd types -- -- -- -- See What does () mean in Haskell -answer by Conor McBride @package boring @version 0.2 -- | Boring and Absurd classes. One approach. -- -- Different approach would be to have -- --
--   -- none-one-tons semiring
--   data NOT = None | One | Tons
--   
--   type family Cardinality (a :: *) :: NOT
--   
--   class Cardinality a ~ None => Absurd a where ...
--   class Cardinality a ~ One  => Boring a where ...
--   
-- -- This would make possible to define more instances, e.g. -- --
--   instance (Mult (Cardinality a) (Cardinality b) ~ None) => Absurd (a, b) where ...
--   
-- --

Functions

-- -- Function is an exponential: -- --
--   Cardinality (a -> b) ~ Exponent (Cardinality b) (Cardinality a)
--   
-- -- or shortly |a -> b| = |b| ^ |a|. This gives us possible -- instances: -- -- -- -- Both instances are Boring, but we chose to define the latter. -- --

Note about adding instances

-- -- At this moment this module misses a lot of instances, please make a -- patch to add more. Especially, if the package is already in the -- transitive dependency closure. -- -- E.g. any possibly empty container f has Absurd a -- => Boring (f a) module Data.Boring -- | Boring types which contains one thing, also boring. -- There is nothing interesting to be gained by comparing one element of -- the boring type with another, because there is nothing to learn about -- an element of the boring type by giving it any of your attention. -- -- Boring Law: -- --
--   boring == x
--   
-- -- Note: This is different class from Default. -- Default gives you some value, Boring gives -- you an unique value. -- -- Also note, that we cannot have instances for e.g. Either, as -- both (Boring a, Absurd b) => Either a b and -- (Absurd a, Boring b) => Either a b would be -- valid instances. -- -- Another useful trick, is that you can rewrite computations with -- Boring results, for example foo :: Int -> (), -- if you are sure that foo is total. -- --
--   {-# RULES "less expensive" foo = boring #-}
--   
-- -- That's particularly useful with equality :~: proofs. class Boring a boring :: Boring a => a boring :: (Boring a, Generic a, GBoring (Rep a)) => a -- | The Absurd type is very exciting, because if somebody ever -- gives you a value belonging to it, you know that you are already dead -- and in Heaven and that anything you want is yours. -- -- Similarly as there are many Boring sums, there are many -- Absurd products, so we don't have Absurd instances for -- tuples. class Absurd a absurd :: Absurd a => a -> b absurd :: (Absurd a, Generic a, GAbsurd (Rep a)) => a -> b -- | A helper class to implement Generic derivation of -- Boring. -- -- Technically we could do (avoiding QuantifiedConstraints): -- --
--   type GBoring f = (Boring (f V.Void), Functor f)
--   
--   gboring :: forall f x. GBoring f => f x
--   gboring = vacuous (boring :: f V.Void)
--   
-- -- but separate class is cleaner. -- --
--   >>> data B2 = B2 () () deriving (Show, Generic)
--   
--   >>> instance Boring B2
--   
--   >>> boring :: B2
--   B2 () ()
--   
class GBoring f -- | A helper class to implement of Generic derivation of -- Absurd. -- --
--   type GAbsurd f = (Absurd (f ()), Functor f)
--   
--   gabsurd :: forall f x y. GAbsurd f => f x -> y
--   gabsurd = absurd . void
--   
class GAbsurd f -- | If Absurd is uninhabited then any Functor that holds -- only values of type Absurd is holding no values. vacuous :: (Functor f, Absurd a) => f a -> f b -- | There is a field for every type in the Absurd. Very zen. -- --
--   devoid :: Absurd s => Over p f s s a b
--   
-- -- type Over p f s t a b = p a (f b) -> s -> f t devoid :: Absurd s => p a (f b) -> s -> f s -- | We can always retrieve a Boring value from any type. -- --
--   united :: Boring a => Lens' s a
--   
united :: (Boring a, Functor f) => (a -> f a) -> s -> f s instance Data.Boring.Absurd a => Data.Boring.Boring [a] instance Data.Boring.Absurd a => Data.Boring.Boring (GHC.Maybe.Maybe a) instance Data.Boring.Absurd Data.Void.Void instance (Data.Boring.Absurd a, Data.Boring.Absurd b) => Data.Boring.Absurd (Data.Either.Either a b) instance Data.Boring.Absurd a => Data.Boring.Absurd (GHC.Base.NonEmpty a) instance Data.Boring.Absurd a => Data.Boring.Absurd (Data.Functor.Identity.Identity a) instance Data.Boring.Absurd (f (g a)) => Data.Boring.Absurd (Data.Functor.Compose.Compose f g a) instance (Data.Boring.Absurd (f a), Data.Boring.Absurd (g a)) => Data.Boring.Absurd (Data.Functor.Sum.Sum f g a) instance Data.Boring.Absurd b => Data.Boring.Absurd (Data.Functor.Const.Const b a) instance Data.Boring.Absurd a => Data.Boring.Absurd (Data.Tagged.Tagged b a) instance Data.Boring.Absurd (GHC.Generics.V1 p) instance Data.Boring.Absurd c => Data.Boring.Absurd (GHC.Generics.K1 i c p) instance Data.Boring.Absurd (f p) => Data.Boring.Absurd (GHC.Generics.M1 i c f p) instance (Data.Boring.Absurd (f p), Data.Boring.Absurd (g p)) => Data.Boring.Absurd ((GHC.Generics.:+:) f g p) instance Data.Boring.Absurd p => Data.Boring.Absurd (GHC.Generics.Par1 p) instance Data.Boring.Absurd (f p) => Data.Boring.Absurd (GHC.Generics.Rec1 f p) instance Data.Boring.Absurd (f (g p)) => Data.Boring.Absurd ((GHC.Generics.:.:) f g p) instance Data.Boring.Absurd c => Data.Boring.GAbsurd (GHC.Generics.K1 i c) instance Data.Boring.GAbsurd GHC.Generics.V1 instance Data.Boring.GAbsurd f => Data.Boring.GAbsurd (GHC.Generics.M1 i c f) instance (Data.Boring.GAbsurd f, Data.Boring.GAbsurd g) => Data.Boring.GAbsurd (f GHC.Generics.:+: g) instance Data.Boring.Boring () instance Data.Boring.Boring b => Data.Boring.Boring (a -> b) instance Data.Boring.Boring (Data.Proxy.Proxy a) instance Data.Boring.Boring a => Data.Boring.Boring (Data.Functor.Const.Const a b) instance Data.Boring.Boring b => Data.Boring.Boring (Data.Tagged.Tagged a b) instance Data.Boring.Boring a => Data.Boring.Boring (Data.Functor.Identity.Identity a) instance Data.Boring.Boring (f (g a)) => Data.Boring.Boring (Data.Functor.Compose.Compose f g a) instance (Data.Boring.Boring (f a), Data.Boring.Boring (g a)) => Data.Boring.Boring (Data.Functor.Product.Product f g a) instance (Data.Boring.Boring a, Data.Boring.Boring b) => Data.Boring.Boring (a, b) instance (Data.Boring.Boring a, Data.Boring.Boring b, Data.Boring.Boring c) => Data.Boring.Boring (a, b, c) instance (Data.Boring.Boring a, Data.Boring.Boring b, Data.Boring.Boring c, Data.Boring.Boring d) => Data.Boring.Boring (a, b, c, d) instance (Data.Boring.Boring a, Data.Boring.Boring b, Data.Boring.Boring c, Data.Boring.Boring d, Data.Boring.Boring e) => Data.Boring.Boring (a, b, c, d, e) instance (a GHC.Types.~ b) => Data.Boring.Boring (a Data.Type.Equality.:~: b) instance (a ~ b) => Data.Boring.Boring (a Data.Type.Equality.:~~: b) instance Data.Typeable.Internal.Typeable a => Data.Boring.Boring (Data.Typeable.Internal.TypeRep a) instance Data.Boring.Boring (GHC.Generics.U1 p) instance Data.Boring.Boring c => Data.Boring.Boring (GHC.Generics.K1 i c p) instance Data.Boring.Boring (f p) => Data.Boring.Boring (GHC.Generics.M1 i c f p) instance (Data.Boring.Boring (f p), Data.Boring.Boring (g p)) => Data.Boring.Boring ((GHC.Generics.:*:) f g p) instance Data.Boring.Boring p => Data.Boring.Boring (GHC.Generics.Par1 p) instance Data.Boring.Boring (f p) => Data.Boring.Boring (GHC.Generics.Rec1 f p) instance Data.Boring.Boring (f (g p)) => Data.Boring.Boring ((GHC.Generics.:.:) f g p) instance Data.Boring.Boring c => Data.Boring.GBoring (GHC.Generics.K1 i c) instance Data.Boring.GBoring GHC.Generics.U1 instance Data.Boring.GBoring f => Data.Boring.GBoring (GHC.Generics.M1 i c f) instance (Data.Boring.GBoring f, Data.Boring.GBoring g) => Data.Boring.GBoring (f GHC.Generics.:*: g)