-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Recover type indexes and instances for your existentialized types. -- -- Recover type indexes and instances for your existentialized types. @package exinst @version 0.4 -- | Exinst is a library providing you with tools to recover type-indexed -- types whose type-indexes have been existentialized, as well as -- automatically deriving instances for them, as long as said type -- indexes are singleton types (see singleton). -- -- In short, what exinst currently gives you is: For any type -- t :: k -> *, if k is a singleton type and c -- (t a) :: Constraint is satisfied, then you can -- existentialize away the a parameter with Some1 -- t, recover it later, and have c (Some1 t) -- automatically satisfied. Currently, up to 4 type indexes can be -- existentialized using Some1, Some2, Some3 and -- Some4 respectively. -- -- NOTE: This tutorial asumes some familiarity with singleton types as -- implemented by the singleton library. A singleton type is, in -- very rough terms, a type inhabited by a single term, which allows one -- to go from its term-level representation to its type-level -- representation and back without much trouble. A bit like the term -- (), which is of type (). Whenever you have the type -- () you know what that its term-level representation must be -- (), and whenever you have the term () you know that -- its type must be (). module Exinst data Some1 (f1 :: k1 -> Type) Some1 :: !(Sing a1) -> !(f1 a1) -> Some1 some1 :: forall (f1 :: k1 -> Type) a1. SingI a1 => f1 a1 -> Some1 f1 fromSome1 :: forall (f1 :: k1 -> Type) a1. (SingI a1, SDecide k1) => Some1 f1 -> Maybe (f1 a1) _Some1 :: forall (f1 :: k1 -> Type) a1. (SingI a1, SDecide k1) => Prism' (Some1 f1) (f1 a1) withSome1 :: forall (f1 :: k1 -> Type) (r :: Type). Some1 f1 -> (forall a1. SingI a1 => f1 a1 -> r) -> r -- | Like withSome1, but takes an explicit Sing besides the -- SingI instance. withSome1Sing :: forall (f1 :: k1 -> Type) (r :: Type). Some1 f1 -> (forall a1. (SingI a1) => Sing a1 -> f1 a1 -> r) -> r some1SingRep :: SingKind k1 => Some1 (f1 :: k1 -> Type) -> DemoteRep k1 class Dict1 (c :: k0 -> Constraint) (f1 :: k1 -> k0) -- | Runtime lookup of the c (f1 a1) instance. dict1 :: Dict1 c f1 => Sing a1 -> Dict (c (f1 a1)) data Some2 (f2 :: k2 -> k1 -> Type) Some2 :: !(Sing a2) -> !(Sing a1) -> !(f2 a2 a1) -> Some2 some2 :: forall (f2 :: k2 -> k1 -> Type) a2 a1. (SingI a2, SingI a1) => f2 a2 a1 -> Some2 f2 fromSome2 :: forall (f2 :: k2 -> k1 -> Type) a2 a1. (SingI a2, SDecide k2, SingI a1, SDecide k1) => Some2 f2 -> Maybe (f2 a2 a1) _Some2 :: forall (f2 :: k2 -> k1 -> Type) a2 a1. (SingI a2, SDecide k2, SingI a1, SDecide k1) => Prism' (Some2 f2) (f2 a2 a1) withSome2 :: forall (f2 :: k2 -> k1 -> Type) (r :: Type). Some2 f2 -> (forall a2 a1. (SingI a2, SingI a1) => f2 a2 a1 -> r) -> r -- | Like withSome2, but takes explicit Sings besides the -- SingI instances. withSome2Sing :: forall (f2 :: k2 -> k1 -> Type) (r :: Type). Some2 f2 -> (forall a2 a1. (SingI a2, SingI a1) => Sing a2 -> Sing a1 -> f2 a2 a1 -> r) -> r some2SingRep :: (SingKind k2, SingKind k1) => Some2 (f2 :: k2 -> k1 -> Type) -> (DemoteRep k2, DemoteRep k1) class Dict2 (c :: k0 -> Constraint) (f2 :: k2 -> k1 -> k0) dict2 :: Dict2 c f2 => Sing a2 -> Sing a1 -> Dict (c (f2 a2 a1)) data Some3 (f3 :: k3 -> k2 -> k1 -> Type) Some3 :: !(Sing a3) -> !(Sing a2) -> !(Sing a1) -> !(f3 a3 a2 a1) -> Some3 some3 :: forall (f3 :: k3 -> k2 -> k1 -> Type) a3 a2 a1. (SingI a3, SingI a2, SingI a1) => f3 a3 a2 a1 -> Some3 f3 fromSome3 :: forall (f3 :: k3 -> k2 -> k1 -> Type) a3 a2 a1. (SingI a3, SDecide k3, SingI a2, SDecide k2, SingI a1, SDecide k1) => Some3 f3 -> Maybe (f3 a3 a2 a1) _Some3 :: forall (f3 :: k3 -> k2 -> k1 -> Type) a3 a2 a1. (SingI a3, SDecide k3, SingI a2, SDecide k2, SingI a1, SDecide k1) => Prism' (Some3 f3) (f3 a3 a2 a1) withSome3 :: forall (f3 :: k3 -> k2 -> k1 -> Type) (r :: Type). Some3 f3 -> (forall a3 a2 a1. (SingI a3, SingI a2, SingI a1) => f3 a3 a2 a1 -> r) -> r -- | Like withSome3, but takes explicit Sings besides the -- SingI instances. withSome3Sing :: forall (f3 :: k3 -> k2 -> k1 -> Type) (r :: Type). Some3 f3 -> (forall a3 a2 a1. (SingI a3, SingI a2, SingI a1) => Sing a3 -> Sing a2 -> Sing a1 -> f3 a3 a2 a1 -> r) -> r some3SingRep :: (SingKind k3, SingKind k2, SingKind k1) => Some3 (f3 :: k3 -> k2 -> k1 -> Type) -> (DemoteRep k3, DemoteRep k2, DemoteRep k1) class Dict3 (c :: k0 -> Constraint) (f3 :: k3 -> k2 -> k1 -> k0) dict3 :: Dict3 c f3 => Sing a3 -> Sing a2 -> Sing a1 -> Dict (c (f3 a3 a2 a1)) data Some4 (f4 :: k4 -> k3 -> k2 -> k1 -> Type) Some4 :: !(Sing a4) -> !(Sing a3) -> !(Sing a2) -> !(Sing a1) -> !(f4 a4 a3 a2 a1) -> Some4 some4 :: forall (f4 :: k4 -> k3 -> k2 -> k1 -> Type) a4 a3 a2 a1. (SingI a4, SingI a3, SingI a2, SingI a1) => f4 a4 a3 a2 a1 -> Some4 f4 fromSome4 :: forall (f4 :: k4 -> k3 -> k2 -> k1 -> Type) a4 a3 a2 a1. (SingI a4, SDecide k4, SingI a3, SDecide k3, SingI a2, SDecide k2, SingI a1, SDecide k1) => Some4 f4 -> Maybe (f4 a4 a3 a2 a1) _Some4 :: forall (f4 :: k4 -> k3 -> k2 -> k1 -> Type) a4 a3 a2 a1. (SingI a4, SDecide k4, SingI a3, SDecide k3, SingI a2, SDecide k2, SingI a1, SDecide k1) => Prism' (Some4 f4) (f4 a4 a3 a2 a1) withSome4 :: forall (f4 :: k4 -> k3 -> k2 -> k1 -> Type) (r :: Type). Some4 f4 -> (forall a4 a3 a2 a1. (SingI a4, SingI a3, SingI a2, SingI a1) => f4 a4 a3 a2 a1 -> r) -> r -- | Like withSome4, but takes explicit Sings besides the -- SingI instances. withSome4Sing :: forall (f4 :: k4 -> k3 -> k2 -> k1 -> Type) (r :: Type). Some4 f4 -> (forall a4 a3 a2 a1. (SingI a4, SingI a3, SingI a2, SingI a1) => Sing a4 -> Sing a3 -> Sing a2 -> Sing a1 -> f4 a4 a3 a2 a1 -> r) -> r some4SingRep :: (SingKind k4, SingKind k3, SingKind k2, SingKind k1) => Some4 (f4 :: k4 -> k3 -> k2 -> k1 -> Type) -> (DemoteRep k4, DemoteRep k3, DemoteRep k2, DemoteRep k1) class Dict4 (c :: k0 -> Constraint) (f4 :: k4 -> k3 -> k2 -> k1 -> k0) dict4 :: Dict4 c f4 => Sing a4 -> Sing a3 -> Sing a2 -> Sing a1 -> Dict (c (f4 a4 a3 a2 a1)) -- | Dict0 is a bit different from Dict1, Dict2, etc. -- in that it looks up an instance for the singleton type itself, and not -- for some other type indexed by said singleton type. class Dict0 (c :: k0 -> Constraint) -- | Runtime lookup of the c a0 instance. dict0 :: Dict0 c => Sing a0 -> Dict (c a0) -- | Like Product from Data.Functor.Product, but only -- intended to be used with kinds other than Type. -- -- This type is particularly useful when used in combination with -- Some1 as Some1 (P1 l r), so as to ensure -- that l and r are indexed by the same type. Moreover, -- P1 already supports many common instances from base, -- hashable, deepseq, aeson, bytes, -- cereal, binary, and quickcheck out of the -- box, so you can benefit from them as well. data P1 l r (a1 :: k1) P1 :: (l a1) -> (r a1) -> P1 l r -- | Like P1, but for l and r taking two type -- indexes. data P2 l r (a2 :: k2) (a1 :: k1) P2 :: (l a2 a1) -> (r a2 a1) -> P2 l r -- | Like P1, but for l and r taking three type -- indexes. data P3 l r (a3 :: k3) (a2 :: k2) (a1 :: k1) P3 :: (l a3 a2 a1) -> (r a3 a2 a1) -> P3 l r -- | Like P1, but for l and r taking four type -- indexes. data P4 l r (a4 :: k4) (a3 :: k3) (a2 :: k2) (a1 :: k1) P4 :: (l a4 a3 a2 a1) -> (r a4 a3 a2 a1) -> P4 l r -- | Like Sum from Data.Functor.Sum, but only intended to be -- used with kinds other than Type. -- -- This type is particularly useful when used in combination with -- Some1 as Some1 (S1 l r), so as to ensure -- that l and r are indexed by the same type. Moreover, -- S1 already supports many common instances from base, -- hashable, deepseq, aeson, bytes, -- cereal, binary, and quickcheck out of the -- box, so you can benefit from them as well. data S1 l r (a1 :: k1) S1L :: (l a1) -> S1 l r S1R :: (r a1) -> S1 l r -- | Like S1, but for l and r taking two type -- indexes. data S2 l r (a2 :: k2) (a1 :: k1) S2L :: (l a2 a1) -> S2 l r S2R :: (r a2 a1) -> S2 l r -- | Like S1, but for l and r taking three type -- indexes. data S3 l r (a3 :: k3) (a2 :: k2) (a1 :: k1) S3L :: (l a3 a2 a1) -> S3 l r S3R :: (r a3 a2 a1) -> S3 l r -- | Like S1, but for l and r taking four type -- indexes. data S4 l r (a4 :: k4) (a3 :: k3) (a2 :: k2) (a1 :: k1) S4L :: (l a4 a3 a2 a1) -> S4 l r S4R :: (r a4 a3 a2 a1) -> S4 l r -- | The kind of constraints, like Show a data Constraint :: * -- | Values of type Dict p capture a dictionary for a -- constraint of type p. -- -- e.g. -- --
-- Dict :: Dict (Eq Int) ---- -- captures a dictionary that proves we have an: -- --
-- instance Eq 'Int ---- -- Pattern matching on the Dict constructor will bring this -- instance into scope. data Dict (a :: Constraint) :: Constraint -> * [Dict] :: Dict a -- | The singleton kind-indexed data family. -- | A SingI constraint is essentially an implicitly-passed -- singleton. If you need to satisfy this constraint with an explicit -- singleton, please see withSingI. class SingI k (a :: k)