-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | various operations on n-ary tuples via GHC.Generics -- -- Uncons operation on n-ary tuples @package tuple-ops @version 0.0.0.1 -- | This module defins operations to manipulate the generic representation -- of tuple. module Data.Tuple.Ops.Internal newtype TupleR (f :: [* -> *]) x TupleR :: Tuple (f <&> x) -> TupleR x [unTupleR] :: TupleR x -> Tuple (f <&> x) -- | prove that (a ++ b) & x == a & x ++ b -- & x class AppDistributive (a :: [* -> *]) appDistrWit :: AppDistributive a => (Proxy a, Proxy b, Proxy x) -> Wit (((a ++ b) <&> x) ~ ((a <&> x) ++ (b <&> x))) -- | inductive proof on a case 1. a is [] -- | case 2. a is _ :< _ -- | utility function to call appDistrWit appDistrWitPassArg :: (f :*: g) x -> (Proxy (L f), Proxy (L g), Proxy x) -- | Representation of tuple are shaped in a balanced tree. L -- transforms the tree into a list, for further manipulation. class Linearize (t :: * -> *) where { type family L t :: [* -> *]; } linearize :: Linearize t => t x -> TupleR (L t) x -- | base case. sinleton -- | inductive case. preppend a product with what ever length' :: TupleR a x -> Proxy (Len a) -- | calculate the half -- | calculate the half half :: Proxy n -> Proxy (Half n) -- | take the first n elements from a product class Take (n :: N) (a :: [* -> *]) where { type family T n a :: [* -> *]; } take' :: Take n a => Proxy n -> TupleR a x -> TupleR (T n a) x -- | base case. take one out of singleton -- | inductive case. take (n+1) elements -- | drop the first n elements from a product class Drop (n :: N) (a :: [* -> *]) where { type family D n a :: [* -> *]; } drop' :: Drop n a => Proxy n -> TupleR a x -> TupleR (D n a) x -- | base case. drop one from product -- | inductive case. drop (n+1) elements -- | Normalize converts a linear product back into a balanced tree. class Normalize (a :: [* -> *]) where { type family N a :: * -> *; } normalize :: Normalize a => TupleR a x -> N a x -- | base case. singleton -- | inductive case. product type MetaS = 'MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy -- | utility type function to trim the Rec0 -- | utility type function to trim the S1 -- | utility type function to trim the D1 -- | utility type function to extract the meta information instance Data.Tuple.Ops.Internal.Linearize (GHC.Generics.S1 Data.Tuple.Ops.Internal.MetaS (GHC.Generics.Rec0 t)) instance Data.Tuple.Ops.Internal.Normalize '[GHC.Generics.S1 Data.Tuple.Ops.Internal.MetaS (GHC.Generics.Rec0 t)] instance (Data.Tuple.Ops.Internal.Take (Data.Tuple.Ops.Internal.Half (Type.Family.Nat.N2 Type.Family.Nat.+ Type.Family.Nat.Len c)) (a Type.Family.List.:< (b Type.Family.List.:< c)), Data.Tuple.Ops.Internal.Drop (Data.Tuple.Ops.Internal.Half (Type.Family.Nat.N2 Type.Family.Nat.+ Type.Family.Nat.Len c)) (a Type.Family.List.:< (b Type.Family.List.:< c)), Data.Tuple.Ops.Internal.Normalize (Data.Tuple.Ops.Internal.T (Data.Tuple.Ops.Internal.Half (Type.Family.Nat.N2 Type.Family.Nat.+ Type.Family.Nat.Len c)) (a Type.Family.List.:< (b Type.Family.List.:< c))), Data.Tuple.Ops.Internal.Normalize (Data.Tuple.Ops.Internal.D (Data.Tuple.Ops.Internal.Half (Type.Family.Nat.N2 Type.Family.Nat.+ Type.Family.Nat.Len c)) (a Type.Family.List.:< (b Type.Family.List.:< c)))) => Data.Tuple.Ops.Internal.Normalize (a Type.Family.List.:< (b Type.Family.List.:< c)) instance Data.Tuple.Ops.Internal.Drop 'Type.Family.Nat.Z as instance Data.Tuple.Ops.Internal.Drop n as => Data.Tuple.Ops.Internal.Drop ('Type.Family.Nat.S n) (a : as) instance Data.Tuple.Ops.Internal.Take 'Type.Family.Nat.Z xs instance Data.Tuple.Ops.Internal.Take n as => Data.Tuple.Ops.Internal.Take ('Type.Family.Nat.S n) (a : as) instance (Data.Tuple.Ops.Internal.Linearize v, Data.Tuple.Ops.Internal.Linearize u, Data.Tuple.Ops.Internal.AppDistributive (Data.Tuple.Ops.Internal.L u)) => Data.Tuple.Ops.Internal.Linearize (u GHC.Generics.:*: v) instance Data.Tuple.Ops.Internal.AppDistributive '[] instance Data.Tuple.Ops.Internal.AppDistributive as => Data.Tuple.Ops.Internal.AppDistributive (a Type.Family.List.:< as) -- | This module define uncons. Examples are given below: -- --
-- >>> uncons (1::Int) -- (1,()) ---- --
-- >>> uncons (1::Int,'a') -- (1,'a') ---- --
-- >>> uncons (True,'a', "S")
-- (True,('a',"S"))
--
module Data.Tuple.Ops.Uncons
-- | uncons takes primitive, pair, tuple, and produces a pair of its
-- first data and the rest elements.
uncons :: Unconsable a b c => a -> (b, c)
-- | calculate the result type of uncons
-- | A constraint on any unconsable data type, where a is
-- the input type, and (b,c) is the output type
type Unconsable a b c = (Generic a, Generic b, Generic c, Uncons a ~ (b, c), Rep a ~ D1 (MetaOfD1 (Rep a)) (UnD1 (Rep a)), Rep b ~ D1 (MetaOfD1 (Rep b)) (UnD1 (Rep b)), Rep c ~ D1 (MetaOfD1 (Rep c)) (UnD1 (Rep c)), UnconsR (UnD1 (Rep a)), HeadR (UnD1 (Rep a)) ~ (UnD1 (Rep b)), TailR (UnD1 (Rep a)) ~ (UnD1 (Rep c)))
instance Data.Tuple.Ops.Uncons.UnconsR (GHC.Generics.C1 mc (GHC.Generics.S1 ms (GHC.Generics.URec a)))
instance Data.Tuple.Ops.Uncons.UnconsR (a GHC.Generics.:+: b)
instance (GHC.Generics.Generic t1, GHC.Generics.Rep t1 ~ GHC.Generics.D1 mt1 ct1, GHC.Generics.Generic t2, GHC.Generics.Rep t2 ~ GHC.Generics.D1 mt2 ct2) => Data.Tuple.Ops.Uncons.UnconsR (Data.Tuple.Ops.Uncons.RepOfPair t1 t2)
instance (Data.Tuple.Ops.Internal.Linearize (a GHC.Generics.:*: (b GHC.Generics.:*: c)), Data.Tuple.Ops.Internal.L (a GHC.Generics.:*: (b GHC.Generics.:*: c)) ~ (GHC.Generics.S1 Data.Tuple.Ops.Internal.MetaS (GHC.Generics.Rec0 t) : w), GHC.Generics.Generic t, GHC.Generics.Rep t ~ GHC.Generics.D1 hm hc, Data.Tuple.Ops.Internal.Normalize w) => Data.Tuple.Ops.Uncons.UnconsR (Data.Tuple.Ops.Uncons.RepOfTuple tcon (a GHC.Generics.:*: (b GHC.Generics.:*: c)))
-- | This module exports various operations on n-ary tuples
module Data.Tuple.Ops
instance GHC.Generics.Generic GHC.Types.Int
instance GHC.Generics.Generic GHC.Types.Word
instance GHC.Generics.Generic GHC.Types.Char
instance GHC.Generics.Generic GHC.Types.Float
instance GHC.Generics.Generic GHC.Types.Double
instance GHC.Generics.Generic (a, b, c, d, e, f, g, h)
instance GHC.Generics.Generic (a, b, c, d, e, f, g, h, i)
instance GHC.Generics.Generic (a, b, c, d, e, f, g, h, i, j)
instance GHC.Generics.Generic (a, b, c, d, e, f, g, h, i, j, k)
instance GHC.Generics.Generic (a, b, c, d, e, f, g, h, i, j, k, l)
instance GHC.Generics.Generic (a, b, c, d, e, f, g, h, i, j, k, l, m)
instance GHC.Generics.Generic (a, b, c, d, e, f, g, h, i, j, k, l, m, n)
instance GHC.Generics.Generic (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
instance GHC.Generics.Generic (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p)