union 0.1.1.2 → 0.1.2
raw patch · 2 files changed
+41/−4 lines, 2 filesdep +hashabledep ~basedep ~deepseqdep ~profunctorsPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: hashable
Dependency ranges changed: base, deepseq, profunctors, vinyl
API changes (from Hackage documentation)
- Data.Union: instance f ~ Data.Functor.Identity.Identity => GHC.Exception.Exception (Data.Union.Union f '[])
- Data.Union: instance forall a (a1 :: a) (as :: [a]). Data.Union.UElem a1 (a1 : as) 'Data.Vinyl.TypeLevel.Z
- Data.Union: 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)
- Data.Union: 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))
- Data.Union: 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))
- Data.Union: 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))
- Data.Union: 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))
- Data.Union: instance forall u (f :: u -> GHC.Types.*). Control.DeepSeq.NFData (Data.Union.Union f '[])
- Data.Union: instance forall u (f :: u -> GHC.Types.*). GHC.Classes.Eq (Data.Union.Union f '[])
- Data.Union: instance forall u (f :: u -> GHC.Types.*). GHC.Classes.Ord (Data.Union.Union f '[])
- Data.Union: instance forall u (f :: u -> GHC.Types.*). GHC.Show.Show (Data.Union.Union f '[])
+ Data.Union: instance (f ~ Data.Functor.Identity.Identity) => GHC.Exception.Exception (Data.Union.Union f '[])
+ Data.Union: instance forall a1 (a2 :: a1) (as :: [a1]). Data.Union.UElem a2 (a2 : as) 'Data.Vinyl.TypeLevel.Z
+ Data.Union: instance forall a1 (a2 :: a1) (b :: a1) (as :: [a1]) (i :: Data.Vinyl.TypeLevel.Nat). (Data.Vinyl.TypeLevel.RIndex a2 (b : as) ~ 'Data.Vinyl.TypeLevel.S i, Data.Union.UElem a2 as i) => Data.Union.UElem a2 (b : as) ('Data.Vinyl.TypeLevel.S i)
+ Data.Union: instance forall a1 (f :: a1 -> *) (a2 :: a1) (as :: [a1]). (Control.DeepSeq.NFData (f a2), Control.DeepSeq.NFData (Data.Union.Union f as)) => Control.DeepSeq.NFData (Data.Union.Union f (a2 : as))
+ Data.Union: instance forall a1 (f :: a1 -> *) (a2 :: a1) (as :: [a1]). (Data.Hashable.Class.Hashable (f a2), Data.Hashable.Class.Hashable (Data.Union.Union f as)) => Data.Hashable.Class.Hashable (Data.Union.Union f (a2 : as))
+ Data.Union: instance forall a1 (f :: a1 -> *) (a2 :: a1) (as :: [a1]). (GHC.Classes.Eq (f a2), GHC.Classes.Eq (Data.Union.Union f as)) => GHC.Classes.Eq (Data.Union.Union f (a2 : as))
+ Data.Union: instance forall a1 (f :: a1 -> *) (a2 :: a1) (as :: [a1]). (GHC.Classes.Ord (f a2), GHC.Classes.Ord (Data.Union.Union f as)) => GHC.Classes.Ord (Data.Union.Union f (a2 : as))
+ Data.Union: instance forall a1 (f :: a1 -> *) (a2 :: a1) (as :: [a1]). (GHC.Show.Show (f a2), GHC.Show.Show (Data.Union.Union f as)) => GHC.Show.Show (Data.Union.Union f (a2 : as))
+ Data.Union: instance forall u (f :: u -> *) (a :: u) (as :: [u]). GHC.Generics.Generic (Data.Union.Union f (a : as))
+ Data.Union: instance forall u (f :: u -> *). Control.DeepSeq.NFData (Data.Union.Union f '[])
+ Data.Union: instance forall u (f :: u -> *). Data.Hashable.Class.Hashable (Data.Union.Union f '[])
+ Data.Union: instance forall u (f :: u -> *). GHC.Classes.Eq (Data.Union.Union f '[])
+ Data.Union: instance forall u (f :: u -> *). GHC.Classes.Ord (Data.Union.Union f '[])
+ Data.Union: instance forall u (f :: u -> *). GHC.Generics.Generic (Data.Union.Union f '[])
+ Data.Union: instance forall u (f :: u -> *). GHC.Show.Show (Data.Union.Union f '[])
- Data.Union: class i ~ RIndex a as => UElem (a :: u) (as :: [u]) (i :: Nat) where uprism = prism' ulift umatch ulift = review uprism umatch = preview uprism
+ Data.Union: class i ~ RIndex a as => UElem (a :: u) (as :: [u]) (i :: Nat)
- Data.Union: class is ~ RImage as bs => USubset (as :: [u]) (bs :: [u]) is where usubset = prism' urelax urestrict urelax = review usubset urestrict = preview usubset
+ Data.Union: class is ~ RImage as bs => USubset (as :: [u]) (bs :: [u]) is
Files
- src/Data/Union.hs +36/−0
- union.cabal +5/−4
src/Data/Union.hs view
@@ -9,11 +9,28 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE EmptyCase #-} {-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeFamilies #-} {- | Extensible type-safe unions. +>>> let a = openUnion # (5 :: Int) :: OpenUnion '[Bool, Int]++>>> a ^? openUnion @Int+Just 5++>>> a ^? openUnion @Bool+Nothing++>>> a ^? openUnion @Char+<interactive>:7:6: error:+ • No instance for (UElem Char '[] (RIndex Char '[]))+ arising from a use of ‘openUnion’+ • In the second argument of ‘(^?)’, namely ‘openUnion @Char’+ In the expression: a ^? openUnion @Char+ In an equation for ‘it’: it = a ^? openUnion @Char+ -} module Data.Union@@ -36,6 +53,8 @@ import Data.Typeable import Data.Vinyl.TypeLevel import Data.Union.Prism+import Data.Hashable+import qualified GHC.Generics as G -- | 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@@ -181,3 +200,20 @@ where matchR = This . Identity <$> fromException sE matchL = That <$> fromException sE++instance G.Generic (Union f '[]) where+ type Rep (Union f '[]) = G.V1+ from = absurdUnion+ to = \case{}++instance G.Generic (Union f (a ': as)) where+ type Rep (Union f (a ': as)) =+ G.C1 ('G.MetaCons "This" 'G.PrefixI 'False) (G.Rec0 (f a)) G.:+:+ G.C1 ('G.MetaCons "That" 'G.PrefixI 'False) (G.Rec0 (Union f as))+ from = union (G.R1 . G.M1 . G.K1) (G.L1 . G.M1 . G.K1)+ to = \case+ G.L1 (G.M1 (G.K1 a)) -> This a+ G.R1 (G.M1 (G.K1 u)) -> That u++instance Hashable (Union f '[])+instance (Hashable (f a), Hashable (Union f as)) => Hashable (Union f (a ': as))
union.cabal view
@@ -1,5 +1,5 @@ name: union-version: 0.1.1.2+version: 0.1.2 synopsis: Extensible type-safe unions description: @@ -37,11 +37,12 @@ RankNTypes ScopedTypeVariables TypeOperators- build-depends: base >=4.8 && <4.11- , vinyl >=0.5 && <0.6- , profunctors >=5.1 && <5.3+ build-depends: base >=4.8 && <4.13+ , vinyl >=0.5 && <0.11+ , profunctors >=5.1 && <5.4 , tagged >=0.8 && <0.9 , deepseq >=1.4 && <1.5+ , hashable >=1.2 && <1.3 hs-source-dirs: src default-language: Haskell2010 ghc-options: -Wall