The laws of Dupable are dual to those of Monoid:
1.
first consume (dup2 a) ≃ a ≃ second consume (dup2 a)(dup2 neutrality)2.
first dup2 (dup2 a) ≃ (second dup2 (dup2 a))(dup2 associativity)
where the (≃) sign represents equality up to type isomorphism.
3.
dup2 = Replicator.elim (,) . dupR(coherence between dup2 and dupR)4.
consume = Replicator.elim () . dupR(coherence between consume and dupR)5.
Replicator.extract . dupR = id(dupR identity)6.
dupR . dupR = (Replicator.map dupR) . dupR(dupR interchange)
(Laws 1-2 and 5-6 are equivalent)
Implementation of Dupable for Data.Unrestricted.Movable types should
be done with deriving via .Data.Unrestricted.AsMovable
Implementation of Dupable for other types can be done with
deriving via Generically. Note that at present this mechanism
can have performance problems for recursive parameterized types.
Specifically, the methods will not specialize to underlying Dupable
instances. See this GHC issue.
Methods
dupR :: a %1 -> Replicator aCreates a Replicator for the given
a.You usually want to define this method using Replicator's Applicative instance. For instance, here is an implementation of
Dupable [a]:instance Dupable a => Dupable [a] where dupR [] = pure [] dupR (a : as) = (:) <$> dupR a <*> dupR asdup2 :: a %1 -> (a, a)Creates two
as from aDupable a, in a linear fashion.
Instances41Dupable, …
Dupable AllDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.DupableDupable AnyDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.DupableDupable Int16Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Instances · orphanDupable Int32Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Instances · orphanDupable Int64Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Instances · orphanDupable Int8Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Instances · orphanDupable Word16Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Instances · orphanDupable Word32Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Instances · orphanDupable Word64Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Instances · orphanDupable Word8Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Instances · orphanDupable BoolDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.DupableDupable CharDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.DupableDupable DoubleDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.DupableDupable FloatDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.DupableDupable IntDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.DupableDupable OrderingDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.DupableDupable WordDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.DupableDupable PoolDefined in linear-base-0.4.0 · Foreign.Marshal.Pure.InternalDupable ()Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.DupableDupable (Array a)Defined in linear-base-0.4.0 · Data.Array.Mutable.Linear.InternalDupable (Replicator a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.DupableDupable (ReplicationStream a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.DupableDupable (Set a)Defined in linear-base-0.4.0 · Data.Set.Mutable.Linear.InternalDupable (Ur a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.DupableDupable (Vector a)Defined in linear-base-0.4.0 · Data.Vector.Mutable.Linear.InternalDupable a => Dupable (NonEmpty a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.DupableDupable a => Dupable (Product a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.DupableDupable a => Dupable (Sum a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.DupableDupable a => Dupable (Maybe a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.DupableDupable a => Dupable (MovableNum a)Defined in linear-base-0.4.0 · Data.Num.LinearDupable a => Dupable (a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.DupableDupable a => Dupable [a]Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.DupableMovable a => Dupable (AsMovable a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Instances(Generic a, GDupable (Rep a)) => Dupable (Generically a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.DupableDupable (HashMap k v)Defined in linear-base-0.4.0 · Data.HashMap.Mutable.Linear.Internal(KnownNat n, Dupable a) => Dupable (V n a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Instances · orphan(Dupable a, Dupable b) => Dupable (Either a b)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Dupable(Dupable a, Dupable b) => Dupable (a, b)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Dupable(Dupable a, Dupable b, Dupable c) => Dupable (a, b, c)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Dupable(Dupable a, Dupable b, Dupable c, Dupable d) => Dupable (a, b, c, d)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Dupable(Dupable a, Dupable b, Dupable c, Dupable d, Dupable e) => Dupable (a, b, c, d, e)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Dupable