-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Ties the knot on data structures that reference each other by unique keys. -- -- Please see the README on GitHub at -- https://github.com/pkamenarsky/knit#readme @package knit @version 0.2.0.0 module Generics.Eot.Datatype -- | Type for meta information about ADTs. data Datatype Datatype :: String -> [Constructor] -> Datatype -- | unqualified name of the type [datatypeName] :: Datatype -> String [constructors] :: Datatype -> [Constructor] data Constructor Constructor :: String -> Fields -> Constructor [constructorName] :: Constructor -> String [fields] :: Constructor -> Fields -- | Type that represents meta information about fields of one constructor. data Fields -- | Record constructor, containing the list of the selector names. Selectors :: [String] -> Fields -- | Constructor with fields, but without selector names. The argument -- gives the number of fields. NoSelectors :: Int -> Fields -- | Constructor without fields. NoFields :: Fields class GenericDatatype (a :: * -> *) datatypeC :: GenericDatatype a => Proxy a -> Datatype class GenericConstructors (a :: * -> *) getConstructors :: GenericConstructors a => Proxy a -> [Constructor] getFields :: GenericFields a => Proxy a -> Fields class GenericFields (a :: * -> *) getFieldsC :: GenericFields a => Proxy a -> [Maybe String] getField :: forall c f. Selector c => Proxy (S1 c (Rec0 f)) -> Maybe String instance GHC.Classes.Eq Generics.Eot.Datatype.Datatype instance GHC.Show.Show Generics.Eot.Datatype.Datatype instance GHC.Classes.Eq Generics.Eot.Datatype.Constructor instance GHC.Show.Show Generics.Eot.Datatype.Constructor instance GHC.Classes.Eq Generics.Eot.Datatype.Fields instance GHC.Show.Show Generics.Eot.Datatype.Fields instance (GHC.Generics.Constructor c, Generics.Eot.Datatype.GenericFields f) => Generics.Eot.Datatype.GenericConstructors (GHC.Generics.C1 c f) instance (Generics.Eot.Datatype.GenericFields a, Generics.Eot.Datatype.GenericFields b) => Generics.Eot.Datatype.GenericFields (a GHC.Generics.:*: b) instance GHC.Generics.Selector c => Generics.Eot.Datatype.GenericFields (GHC.Generics.S1 c (GHC.Generics.Rec0 f)) instance Generics.Eot.Datatype.GenericFields GHC.Generics.U1 instance (GHC.Generics.Datatype c, Generics.Eot.Datatype.GenericConstructors f) => Generics.Eot.Datatype.GenericDatatype (GHC.Generics.D1 c f) instance (Generics.Eot.Datatype.GenericConstructors a, Generics.Eot.Datatype.GenericConstructors b) => Generics.Eot.Datatype.GenericConstructors (a GHC.Generics.:+: b) instance Generics.Eot.Datatype.GenericConstructors GHC.Generics.V1 module Generics.Eot.Eot class HasEotG (a :: * -> *) where { type family EotG a :: *; } toEotG :: HasEotG a => a x -> EotG a fromEotG :: HasEotG a => EotG a -> a x data Named (a :: Symbol) field Named :: field -> Named field instance GHC.Show.Show field => GHC.Show.Show (Generics.Eot.Eot.Unnamed field) instance GHC.Show.Show field => GHC.Show.Show (Generics.Eot.Eot.Named a field) instance (Generics.Eot.Eot.HasFieldsG a, Generics.Eot.Eot.HasFieldsG b, Generics.Eot.Eot.Concat (Generics.Eot.Eot.Fields a) (Generics.Eot.Eot.Fields b)) => Generics.Eot.Eot.HasFieldsG (a GHC.Generics.:*: b) instance Generics.Eot.Eot.Concat as bs => Generics.Eot.Eot.Concat (a, as) bs instance Generics.Eot.Eot.Concat () bs instance Generics.Eot.Eot.HasFieldsG (GHC.Generics.S1 ('GHC.Generics.MetaSel 'GHC.Maybe.Nothing x y z) (GHC.Generics.Rec0 f)) instance GHC.TypeLits.KnownSymbol name => Generics.Eot.Eot.HasFieldsG (GHC.Generics.S1 ('GHC.Generics.MetaSel ('GHC.Maybe.Just name) x y z) (GHC.Generics.Rec0 f)) instance Generics.Eot.Eot.HasFieldsG f => Generics.Eot.Eot.HasConstructorsG (GHC.Generics.C1 c f) instance Generics.Eot.Eot.HasFieldsG GHC.Generics.U1 instance (Generics.Eot.Eot.HasConstructorsG a, Generics.Eot.Eot.HasConstructorsG b, Generics.Eot.Eot.Normalize (Generics.Eot.Eot.Constructors a) (Generics.Eot.Eot.Constructors b)) => Generics.Eot.Eot.HasConstructorsG (a GHC.Generics.:+: b) instance Generics.Eot.Eot.Normalize b c => Generics.Eot.Eot.Normalize (Data.Either.Either a b) c instance Generics.Eot.Eot.Normalize Data.Void.Void b instance Generics.Eot.Eot.HasConstructorsG f => Generics.Eot.Eot.HasEotG (GHC.Generics.D1 c f) instance Generics.Eot.Eot.HasConstructorsG GHC.Generics.V1 -- | generics-eot tries to be a library for datatype generic -- programming that is easy to understand. "eot" stands for "eithers of -- tuples". -- -- A tutorial on how to use generics-eot can be found here: -- https://generics-eot.readthedocs.io/. module Generics.Eot -- | An instance (HasEot a) allows us to -- --
-- data Foo = A Int Bool | B String
--
--
-- would be mapped to:
--
--
-- Either (Int, (Bool, ())) (Either (String, ()) Void)
--
--
-- These representations follow these rules:
--
-- -- from . to ≡ id -- to . from ≡ id --class Generic a -- | Proxy is a type that holds no data, but has a phantom parameter -- of arbitrary type (or even kind). Its use is to provide type -- information, even though there is no value available of that type (or -- it may be too costly to create one). -- -- Historically, Proxy :: Proxy a is a safer -- alternative to the 'undefined :: a' idiom. -- --
-- >>> Proxy :: Proxy (Void, Int -> Int) -- Proxy ---- -- Proxy can even hold types of higher kinds, -- --
-- >>> Proxy :: Proxy Either -- Proxy ---- --
-- >>> Proxy :: Proxy Functor -- Proxy ---- --
-- >>> Proxy :: Proxy complicatedStructure -- Proxy --data Proxy (t :: k) :: forall k. () => k -> Type Proxy :: Proxy -- | Uninhabited data type data Void -- | Since Void values logically don't exist, this witnesses the -- logical reasoning tool of "ex falso quodlibet". -- --
-- >>> let x :: Either Void Int; x = Right 5
--
-- >>> :{
-- case x of
-- Right r -> r
-- Left l -> absurd l
-- :}
-- 5
--
absurd :: () => Void -> a
instance (GHC.Generics.Generic a, Generics.Eot.ImpliedByGeneric a c f) => Generics.Eot.HasEot a