-- 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.0 -- | This module defins operations to manipulate the generic representation -- of tuple. module Data.Tuple.Ops.Internal -- | a sentinial datatype that represents a empty product data End a End :: End a -- | Representation of tuple are shaped in a balanced tree. L -- transforms the tree into a line, for further manipulation. class Linearize (t :: * -> *) (b :: * -> *) where { type family L t b :: * -> *; } linearize :: Linearize t b => t x -> b x -> L t b x -- | base case 1. cons field with end -- | base case 2. cons field1 with field2 -- | base case 3. cons field1 with a product -- | inductive case. preppend a product with what ever -- | calculate the number of fields of a product note: undefined on -- non-product rep -- | calculate the number of fields of a product length :: a x -> Proxy (Length a) -- | calculate the half -- | calculate the half half :: KnownNat n => Proxy n -> Proxy (Half n) -- | Positive natural number in type level We rely on the SNat to define -- Take and Drop data SNat One :: SNat Succ :: SNat -> SNat -- | transform the GHC's typelit into SNat -- | transform the GHC's typelit into SNat tosnat :: KnownNat n => Proxy n -> Proxy (ToSNat n) -- | take the first n elements from a product class Take (n :: SNat) (a :: * -> *) where { type family T n a :: * -> *; } take :: Take n a => Proxy n -> a x -> T n a x -- | base case 1. take one out of singleton -- | base case 2. take one out of a product -- | inductive case. take (n+1) elements -- | drop the first n elements from a product class Drop (n :: SNat) (a :: * -> *) where { type family D n a :: * -> *; } drop :: Drop n a => Proxy n -> a x -> D n a x -- | base case 1. 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 => a x -> N a x -- | base case 1. 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 instance (GHC.TypeNats.KnownNat (Data.Tuple.Ops.Internal.Length a GHC.TypeNats.+ Data.Tuple.Ops.Internal.Length b), GHC.TypeNats.KnownNat (Data.Tuple.Ops.Internal.Half (Data.Tuple.Ops.Internal.Length a GHC.TypeNats.+ Data.Tuple.Ops.Internal.Length b)), Data.Tuple.Ops.Internal.Take (Data.Tuple.Ops.Internal.ToSNat (Data.Tuple.Ops.Internal.Half (Data.Tuple.Ops.Internal.Length a GHC.TypeNats.+ Data.Tuple.Ops.Internal.Length b))) (a GHC.Generics.:*: b), Data.Tuple.Ops.Internal.Drop (Data.Tuple.Ops.Internal.ToSNat (Data.Tuple.Ops.Internal.Half (Data.Tuple.Ops.Internal.Length a GHC.TypeNats.+ Data.Tuple.Ops.Internal.Length b))) (a GHC.Generics.:*: b), Data.Tuple.Ops.Internal.Normalize (Data.Tuple.Ops.Internal.T (Data.Tuple.Ops.Internal.ToSNat (Data.Tuple.Ops.Internal.Half (Data.Tuple.Ops.Internal.Length a GHC.TypeNats.+ Data.Tuple.Ops.Internal.Length b))) (a GHC.Generics.:*: b)), Data.Tuple.Ops.Internal.Normalize (Data.Tuple.Ops.Internal.D (Data.Tuple.Ops.Internal.ToSNat (Data.Tuple.Ops.Internal.Half (Data.Tuple.Ops.Internal.Length a GHC.TypeNats.+ Data.Tuple.Ops.Internal.Length b))) (a GHC.Generics.:*: b))) => Data.Tuple.Ops.Internal.Normalize (a GHC.Generics.:*: b) instance Data.Tuple.Ops.Internal.Linearize (GHC.Generics.S1 Data.Tuple.Ops.Internal.MetaS (GHC.Generics.Rec0 t)) Data.Tuple.Ops.Internal.End instance Data.Tuple.Ops.Internal.Linearize (GHC.Generics.S1 Data.Tuple.Ops.Internal.MetaS (GHC.Generics.Rec0 t)) (GHC.Generics.S1 Data.Tuple.Ops.Internal.MetaS (GHC.Generics.Rec0 b)) instance Data.Tuple.Ops.Internal.Linearize (GHC.Generics.S1 Data.Tuple.Ops.Internal.MetaS (GHC.Generics.Rec0 t)) (b GHC.Generics.:*: c) instance Data.Tuple.Ops.Internal.Take 'Data.Tuple.Ops.Internal.One (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.Drop 'Data.Tuple.Ops.Internal.One (a GHC.Generics.:*: b) instance Data.Tuple.Ops.Internal.Drop n b => Data.Tuple.Ops.Internal.Drop ('Data.Tuple.Ops.Internal.Succ n) (a GHC.Generics.:*: b) instance Data.Tuple.Ops.Internal.Take 'Data.Tuple.Ops.Internal.One (a GHC.Generics.:*: b) instance Data.Tuple.Ops.Internal.Take n b => Data.Tuple.Ops.Internal.Take ('Data.Tuple.Ops.Internal.Succ n) (a GHC.Generics.:*: b) instance (Data.Tuple.Ops.Internal.Linearize v b, Data.Tuple.Ops.Internal.Linearize u (Data.Tuple.Ops.Internal.L v b)) => Data.Tuple.Ops.Internal.Linearize (u GHC.Generics.:*: v) b -- | 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 :: (Generic a, Rep a ~ D1 ma ra, Uncons a ~ (b, c), Generic b, Rep b ~ D1 mb rb, Generic c, Rep c ~ D1 mc rc, UnconsR ra, HeadR ra ~ rb, TailR ra ~ rc) => a -> Uncons a
-- | calculate the result type of uncons
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 c Data.Tuple.Ops.Internal.End, Data.Tuple.Ops.Internal.Linearize b (Data.Tuple.Ops.Internal.L c Data.Tuple.Ops.Internal.End), Data.Tuple.Ops.Internal.Linearize a (Data.Tuple.Ops.Internal.L b (Data.Tuple.Ops.Internal.L c Data.Tuple.Ops.Internal.End)), Data.Tuple.Ops.Internal.L a (Data.Tuple.Ops.Internal.L b (Data.Tuple.Ops.Internal.L c Data.Tuple.Ops.Internal.End)) ~ (GHC.Generics.S1 Data.Tuple.Ops.Internal.MetaS (GHC.Generics.Rec0 t) GHC.Generics.:*: 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)