-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Extensible type-safe unions -- -- Extensible type-safe unions for Haskell with prisms using modern GHC -- features. Dual to vinyl records. Unions are also known as corecords or -- polymorphic variants. Neither requires a Typeable constraint -- nor uses unsafe coercions at the cost of linear time access -- (negligible in practice). @package union @version 0.1.1.2 -- | Extensible type-safe unions. module Data.Union -- | A union is parameterized by a universe u, an interpretation -- f and a list of labels as. The labels of the union -- are given by inhabitants of the kind u; the type of values at -- any label a :: u is given by its interpretation f a :: -- *. data Union (f :: u -> *) (as :: [u]) [This] :: !(f a) -> Union f (a : as) [That] :: !(Union f as) -> Union f (a : as) -- | Case analysis for unions. union :: (Union f as -> c) -> (f a -> c) -> Union f (a : as) -> c -- | Since a union with an empty list of labels is uninhabited, we can -- recover any type from it. absurdUnion :: Union f '[] -> a umap :: (forall a. f a -> g a) -> Union f as -> Union g as _This :: Prism (Union f (a : as)) (Union f (b : as)) (f a) (f b) _That :: Prism (Union f (a : as)) (Union f (a : bs)) (Union f as) (Union f bs) class i ~ RIndex a as => UElem (a :: u) (as :: [u]) (i :: Nat) where uprism = prism' ulift umatch ulift = review uprism umatch = preview uprism uprism :: UElem a as i => Prism' (Union f as) (f a) ulift :: UElem a as i => f a -> Union f as umatch :: UElem a as i => Union f as -> Maybe (f a) class is ~ RImage as bs => USubset (as :: [u]) (bs :: [u]) is where usubset = prism' urelax urestrict urelax = review usubset urestrict = preview usubset usubset :: USubset as bs is => Prism' (Union f bs) (Union f as) urelax :: USubset as bs is => Union f as -> Union f bs urestrict :: USubset as bs is => Union f bs -> Maybe (Union f as) type OpenUnion = Union Identity openUnion :: forall a as. UElem a as (RIndex a as) => Prism' (OpenUnion as) a instance forall a (a1 :: a) (as :: [a]). Data.Union.UElem a1 (a1 : as) 'Data.Vinyl.TypeLevel.Z instance forall a (a1 :: a) (b :: a) (as :: [a]) (i :: Data.Vinyl.TypeLevel.Nat). (Data.Vinyl.TypeLevel.RIndex a1 (b : as) ~ 'Data.Vinyl.TypeLevel.S i, Data.Union.UElem a1 as i) => Data.Union.UElem a1 (b : as) ('Data.Vinyl.TypeLevel.S i) instance forall u (bs :: [u]). Data.Union.USubset '[] bs '[] instance forall u (a :: u) (bs :: [u]) (i :: Data.Vinyl.TypeLevel.Nat) (as :: [u]) (is :: [Data.Vinyl.TypeLevel.Nat]). (Data.Union.UElem a bs i, Data.Union.USubset as bs is) => Data.Union.USubset (a : as) bs (i : is) instance forall u (f :: u -> GHC.Types.*). Control.DeepSeq.NFData (Data.Union.Union f '[]) instance forall a (f :: a -> *) (a1 :: a) (as :: [a]). (Control.DeepSeq.NFData (f a1), Control.DeepSeq.NFData (Data.Union.Union f as)) => Control.DeepSeq.NFData (Data.Union.Union f (a1 : as)) instance forall u (f :: u -> GHC.Types.*). GHC.Show.Show (Data.Union.Union f '[]) instance forall a (f :: a -> *) (a1 :: a) (as :: [a]). (GHC.Show.Show (f a1), GHC.Show.Show (Data.Union.Union f as)) => GHC.Show.Show (Data.Union.Union f (a1 : as)) instance forall u (f :: u -> GHC.Types.*). GHC.Classes.Eq (Data.Union.Union f '[]) instance forall a (f :: a -> *) (a1 :: a) (as :: [a]). (GHC.Classes.Eq (f a1), GHC.Classes.Eq (Data.Union.Union f as)) => GHC.Classes.Eq (Data.Union.Union f (a1 : as)) instance forall u (f :: u -> GHC.Types.*). GHC.Classes.Ord (Data.Union.Union f '[]) instance forall a (f :: a -> *) (a1 :: a) (as :: [a]). (GHC.Classes.Ord (f a1), GHC.Classes.Ord (Data.Union.Union f as)) => GHC.Classes.Ord (Data.Union.Union f (a1 : as)) instance f ~ Data.Functor.Identity.Identity => GHC.Exception.Exception (Data.Union.Union f '[]) instance (f ~ Data.Functor.Identity.Identity, GHC.Exception.Exception a, Data.Typeable.Internal.Typeable as, GHC.Exception.Exception (Data.Union.Union f as)) => GHC.Exception.Exception (Data.Union.Union f (a : as))