-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Math in Haskell. -- -- TODO @package noether @version 0.0.1 module Noether.Lemmata.TypeFu type ($$>) (a :: k1 -> k2 -> k3 -> k4 -> k5) (b :: k1 -> k2 -> k3 -> k4) (p :: k1) (q :: k2) (r :: k3) = a p q r (b p q r) module Noether.Lemmata.TypeFu.Set type TSet s = Nub (Sort s) type TSet' s = Sort s module Noether.Lemmata.TypeFu.DList data The k (x :: k) The :: The k data Tagged (s :: Symbol) k (x :: k) Tagged :: Tagged k data DList (xs :: [Type]) :: Type [Nil] :: DList '[] [Tag] :: The Symbol s -> The k x -> DList xs -> DList (Tagged s k x : xs) nil :: DList '[] data Foo Bar :: Foo Baz :: Foo type (**) k (x :: k) = (The :: The k x) type (~>) (s :: Symbol) (the :: The k x) = Tag (The :: The Symbol s) the type (|-|) a b = a b type (|<|) a b = a (b Nil) type (|>|) a b = Conv (a b) newtype DList_ xs DList_ :: (Proxy (Sort xs)) -> DList_ xs type B = ("index" ~> (Nat ** 1)) |-| (("type" ~> (Type ** Type)) |-| (("afoo" ~> (Nat ** 2)) |-| (("akoe" ~> (Nat ** 2)) |-| (("pqr" ~> (Type ** (Type -> Type))) |<| ("aardvark" ~> ([Type] ** '[Type])))))) type A = ("index" ~> (Nat ** 1)) |>| (("type" ~> (Type ** Type)) |-| (("afoo" ~> (Nat ** 2)) |-| (("akoe" ~> (Nat ** 2)) |-| (("pqr" ~> (Type ** (Type -> Type))) |<| ("aardvark" ~> ([Type] ** (("b" ~> (Type ** Nat)) |>| (("aa" ~> (Type ** (Type, Type))) |<| ("a" ~> (Nat ** 1)))))))))) class A__ (a :: [Type]) (b :: Type) | a -> b data ATag data BTag class A_ (a :: [Type]) f :: A__ A ATag => Proxy Nat a :: Proxy A instance a ~ Noether.Lemmata.TypeFu.DList.A => Noether.Lemmata.TypeFu.DList.A_ a instance Noether.Lemmata.TypeFu.DList.A_ a => Noether.Lemmata.TypeFu.DList.A__ a Noether.Lemmata.TypeFu.DList.ATag module Noether.Lemmata.TypeFu.Map type (<+>) m n = TMap (m ++ n) type TMap m = Nub (Sort m) type TMap' m = Sort m data (:=) (k :: k1) (v :: k2) module Noether.Lemmata.Prelude fromInteger :: Num a => Integer -> a fromString :: IsString a => String -> a -- | Flexible, extensible notions of equality supporting "custom deriving -- strategies". -- -- This module is, as of now, completely separate from the rest of the -- codebase (which was developed later, using ideas first tested here). -- -- There are no incoherent or even overlapping instances anywhere here. -- The ideas are based off of the "Advanced Overlap" page on the Haskell -- wiki: https://wiki.haskell.org/GHC/AdvancedOverlap, and were -- inspired by the observation that the overlapping instances there could -- be completely replaced with not-necessarily-closed type families. -- -- This last point is crucial for Noether, which aspires to be a library -- that people can use for their own work. The closed-TF approach of -- declaring how a couple standard types are compared, putting a -- catch-all case after those to handle everything else (all in the core -- library), and then calling it a day isn't really sensible, then, for -- obvious reasons. -- -- I have some prototype Oleg-style "guided resolution" in development -- that seems to be promising, and I think this approach, together with -- the former, can be used to handle (instances of typeclasses -- representing) algebraic structures on types without the incoherent -- nonsense in place currently. module Noether.Equality -- | This represents the unique "equality strategy" to be used for -- a. -- -- There may be many different notions of equality that can be applied to -- a particular type, and instances of the Equality family are -- used to disambiguate those by specifying which one to use. -- | Different notions of equality can have different "results". For -- instance, standard Eq-style "tired" equality returns Bool values, -- whereas a more numerically "wired" implementation for floating-point -- numbers could instead use tolerances/"epsilons" to compare things. -- -- This is reminiscent of subhask-ish things (in particular, the -- all-pervasive Logic type family). type EquateResult' a = EquateResult (Equality a) a type EquateAs' a = EquateAs (Equality a) a -- | This is the user-facing Eq replacement class. -- -- The Eq a/EquateAs s a trick is straight off the GHC wiki, as I said, -- although we can now use proxies instead of slinging undefineds -- around :) class Eq a (==) :: Eq a => a -> a -> EquateResult' a -- | An instance of this class defines a way to equate two terms of a given -- type according to a given "strategy" s. class EquateAs s a equateAs :: EquateAs s a => Proxy# s -> a -> a -> EquateResult s a data PreludeEq data Numeric data Approximate data Common a -- | The Composite strategy just uses the canonical strategies on -- each "slot" of the tuple and returns a tuple of results. -- -- It's ... sort of lazy. data Composite a b data Explicit (s :: k) data Modulo (n :: Nat) -- | Lightweight equality for newtypes using Coercible from -- Coerce. -- -- This is so, so wonderful. (Well, now that the complaints about -- differing representations have gone away, anyway.) data CoerceFrom a s type CoerceFrom' a = CoerceFrom a (Equality a) instance (Noether.Equality.EquateAs s a, s ~ Noether.Equality.Equality a) => Noether.Equality.Eq a instance GHC.Classes.Eq a => Noether.Equality.EquateAs Noether.Equality.PreludeEq a instance (GHC.Classes.Eq a, GHC.Num.Num a) => Noether.Equality.EquateAs Noether.Equality.Numeric a instance (GHC.Num.Num a, GHC.Classes.Ord a) => Noether.Equality.EquateAs Noether.Equality.Approximate a instance Noether.Equality.EquateAs Noether.Equality.Approximate a => Noether.Equality.EquateAs (Noether.Equality.Common Noether.Equality.Approximate) (a, a) instance (Noether.Equality.EquateAs Noether.Equality.Numeric a, Noether.Equality.EquateAs Noether.Equality.Numeric a) => Noether.Equality.EquateAs (Noether.Equality.Common Noether.Equality.Numeric) (a, a) instance (Noether.Equality.EquateAs Noether.Equality.PreludeEq a, Noether.Equality.EquateAs Noether.Equality.PreludeEq a) => Noether.Equality.EquateAs (Noether.Equality.Common Noether.Equality.PreludeEq) (a, a) instance (Noether.Equality.EquateAs l a, Noether.Equality.EquateAs r b) => Noether.Equality.EquateAs (Noether.Equality.Composite l r) (a, b) instance GHC.TypeLits.KnownNat n => Noether.Equality.EquateAs (Noether.Equality.Explicit (Noether.Equality.Modulo n)) GHC.Types.Int instance (Noether.Equality.EquateAs s a, GHC.Types.Coercible b a) => Noether.Equality.EquateAs (Noether.Equality.CoerceFrom a s) b module Noether.Equality.Tutorial testInt :: Bool testDouble :: (Bool, Bool) test1 :: Double -> Bool newtype Dbl Dbl :: Double -> Dbl test2 :: Bool newtype Dbl' Dbl' :: Double -> Dbl' test3 :: Bool test4 :: (Bool, Bool) newtype Mod (n :: Nat) Mod :: Int -> Mod test5 :: Bool module Noether.Algebra.Vector.Tags data VectorLift data UVectorLift data BVectorLift data SVectorLift data MVectorLift data SMVectorLift data UMVectorLift module Noether.Algebra.Tags data BinaryNumeric Add :: BinaryNumeric Mul :: BinaryNumeric data BinaryBoolean And :: BinaryBoolean Or :: BinaryBoolean Xor :: BinaryBoolean -- | Oh, Either... data Side L :: Side R :: Side data FunctionLift FunctionLift :: FunctionLift module Noether.Algebra.Subtyping class Subtype a b embed :: Subtype a b => a -> b embed :: Subtype a b => a -> b module Noether.Algebra.Single.Synonyms module Noether.Algebra.Single.Neutral data NeutralE NeutralPrim :: NeutralE NeutralNum :: NeutralE NeutralNamed :: Symbol -> NeutralE -> NeutralE NeutralTagged :: Type -> NeutralE -> NeutralE class NeutralK (op :: k) a (s :: NeutralE) neutralK :: NeutralK op a s => Proxy op -> Proxy s -> a type Neutral op a = NeutralK op a (NeutralS op a) instance GHC.Num.Num a => Noether.Algebra.Single.Neutral.NeutralK 'Noether.Algebra.Tags.Add a 'Noether.Algebra.Single.Neutral.NeutralNum instance GHC.Num.Num a => Noether.Algebra.Single.Neutral.NeutralK 'Noether.Algebra.Tags.Mul a 'Noether.Algebra.Single.Neutral.NeutralNum instance Noether.Algebra.Single.Neutral.NeutralK 'Noether.Algebra.Tags.And GHC.Types.Bool 'Noether.Algebra.Single.Neutral.NeutralPrim instance Noether.Algebra.Single.Neutral.NeutralK 'Noether.Algebra.Tags.Or GHC.Types.Bool 'Noether.Algebra.Single.Neutral.NeutralPrim instance forall k (sym :: GHC.Types.Symbol) (op :: k) a (s :: Noether.Algebra.Single.Neutral.NeutralE). (GHC.TypeLits.KnownSymbol sym, Noether.Algebra.Single.Neutral.NeutralK op a s) => Noether.Algebra.Single.Neutral.NeutralK op a ('Noether.Algebra.Single.Neutral.NeutralNamed sym s) module Noether.Algebra.Single.Magma data MagmaE MagmaPrim :: MagmaE MagmaNum :: MagmaE MagmaNamed :: Symbol -> MagmaE -> MagmaE MagmaTagged :: Type -> MagmaE -> MagmaE class MagmaK (op :: k) a (s :: MagmaE) binaryOpK :: MagmaK op a s => Proxy op -> Proxy s -> a -> a -> a type Magma op a = MagmaK op a (MagmaS op a) instance GHC.Num.Num a => Noether.Algebra.Single.Magma.MagmaK 'Noether.Algebra.Tags.Add a 'Noether.Algebra.Single.Magma.MagmaNum instance GHC.Num.Num a => Noether.Algebra.Single.Magma.MagmaK 'Noether.Algebra.Tags.Mul a 'Noether.Algebra.Single.Magma.MagmaNum instance Noether.Algebra.Single.Magma.MagmaK 'Noether.Algebra.Tags.And GHC.Types.Bool 'Noether.Algebra.Single.Magma.MagmaPrim instance Noether.Algebra.Single.Magma.MagmaK 'Noether.Algebra.Tags.Or GHC.Types.Bool 'Noether.Algebra.Single.Magma.MagmaPrim instance forall k (op :: k) a (s :: Noether.Algebra.Single.Magma.MagmaE) (sym :: GHC.Types.Symbol). Noether.Algebra.Single.Magma.MagmaK op a s => Noether.Algebra.Single.Magma.MagmaK op a ('Noether.Algebra.Single.Magma.MagmaNamed sym s) instance forall k (op :: k) a (s :: Noether.Algebra.Single.Magma.MagmaE) i. Noether.Algebra.Single.Magma.MagmaK op a s => Noether.Algebra.Single.Magma.MagmaK op (i -> a) ('Noether.Algebra.Single.Magma.MagmaTagged Noether.Algebra.Tags.FunctionLift s) module Noether.Algebra.Single.Semigroup data SemigroupE Semigroup_Magma :: MagmaE -> SemigroupE SemigroupNamed :: Symbol -> SemigroupE -> SemigroupE class SemigroupK (op :: k) a (s :: SemigroupE) type SemigroupC op a = SemigroupK op a (SemigroupS op a) instance forall k (op :: k) a (s :: Noether.Algebra.Single.Magma.MagmaE). Noether.Algebra.Single.Magma.MagmaK op a s => Noether.Algebra.Single.Semigroup.SemigroupK op a ('Noether.Algebra.Single.Semigroup.Semigroup_Magma s) instance forall k k1 (sym :: GHC.Types.Symbol) (op :: k1) (a :: k) (s :: Noether.Algebra.Single.Semigroup.SemigroupE). (GHC.TypeLits.KnownSymbol sym, Noether.Algebra.Single.Semigroup.SemigroupK op a s) => Noether.Algebra.Single.Semigroup.SemigroupK op a ('Noether.Algebra.Single.Semigroup.SemigroupNamed sym s) module Noether.Algebra.Single.Monoid data MonoidE Monoid_Semigroup_Neutral :: SemigroupE -> NeutralE -> MonoidE MonoidNamed :: Symbol -> MonoidE -> MonoidE class MonoidK (op :: k) a (s :: MonoidE) type MonoidC op a = MonoidK op a (MonoidS op a) instance forall k (op :: k) a (zs :: Noether.Algebra.Single.Semigroup.SemigroupE) (zn :: Noether.Algebra.Single.Neutral.NeutralE). (Noether.Algebra.Single.Semigroup.SemigroupK op a zs, Noether.Algebra.Single.Neutral.NeutralK op a zn) => Noether.Algebra.Single.Monoid.MonoidK op a ('Noether.Algebra.Single.Monoid.Monoid_Semigroup_Neutral zs zn) instance forall k k1 (sym :: GHC.Types.Symbol) (op :: k1) (a :: k) (s :: Noether.Algebra.Single.Monoid.MonoidE). (GHC.TypeLits.KnownSymbol sym, Noether.Algebra.Single.Monoid.MonoidK op a s) => Noether.Algebra.Single.Monoid.MonoidK op a ('Noether.Algebra.Single.Monoid.MonoidNamed sym s) module Noether.Algebra.Single.Commutative data CommutativeE CommutativeNum :: CommutativeE CommutativeNamed :: Symbol -> CommutativeE -> CommutativeE CommutativeTagged :: Type -> CommutativeE -> CommutativeE class CommutativeK (op :: k) a (s :: CommutativeE) type Commutative op a = CommutativeK op a (CommutativeS op a) instance GHC.Num.Num a => Noether.Algebra.Single.Commutative.CommutativeK 'Noether.Algebra.Tags.Add a 'Noether.Algebra.Single.Commutative.CommutativeNum instance GHC.Num.Num a => Noether.Algebra.Single.Commutative.CommutativeK 'Noether.Algebra.Tags.Mul a 'Noether.Algebra.Single.Commutative.CommutativeNum instance forall k k1 (sym :: GHC.Types.Symbol) (op :: k1) (a :: k) (s :: Noether.Algebra.Single.Commutative.CommutativeE). (GHC.TypeLits.KnownSymbol sym, Noether.Algebra.Single.Commutative.CommutativeK op a s) => Noether.Algebra.Single.Commutative.CommutativeK op a ('Noether.Algebra.Single.Commutative.CommutativeNamed sym s) instance forall k k1 (op :: k1) (a :: k) (s :: Noether.Algebra.Single.Commutative.CommutativeE) tag. Noether.Algebra.Single.Commutative.CommutativeK op a s => Noether.Algebra.Single.Commutative.CommutativeK op a ('Noether.Algebra.Single.Commutative.CommutativeTagged tag s) module Noether.Algebra.Single.Cancellative data CancellativeE CancellativeNum :: CancellativeE CancellativeFractional :: CancellativeE CancellativeNamed :: Symbol -> CancellativeE -> CancellativeE CancellativeTagged :: Type -> CancellativeE -> CancellativeE class CancellativeK (op :: k) a (s :: CancellativeE) cancelK :: CancellativeK op a s => Proxy op -> Proxy s -> a -> a type Cancellative op a = CancellativeK op a (CancellativeS op a) instance GHC.Num.Num a => Noether.Algebra.Single.Cancellative.CancellativeK 'Noether.Algebra.Tags.Add a 'Noether.Algebra.Single.Cancellative.CancellativeNum instance GHC.Real.Fractional a => Noether.Algebra.Single.Cancellative.CancellativeK 'Noether.Algebra.Tags.Mul a 'Noether.Algebra.Single.Cancellative.CancellativeFractional instance forall k (sym :: GHC.Types.Symbol) (op :: k) a (s :: Noether.Algebra.Single.Cancellative.CancellativeE). (GHC.TypeLits.KnownSymbol sym, Noether.Algebra.Single.Cancellative.CancellativeK op a s) => Noether.Algebra.Single.Cancellative.CancellativeK op a ('Noether.Algebra.Single.Cancellative.CancellativeNamed sym s) instance forall k (op :: k) a (s :: Noether.Algebra.Single.Cancellative.CancellativeE) i. Noether.Algebra.Single.Cancellative.CancellativeK op a s => Noether.Algebra.Single.Cancellative.CancellativeK op (i -> a) ('Noether.Algebra.Single.Cancellative.CancellativeTagged Noether.Algebra.Tags.FunctionLift s) module Noether.Algebra.Single.Group data GroupE Group_Monoid_Cancellative :: MonoidE -> CancellativeE -> GroupE GroupNamed :: Symbol -> GroupE -> GroupE class GroupK (op :: k) a (s :: GroupE) type GroupC op a = GroupK op a (GroupS op a) instance forall k (op :: k) a (zm :: Noether.Algebra.Single.Monoid.MonoidE) (zl :: Noether.Algebra.Single.Cancellative.CancellativeE). (Noether.Algebra.Single.Monoid.MonoidK op a zm, Noether.Algebra.Single.Cancellative.CancellativeK op a zl) => Noether.Algebra.Single.Group.GroupK op a ('Noether.Algebra.Single.Group.Group_Monoid_Cancellative zm zl) instance forall k k1 (sym :: GHC.Types.Symbol) (op :: k1) (a :: k) (s :: Noether.Algebra.Single.Group.GroupE). (GHC.TypeLits.KnownSymbol sym, Noether.Algebra.Single.Group.GroupK op a s) => Noether.Algebra.Single.Group.GroupK op a ('Noether.Algebra.Single.Group.GroupNamed sym s) module Noether.Algebra.Single.AbelianGroup data AbelianGroupE AbelianGroup_Commutative_Group :: CommutativeE -> GroupE -> AbelianGroupE AbelianGroupNamed :: Symbol -> AbelianGroupE -> AbelianGroupE class AbelianGroupK (op :: k) a (s :: AbelianGroupE) type AbelianGroupC op a = AbelianGroupK op a (AbelianGroupS op a) instance forall k k1 (op :: k1) (a :: k) (zm :: Noether.Algebra.Single.Group.GroupE) (zl :: Noether.Algebra.Single.Commutative.CommutativeE). (Noether.Algebra.Single.Group.GroupK op a zm, Noether.Algebra.Single.Commutative.CommutativeK op a zl) => Noether.Algebra.Single.AbelianGroup.AbelianGroupK op a ('Noether.Algebra.Single.AbelianGroup.AbelianGroup_Commutative_Group zl zm) instance forall k k1 (sym :: GHC.Types.Symbol) (op :: k1) (a :: k) (s :: Noether.Algebra.Single.AbelianGroup.AbelianGroupE). (GHC.TypeLits.KnownSymbol sym, Noether.Algebra.Single.AbelianGroup.AbelianGroupK op a s) => Noether.Algebra.Single.AbelianGroup.AbelianGroupK op a ('Noether.Algebra.Single.AbelianGroup.AbelianGroupNamed sym s) module Noether.Algebra.Single.Strategies type Semigroup op a = (SemigroupC op a, Magma op a) type Monoid op a = (MonoidC op a, Semigroup op a, Neutral op a) type Group op a = (GroupC op a, Monoid op a, Cancellative op a) type AbelianGroup op a = (AbelianGroupC op a, Group op a, Commutative op a) type DeriveMagma_Tagged tag op a = MagmaTagged tag (MagmaS op a) type DeriveMagma_Named tag op a = MagmaNamed tag (MagmaS op a) type DeriveCommutative_Tagged tag op a = CommutativeTagged tag (CommutativeS op a) type DeriveCancellative_Tagged tag op a = CancellativeTagged tag (CancellativeS op a) type DeriveNeutral_Tagged tag op a = NeutralTagged tag (NeutralS op a) type DeriveSemigroup_Magma (t :: k) (a :: Type) = Semigroup_Magma (MagmaS t a) type DeriveMonoid_Semigroup_Neutral t a = Monoid_Semigroup_Neutral (SemigroupS t a) (NeutralS t a) type DeriveGroup_Monoid_Cancellative t a = Group_Monoid_Cancellative (MonoidS t a) (CancellativeS t a) type DeriveAbelianGroup_Commutative_Group t a = AbelianGroup_Commutative_Group (CommutativeS t a) (GroupS t a) type DeriveAbelianGroup_Commutative_Monoid_Cancellative t a = AbelianGroup_Commutative_Group (CommutativeS t a) (DeriveGroup_Monoid_Cancellative t a) data ComplexLift module Noether.Algebra.Single.API cancel :: forall op a. Cancellative op a => Proxy op -> a -> a binaryOp :: forall op a. Magma op a => Proxy op -> a -> a -> a neutral :: forall op a. Neutral op a => Proxy op -> a zero :: Neutral Add a => a one :: Neutral Mul a => a true :: Neutral And a => a false :: Neutral Or a => a negate :: Cancellative Add a => a -> a reciprocal :: Cancellative Mul a => a -> a (+) :: Magma Add a => a -> a -> a infixl 6 + (*) :: Magma Mul a => a -> a -> a infixl 7 * (-) :: (Magma Add a, Cancellative Add a) => a -> a -> a infixl 6 - (/) :: (Magma Mul a, Cancellative Mul a) => a -> a -> a infixl 7 / (&&) :: Magma And a => a -> a -> a infixl 3 && (||) :: Magma Or a => a -> a -> a infixl 2 || module Noether.Algebra.Single module Noether.Algebra.Multiple.Semiring data SemiringE Semiring_Commutative_Monoid_Monoid :: CommutativeE -> MonoidE -> MonoidE -> SemiringE [semiring_commutative] :: SemiringE -> CommutativeE [semiring_additive_monoid] :: SemiringE -> MonoidE [semiring_multiplicative_monoid] :: SemiringE -> MonoidE SemiringNamed :: Symbol -> SemiringE -> SemiringE class SemiringK (add :: ka) (mul :: km) a (s :: SemiringE) type SemiringC p m a = (SemiringK $$> SemiringS) p m a instance forall km k ka (p :: ka) (a :: k) (zam :: Noether.Algebra.Single.Monoid.MonoidE) (zac :: Noether.Algebra.Single.Commutative.CommutativeE) (m :: km) (zbm :: Noether.Algebra.Single.Monoid.MonoidE). (Noether.Algebra.Single.Monoid.MonoidK p a zam, Noether.Algebra.Single.Commutative.CommutativeK p a zac, Noether.Algebra.Single.Monoid.MonoidK m a zbm) => Noether.Algebra.Multiple.Semiring.SemiringK p m a ('Noether.Algebra.Multiple.Semiring.Semiring_Commutative_Monoid_Monoid zac zam zbm) instance forall k km ka (sym :: GHC.Types.Symbol) (p :: ka) (m :: km) (a :: k) (s :: Noether.Algebra.Multiple.Semiring.SemiringE). (GHC.TypeLits.KnownSymbol sym, Noether.Algebra.Multiple.Semiring.SemiringK p m a s) => Noether.Algebra.Multiple.Semiring.SemiringK p m a ('Noether.Algebra.Multiple.Semiring.SemiringNamed sym s) module Noether.Algebra.Multiple.Ring data RingE Ring_Semiring_Cancellative :: SemiringE -> CancellativeE -> RingE [ring_semiring] :: RingE -> SemiringE [ring_addition_cancellative] :: RingE -> CancellativeE Ring_AbelianGroup_Group :: AbelianGroupE -> GroupE -> RingE [ring_additive_group] :: RingE -> AbelianGroupE [ring_multiplicative_group] :: RingE -> GroupE RingNamed :: Symbol -> RingE -> RingE class RingK (add :: ka) (mul :: km) a (s :: RingE) type RingC p m a = RingK p m a (RingS p m a) instance forall km ka (p :: ka) (m :: km) a (zs :: Noether.Algebra.Multiple.Semiring.SemiringE) (zpc :: Noether.Algebra.Single.Cancellative.CancellativeE). (Noether.Algebra.Multiple.Semiring.SemiringK p m a zs, Noether.Algebra.Single.Cancellative.CancellativeK p a zpc) => Noether.Algebra.Multiple.Ring.RingK p m a ('Noether.Algebra.Multiple.Ring.Ring_Semiring_Cancellative zs zpc) instance forall km k ka (p :: ka) (a :: k) (zpab :: Noether.Algebra.Single.AbelianGroup.AbelianGroupE) (m :: km) (zmg :: Noether.Algebra.Single.Group.GroupE). (Noether.Algebra.Single.AbelianGroup.AbelianGroupK p a zpab, Noether.Algebra.Single.Group.GroupK m a zmg) => Noether.Algebra.Multiple.Ring.RingK p m a ('Noether.Algebra.Multiple.Ring.Ring_AbelianGroup_Group zpab zmg) instance forall k km ka (sym :: GHC.Types.Symbol) (p :: ka) (m :: km) (a :: k) (s :: Noether.Algebra.Multiple.Ring.RingE). (GHC.TypeLits.KnownSymbol sym, Noether.Algebra.Multiple.Ring.RingK p m a s) => Noether.Algebra.Multiple.Ring.RingK p m a ('Noether.Algebra.Multiple.Ring.RingNamed sym s) module Noether.Algebra.Multiple.Strategies type Ring p m a = (RingC p m a, Group m a, AbelianGroup p a) type Semiring p m a = (SemiringC p m a, Commutative p a, Monoid p a, Monoid m a) type DeriveSemiring_Commutative_Monoid_Monoid p m a = Semiring_Commutative_Monoid_Monoid (CommutativeS p a) (MonoidS p a) (MonoidS m a) type DeriveRing_Semiring_Cancellative p m a = Ring_Semiring_Cancellative (SemiringS p m a) (CancellativeS p a) type DeriveRing_AbelianGroup_Group p m a = Ring_AbelianGroup_Group (AbelianGroupS p a) (GroupS m a) type DeriveRingDoc_AbelianGroup_Group p m a = RingNamedT (DeriveRing_AbelianGroup_Group p m a) p :: Ring Add Mul a => a -> a -> a q :: Double module Noether.Algebra.Multiple module Noether.Algebra.Inference data Synergise (a :: [k]) type Infer (t :: k) a (h :: [Symbol]) = Synergise (Nub (Sort (Infer_ t a h))) data Prim data DerivedFrom (a :: k) module Noether.Algebra.Derive data Automatic module Noether.Algebra.Actions.GroupActions module Noether.Algebra.Actions.Acts data ActsE Acts_Magma :: MagmaE -> ActsE ActsNamed :: Symbol -> ActsE -> ActsE ActsTagged :: Type -> ActsE -> ActsE class ActsK (lr :: Side) (op :: k) a b (s :: ActsE) actK :: ActsK lr op a b s => Proxy op -> Proxy s -> Proxy lr -> a -> b -> b instance forall k (op :: k) a (zm :: Noether.Algebra.Single.Magma.MagmaE) (lr :: Noether.Algebra.Tags.Side). Noether.Algebra.Single.Magma.MagmaK op a zm => Noether.Algebra.Actions.Acts.ActsK lr op a a ('Noether.Algebra.Actions.Acts.Acts_Magma zm) module Noether.Algebra.Actions.Compatible -- | A strategy-parameterized typeclass for a compatible action, where -- compatibility is defined in the group action sense. -- -- A compatible action satisfies a act (a' act b) = (a -- op a') act b class CompatibleK (lr :: Side) (op :: k1) (act :: k2) a b (s :: CompatibleE) data CompatibleE Compatible_Acts_Semigroup :: Type -> ActsE -> SemigroupE -> CompatibleE [compatible_actor] :: CompatibleE -> Type [compatible_action] :: CompatibleE -> ActsE [compatible_actor_semigroup] :: CompatibleE -> SemigroupE instance forall k1 k2 (lr :: Noether.Algebra.Tags.Side) (act :: k2) a b (za :: Noether.Algebra.Actions.Acts.ActsE) (op :: k1) (zs :: Noether.Algebra.Single.Semigroup.SemigroupE). (Noether.Algebra.Actions.Acts.ActsK lr act a b za, Noether.Algebra.Single.Semigroup.SemigroupK op a zs) => Noether.Algebra.Actions.Compatible.CompatibleK lr op act a b ('Noether.Algebra.Actions.Compatible.Compatible_Acts_Semigroup a za zs) module Noether.Algebra.Actions.Linearity data ActorLinearE ActorLinear_Acts_Semigroup_Semigroup :: ActsE -> SemigroupE -> SemigroupE -> ActorLinearE data ActeeLinearE ActeeLinear_Acts_Semigroup :: ActsE -> SemigroupE -> ActeeLinearE class ActorLinearK lr act ao a bo b (s :: ActorLinearE) class ActeeLinearK lr act a bo b (s :: ActeeLinearE) instance forall k k1 k2 (lr :: Noether.Algebra.Tags.Side) (act :: k2) a b (za :: Noether.Algebra.Actions.Acts.ActsE) (ao :: k1) (zas :: Noether.Algebra.Single.Semigroup.SemigroupE) (bo :: k) (zbs :: Noether.Algebra.Single.Semigroup.SemigroupE). (Noether.Algebra.Actions.Acts.ActsK lr act a b za, Noether.Algebra.Single.Semigroup.SemigroupK ao a zas, Noether.Algebra.Single.Semigroup.SemigroupK bo b zbs) => Noether.Algebra.Actions.Linearity.ActorLinearK lr act ao a bo b ('Noether.Algebra.Actions.Linearity.ActorLinear_Acts_Semigroup_Semigroup za zas zbs) instance forall k k1 (lr :: Noether.Algebra.Tags.Side) (act :: k1) a b (za :: Noether.Algebra.Actions.Acts.ActsE) (bo :: k) (zbs :: Noether.Algebra.Single.Semigroup.SemigroupE). (Noether.Algebra.Actions.Acts.ActsK lr act a b za, Noether.Algebra.Single.Semigroup.SemigroupK bo b zbs) => Noether.Algebra.Actions.Linearity.ActeeLinearK lr act a bo b ('Noether.Algebra.Actions.Linearity.ActeeLinear_Acts_Semigroup za zbs) module Noether.Algebra.Actions.API type CompatibleC lr op act a b = CompatibleK lr op act a b (CompatibleS lr op act a b) type Compatible lr op act a b = (CompatibleC lr op act a b, Semigroup op a, Acts lr act a b) type LeftCompatible act ao a b = Compatible L act ao a b type RightCompatible act ao a b = Compatible R act ao a b type Acts lr op a b = ActsK lr op a b (ActsS lr op a b) type LeftActs op a b = Acts L op a b type RightActs op a b = Acts R op a b type BiActs op a b = (LeftActs op a b, RightActs op a b) leftActK :: forall op s a b. ActsK L op a b s => a -> b -> b rightActK :: forall op s a b. ActsK R op a b s => a -> b -> b leftAct :: forall op a b. LeftActs op a b => a -> b -> b rightAct :: forall op a b. RightActs op a b => a -> b -> b -- |
--   (a1 `ao` a2) `act` b = (a1 `act` b) `bo` (a2 `act` b)
--   
type ActorLinearC lr act ao a bo b = ActorLinearK lr act ao a bo b (ActorLinearS lr act ao a bo b) -- |
--   a `act` (b1 `bo` b2) = (a `act` b1) `bo` (a `act` b2)
--   
type ActeeLinearC lr act a bo b = ActeeLinearK lr act a bo b (ActeeLinearS lr act a bo b) type LinearActsOn lr act ao a bo b = (ActorLinearC lr act ao a bo b, ActeeLinearC lr act a bo b, Acts lr act a b, Semigroup ao a, Semigroup bo b) type LinearActs act ao a bo b = (LinearActsOn L act ao a bo b, LinearActsOn R act ao a bo b) type LeftLinear act ao a bo b = LinearActsOn L act ao a bo b type RightLinear act ao a bo b = LinearActsOn R act ao a bo b module Noether.Algebra.Actions.Strategies type DeriveActs_Tagged tag lr op a b = ActsTagged tag (ActsS lr op a b) type DeriveActs_Magma op a = Acts_Magma (MagmaS op a) type DeriveCompatible_Acts_Semigroup lr op act a b = Compatible_Acts_Semigroup a (ActsS lr act a b) (SemigroupS op a) -- | a + (b + c) = (a + b) + c type DeriveCompatible_Associativity lr op a = DeriveCompatible_Acts_Semigroup lr op op a a type DeriveActorLinearActs_Acts_Semigroup_Semigroup lr act ao a bo b = ActorLinear_Acts_Semigroup_Semigroup (ActsS lr act a b) (SemigroupS ao a) (SemigroupS bo b) type DeriveActeeLinearActs_Acts_Semigroup lr act a bo b = ActeeLinear_Acts_Semigroup (ActsS lr act a b) (SemigroupS bo b) -- | (a + b) * c = a * c + b * c type DeriveActorLinearActs_LeftDistributivity lr p m a = DeriveActorLinearActs_Acts_Semigroup_Semigroup lr m p a p a -- | a * (b + c) = a * b + a * c type DeriveActeeLinearActs_RightDistributivity lr p m a = DeriveActeeLinearActs_Acts_Semigroup lr m a p a module Noether.Algebra.Actions module Noether.Algebra.Linear.Module data LeftModuleE LeftModule_Ring_AbelianGroup_Linear_Compatible :: RingE -> AbelianGroupE -> ActorLinearE -> ActeeLinearE -> CompatibleE -> LeftModuleE [leftModule_ring] :: LeftModuleE -> RingE [leftModule_abelianGroup] :: LeftModuleE -> AbelianGroupE [leftModule_actorLinearity] :: LeftModuleE -> ActorLinearE [leftModule_acteeLinearity] :: LeftModuleE -> ActeeLinearE [leftModule_compatibility] :: LeftModuleE -> CompatibleE LeftModule_Named :: Symbol -> LeftModuleE -> LeftModuleE -- | A left module (v, a) over the ring (r, p, m). class LeftModuleK op p m r a v s type LeftModuleC op p m r a v = LeftModuleK op p m r a v (LeftModuleS op p m r a v) type LeftModule op p m r a v = (LeftModuleC op p m r a v, Ring p m r, AbelianGroup a v, LinearActsOn L m p r a v, LeftCompatible op m r v) data RightModuleE RightModule_Ring_AbelianGroup_Linear_Compatible :: RingE -> AbelianGroupE -> ActorLinearE -> ActeeLinearE -> CompatibleE -> RightModuleE [rightModule_ring] :: RightModuleE -> RingE [rightModule_abelianGroup] :: RightModuleE -> AbelianGroupE [rightModule_actorLinearity] :: RightModuleE -> ActorLinearE [rightModule_acteeLinearity] :: RightModuleE -> ActeeLinearE [rightModule_compatibility] :: RightModuleE -> CompatibleE RightModule_Named :: Symbol -> RightModuleE -> RightModuleE -- | A right module (v, a) over the ring (r, p, m). class RightModuleK op p m r a v s type RightModuleC op p m r a v = RightModuleK op p m r a v (RightModuleS op p m r a v) type RightModule op p m r a v = (RightModuleC op p m r a v, Ring p m r, AbelianGroup a v, LinearActsOn R m p r a v, RightCompatible op m r v) instance forall k k1 k2 k3 k4 k5 (p :: k5) (m :: k4) (r :: k3) (zr :: Noether.Algebra.Multiple.Ring.RingE) (a :: k2) (v :: k1) (zag :: Noether.Algebra.Single.AbelianGroup.AbelianGroupE) (zor :: Noether.Algebra.Actions.Linearity.ActorLinearE) (zee :: Noether.Algebra.Actions.Linearity.ActeeLinearE) (op :: k) (zlc :: Noether.Algebra.Actions.Compatible.CompatibleE). (Noether.Algebra.Multiple.Ring.RingK p m r zr, Noether.Algebra.Single.AbelianGroup.AbelianGroupK a v zag, Noether.Algebra.Actions.Linearity.ActorLinearK 'Noether.Algebra.Tags.L m p r a v zor, Noether.Algebra.Actions.Linearity.ActeeLinearK 'Noether.Algebra.Tags.L m r a v zee, Noether.Algebra.Actions.Compatible.CompatibleK 'Noether.Algebra.Tags.L op m r v zlc) => Noether.Algebra.Linear.Module.LeftModuleK op p m r a v ('Noether.Algebra.Linear.Module.LeftModule_Ring_AbelianGroup_Linear_Compatible zr zag zor zee zlc) instance forall k k1 k2 k3 k4 k5 (p :: k5) (m :: k4) (r :: k3) (zr :: Noether.Algebra.Multiple.Ring.RingE) (a :: k2) (v :: k1) (zag :: Noether.Algebra.Single.AbelianGroup.AbelianGroupE) (zor :: Noether.Algebra.Actions.Linearity.ActorLinearE) (zee :: Noether.Algebra.Actions.Linearity.ActeeLinearE) (op :: k) (zrc :: Noether.Algebra.Actions.Compatible.CompatibleE). (Noether.Algebra.Multiple.Ring.RingK p m r zr, Noether.Algebra.Single.AbelianGroup.AbelianGroupK a v zag, Noether.Algebra.Actions.Linearity.ActorLinearK 'Noether.Algebra.Tags.R m p r a v zor, Noether.Algebra.Actions.Linearity.ActeeLinearK 'Noether.Algebra.Tags.R m r a v zee, Noether.Algebra.Actions.Compatible.CompatibleK 'Noether.Algebra.Tags.R op m r v zrc) => Noether.Algebra.Linear.Module.RightModuleK op p m r a v ('Noether.Algebra.Linear.Module.RightModule_Ring_AbelianGroup_Linear_Compatible zr zag zor zee zrc) module Noether.Algebra.Linear.Strategies type DeriveLeftModule_Ring_AbelianGroup op p m r a v = LeftModule_Ring_AbelianGroup_Linear_Compatible (RingS p m r) (AbelianGroupS a v) (ActorLinearS L m p r a v) (ActeeLinearS L m r a v) (CompatibleS L op m r v) type DeriveLeftModule_Self p m r = DeriveLeftModule_Ring_AbelianGroup m p m r p r type DeriveRightModule_Ring_AbelianGroup op p m r a v = RightModule_Ring_AbelianGroup_Linear_Compatible (RingS p m r) (AbelianGroupS a v) (ActorLinearS R m p r a v) (ActeeLinearS R m r a v) (CompatibleS R op m r v) type DeriveRightModule_Self p m r = DeriveRightModule_Ring_AbelianGroup m p m r p r module Noether.Algebra.Linear.API (%<) :: LeftActs Mul r v => r -> v -> v (>%) :: RightActs Mul r v => v -> r -> v -- | Locally use the left self-action induced by the multiplicative magma -- structure of the ring, whatever structure the user may have chosen to -- use globally. -- --
--   a %<~ b = a * b
--   
(%<~) :: forall r. Ring Add Mul r => r -> r -> r -- | Locally use the right self-action induced by the multiplicative magma -- structure of the ring, whatever structure the user may have chosen to -- use globally. -- --
--   b ~>% a = a * b
--   
(~>%) :: forall r. Ring Add Mul r => r -> r -> r -- | Linear interpolation. -- --
--   lerp λ v w = λv + (1 - λ)w
--   
lerp :: (Neutral Mul r, Cancellative Add r, Magma Add r, Magma Add a, Acts R Mul r a, Acts L Mul r a) => r -> a -> a -> a module Noether.Algebra.Linear module Noether.Algebra.Vector.Generic gBinaryOpK :: forall v a s op z. (MagmaK op a s, Vector v a, Coercible v z) => Proxy op -> z a -> z a -> z a gCancelK :: forall v a s op z. (CancellativeK op a s, Vector v a, Coercible v z) => Proxy op -> z a -> z a gActK :: forall v a b s lr op z. (ActsK lr op a b s, Vector v b, Coercible v z) => Proxy op -> a -> z b -> z b gNeutralK :: forall n v a s op b. (NeutralK op a s, KnownNat n, Vector v a, Coercible v (b n)) => Proxy op -> b n a module Noether.Algebra.Vector.Boxed -- | BVector n v ≅ v^n. newtype BVector (n :: k) v BVector :: (Vector v) -> BVector v unsafeFromList :: [a] -> BVector n a unsafeChangeDimension :: forall k l (m :: k) (n :: l) a. BVector m a -> BVector n a -- | Lifting addition and multiplication coordinatewise (Hadamard?) -- | Neutral elements for addition and multiplication. -- | Pointwise negation and inversion. -- -- Note that v^n has (a lot of) nontrivial zerodivisors even if v does -- not. The zerodivisors are all elements with a zero(divisor) in some -- coordinate, e.g. (1,0) and (0,1) are zerodivisors in R^2. -- -- (This corresponds to the idea that the Spec of a product ring is -- disconnected!) -- | Actions of a on b extend to actions of a on 'BVector n b'. instance forall k (n :: k) v. GHC.Show.Show v => GHC.Show.Show (Noether.Algebra.Vector.Boxed.BVector n v) instance forall k k1 (op :: k1) v (s :: Noether.Algebra.Single.Magma.MagmaE) (n :: k). Noether.Algebra.Single.Magma.MagmaK op v s => Noether.Algebra.Single.Magma.MagmaK op (Noether.Algebra.Vector.Boxed.BVector n v) ('Noether.Algebra.Single.Magma.MagmaTagged Noether.Algebra.Vector.Tags.BVectorLift s) instance forall k (n :: GHC.Types.Nat) (op :: k) v (s :: Noether.Algebra.Single.Neutral.NeutralE). (GHC.TypeLits.KnownNat n, Noether.Algebra.Single.Neutral.NeutralK op v s) => Noether.Algebra.Single.Neutral.NeutralK op (Noether.Algebra.Vector.Boxed.BVector n v) ('Noether.Algebra.Single.Neutral.NeutralTagged Noether.Algebra.Vector.Tags.BVectorLift s) instance forall k k1 (op :: k1) v (s :: Noether.Algebra.Single.Cancellative.CancellativeE) (n :: k). Noether.Algebra.Single.Cancellative.CancellativeK op v s => Noether.Algebra.Single.Cancellative.CancellativeK op (Noether.Algebra.Vector.Boxed.BVector n v) ('Noether.Algebra.Single.Cancellative.CancellativeTagged Noether.Algebra.Vector.Tags.BVectorLift s) instance forall k k1 (lr :: Noether.Algebra.Tags.Side) (op :: k1) a b (s :: Noether.Algebra.Actions.Acts.ActsE) (n :: k). Noether.Algebra.Actions.Acts.ActsK lr op a b s => Noether.Algebra.Actions.Acts.ActsK lr op a (Noether.Algebra.Vector.Boxed.BVector n b) ('Noether.Algebra.Actions.Acts.ActsTagged Noether.Algebra.Vector.Tags.BVectorLift s) -- | A work-in-progress tutorial for Noether vectors. -- -- This module demonstrates creating vectors, using simple operators to -- transform them, and techniques that leverage type system features to -- provide improved correctness guarantees. module Noether.Algebra.Vector.Tutorial module Noether.Algebra.Vector.Unboxed -- | UVector n v ≅ v^n for Unbox types v. newtype UVector (n :: Nat) v UVector :: (Vector v) -> UVector v -- | Lifting addition and multiplication coordinatewise (Hadamard?) -- | Neutral elements for addition and multiplication. -- | Pointwise negation and inversion. -- -- Note that v^n has (a lot of) nontrivial zerodivisors even if v does -- not. The zerodivisors are all elements with a zero(divisor) in some -- coordinate, e.g. (1,0) and (0,1) are zerodivisors in R^2. -- -- (This corresponds to the idea that the Spec of a product ring is -- disconnected!) -- | Actions of a on b extend to actions of a on 'UVector n b'. v :: UVector 10 Double w :: UVector 10 Double f :: (MagmaK BinaryNumeric Mul a (MagmaS BinaryNumeric Mul a), MagmaK BinaryNumeric Add a (MagmaS BinaryNumeric Add a), CancellativeK BinaryNumeric Add a (CancellativeS BinaryNumeric Add a)) => a -> a -- | This is equal to > UVector -- [5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0] g :: [UVector 10 Double] instance (Data.Vector.Unboxed.Base.Unbox v, GHC.Show.Show v) => GHC.Show.Show (Noether.Algebra.Vector.Unboxed.UVector n v) instance forall k v (op :: k) (s :: Noether.Algebra.Single.Magma.MagmaE) (n :: GHC.Types.Nat). (Data.Vector.Unboxed.Base.Unbox v, Noether.Algebra.Single.Magma.MagmaK op v s) => Noether.Algebra.Single.Magma.MagmaK op (Noether.Algebra.Vector.Unboxed.UVector n v) ('Noether.Algebra.Single.Magma.MagmaTagged Noether.Algebra.Vector.Tags.UVectorLift s) instance forall k v (n :: GHC.Types.Nat) (op :: k) (s :: Noether.Algebra.Single.Neutral.NeutralE). (Data.Vector.Unboxed.Base.Unbox v, GHC.TypeLits.KnownNat n, Noether.Algebra.Single.Neutral.NeutralK op v s) => Noether.Algebra.Single.Neutral.NeutralK op (Noether.Algebra.Vector.Unboxed.UVector n v) ('Noether.Algebra.Single.Neutral.NeutralTagged Noether.Algebra.Vector.Tags.UVectorLift s) instance forall k v (n :: GHC.Types.Nat) (op :: k) (s :: Noether.Algebra.Single.Cancellative.CancellativeE). (Data.Vector.Unboxed.Base.Unbox v, GHC.TypeLits.KnownNat n, Noether.Algebra.Single.Cancellative.CancellativeK op v s) => Noether.Algebra.Single.Cancellative.CancellativeK op (Noether.Algebra.Vector.Unboxed.UVector n v) ('Noether.Algebra.Single.Cancellative.CancellativeTagged Noether.Algebra.Vector.Tags.UVectorLift s) instance forall k b (n :: GHC.Types.Nat) (lr :: Noether.Algebra.Tags.Side) (op :: k) a (s :: Noether.Algebra.Actions.Acts.ActsE). (Data.Vector.Unboxed.Base.Unbox b, GHC.TypeLits.KnownNat n, Noether.Algebra.Actions.Acts.ActsK lr op a b s) => Noether.Algebra.Actions.Acts.ActsK lr op a (Noether.Algebra.Vector.Unboxed.UVector n b) ('Noether.Algebra.Actions.Acts.ActsTagged Noether.Algebra.Vector.Tags.UVectorLift s) module Lemmata.Semiring class Monoid m => Semiring m one :: Semiring m => m (<.>) :: Semiring m => m -> m -> m -- | Alias for mempty zero :: Monoid m => m module Lemmata.List head :: (Foldable f) => f a -> Maybe a ordNub :: (Ord a) => [a] -> [a] sortOn :: (Ord o) => (a -> o) -> [a] -> [a] list :: [b] -> (a -> b) -> [a] -> [b] product :: (Foldable f, Num a) => f a -> a sum :: (Foldable f, Num a) => f a -> a module Lemmata.Functor -- | The Functor class is used for types that can be mapped over. -- Instances of Functor should satisfy the following laws: -- --
--   fmap id  ==  id
--   fmap (f . g)  ==  fmap f . fmap g
--   
-- -- The instances of Functor for lists, Maybe and IO -- satisfy these laws. class Functor (f :: * -> *) fmap :: Functor f => (a -> b) -> f a -> f b -- | Replace all locations in the input with the same value. The default -- definition is fmap . const, but this may be -- overridden with a more efficient version. (<$) :: Functor f => a -> f b -> f a -- | Flipped version of <$. -- --

Examples

-- -- Replace the contents of a Maybe Int with a -- constant String: -- --
--   >>> Nothing $> "foo"
--   Nothing
--   
--   >>> Just 90210 $> "foo"
--   Just "foo"
--   
-- -- Replace the contents of an Either Int -- Int with a constant String, resulting in an -- Either Int String: -- --
--   >>> Left 8675309 $> "foo"
--   Left 8675309
--   
--   >>> Right 8675309 $> "foo"
--   Right "foo"
--   
-- -- Replace each element of a list with a constant String: -- --
--   >>> [1,2,3] $> "foo"
--   ["foo","foo","foo"]
--   
-- -- Replace the second element of a pair with a constant String: -- --
--   >>> (1,2) $> "foo"
--   (1,"foo")
--   
($>) :: Functor f => f a -> b -> f b infixl 4 $> -- | An infix synonym for fmap. -- -- The name of this operator is an allusion to $. Note the -- similarities between their types: -- --
--    ($)  ::              (a -> b) ->   a ->   b
--   (<$>) :: Functor f => (a -> b) -> f a -> f b
--   
-- -- Whereas $ is function application, <$> is -- function application lifted over a Functor. -- --

Examples

-- -- Convert from a Maybe Int to a -- Maybe String using show: -- --
--   >>> show <$> Nothing
--   Nothing
--   
--   >>> show <$> Just 3
--   Just "3"
--   
-- -- Convert from an Either Int Int to -- an Either Int String using -- show: -- --
--   >>> show <$> Left 17
--   Left 17
--   
--   >>> show <$> Right 17
--   Right "17"
--   
-- -- Double each element of a list: -- --
--   >>> (*2) <$> [1,2,3]
--   [2,4,6]
--   
-- -- Apply even to the second element of a pair: -- --
--   >>> even <$> (2,2)
--   (2,True)
--   
(<$>) :: Functor f => (a -> b) -> f a -> f b infixl 4 <$> (<<$>>) :: (Functor f, Functor g) => (a -> b) -> f (g a) -> f (g b) infixl 4 <<$>> -- | void value discards or ignores the result of -- evaluation, such as the return value of an IO action. -- --

Examples

-- -- Replace the contents of a Maybe Int with -- unit: -- --
--   >>> void Nothing
--   Nothing
--   
--   >>> void (Just 3)
--   Just ()
--   
-- -- Replace the contents of an Either Int -- Int with unit, resulting in an Either -- Int '()': -- --
--   >>> void (Left 8675309)
--   Left 8675309
--   
--   >>> void (Right 8675309)
--   Right ()
--   
-- -- Replace every element of a list with unit: -- --
--   >>> void [1,2,3]
--   [(),(),()]
--   
-- -- Replace the second element of a pair with unit: -- --
--   >>> void (1,2)
--   (1,())
--   
-- -- Discard the result of an IO action: -- --
--   >>> mapM print [1,2]
--   1
--   2
--   [(),()]
--   
--   >>> void $ mapM print [1,2]
--   1
--   2
--   
void :: Functor f => f a -> f () module Lemmata.Either maybeToLeft :: r -> Maybe l -> Either l r maybeToRight :: l -> Maybe r -> Either l r leftToMaybe :: Either l r -> Maybe l rightToMaybe :: Either l r -> Maybe r maybeToEither :: Monoid b => (a -> b) -> Maybe a -> b module Lemmata.Bool whenM :: Monad m => m Bool -> m () -> m () unlessM :: Monad m => m Bool -> m () -> m () ifM :: Monad m => m Bool -> m a -> m a -> m a guardM :: MonadPlus m => m Bool -> m () bool :: a -> a -> Bool -> a -- | The && operator lifted to a monad. If the first -- argument evaluates to False the second argument will not be -- evaluated. (&&^) :: Monad m => m Bool -> m Bool -> m Bool infixr 3 &&^ -- | The || operator lifted to a monad. If the first argument -- evaluates to True the second argument will not be evaluated. (||^) :: Monad m => m Bool -> m Bool -> m Bool infixr 2 ||^ -- | && lifted to an Applicative. Unlike &&^ -- the operator is not short-circuiting. (<&&>) :: Applicative a => a Bool -> a Bool -> a Bool infixr 3 <&&> -- | || lifted to an Applicative. Unlike ||^ the operator is -- not short-circuiting. (<||>) :: Applicative a => a Bool -> a Bool -> a Bool infixr 2 <||> module Lemmata.Bifunctor class Bifunctor p where bimap f g = first f . second g first f = bimap f id second = bimap id bimap :: Bifunctor p => (a -> b) -> (c -> d) -> p a c -> p b d first :: Bifunctor p => (a -> b) -> p a c -> p b c second :: Bifunctor p => (b -> c) -> p a b -> p a c instance Lemmata.Bifunctor.Bifunctor (,) instance Lemmata.Bifunctor.Bifunctor ((,,) x1) instance Lemmata.Bifunctor.Bifunctor ((,,,) x1 x2) instance Lemmata.Bifunctor.Bifunctor ((,,,,) x1 x2 x3) instance Lemmata.Bifunctor.Bifunctor ((,,,,,) x1 x2 x3 x4) instance Lemmata.Bifunctor.Bifunctor ((,,,,,,) x1 x2 x3 x4 x5) instance Lemmata.Bifunctor.Bifunctor Data.Either.Either instance Lemmata.Bifunctor.Bifunctor Data.Functor.Const.Const module Lemmata.Base ($!) :: (a -> b) -> a -> b infixr 0 $! module Lemmata.Conv class StringConv a b strConv :: StringConv a b => Leniency -> a -> b toS :: StringConv a b => a -> b toSL :: StringConv a b => a -> b data Leniency Lenient :: Leniency Strict :: Leniency instance GHC.Enum.Bounded Lemmata.Conv.Leniency instance GHC.Enum.Enum Lemmata.Conv.Leniency instance GHC.Classes.Ord Lemmata.Conv.Leniency instance GHC.Show.Show Lemmata.Conv.Leniency instance GHC.Classes.Eq Lemmata.Conv.Leniency instance Lemmata.Conv.StringConv GHC.Base.String GHC.Base.String instance Lemmata.Conv.StringConv GHC.Base.String Data.ByteString.Internal.ByteString instance Lemmata.Conv.StringConv GHC.Base.String Data.ByteString.Lazy.Internal.ByteString instance Lemmata.Conv.StringConv GHC.Base.String Data.Text.Internal.Text instance Lemmata.Conv.StringConv GHC.Base.String Data.Text.Internal.Lazy.Text instance Lemmata.Conv.StringConv Data.ByteString.Internal.ByteString GHC.Base.String instance Lemmata.Conv.StringConv Data.ByteString.Internal.ByteString Data.ByteString.Internal.ByteString instance Lemmata.Conv.StringConv Data.ByteString.Internal.ByteString Data.ByteString.Lazy.Internal.ByteString instance Lemmata.Conv.StringConv Data.ByteString.Internal.ByteString Data.Text.Internal.Text instance Lemmata.Conv.StringConv Data.ByteString.Internal.ByteString Data.Text.Internal.Lazy.Text instance Lemmata.Conv.StringConv Data.ByteString.Lazy.Internal.ByteString GHC.Base.String instance Lemmata.Conv.StringConv Data.ByteString.Lazy.Internal.ByteString Data.ByteString.Internal.ByteString instance Lemmata.Conv.StringConv Data.ByteString.Lazy.Internal.ByteString Data.ByteString.Lazy.Internal.ByteString instance Lemmata.Conv.StringConv Data.ByteString.Lazy.Internal.ByteString Data.Text.Internal.Text instance Lemmata.Conv.StringConv Data.ByteString.Lazy.Internal.ByteString Data.Text.Internal.Lazy.Text instance Lemmata.Conv.StringConv Data.Text.Internal.Text GHC.Base.String instance Lemmata.Conv.StringConv Data.Text.Internal.Text Data.ByteString.Internal.ByteString instance Lemmata.Conv.StringConv Data.Text.Internal.Text Data.ByteString.Lazy.Internal.ByteString instance Lemmata.Conv.StringConv Data.Text.Internal.Text Data.Text.Internal.Lazy.Text instance Lemmata.Conv.StringConv Data.Text.Internal.Text Data.Text.Internal.Text instance Lemmata.Conv.StringConv Data.Text.Internal.Lazy.Text GHC.Base.String instance Lemmata.Conv.StringConv Data.Text.Internal.Lazy.Text Data.Text.Internal.Text instance Lemmata.Conv.StringConv Data.Text.Internal.Lazy.Text Data.Text.Internal.Lazy.Text instance Lemmata.Conv.StringConv Data.Text.Internal.Lazy.Text Data.ByteString.Lazy.Internal.ByteString instance Lemmata.Conv.StringConv Data.Text.Internal.Lazy.Text Data.ByteString.Internal.ByteString module Lemmata.Exceptions hush :: Alternative m => Either e a -> m a note :: (MonadError e m) => e -> Maybe a -> m a tryIO :: MonadIO m => IO a -> ExceptT IOException m a module Lemmata.Monad -- | The Monad class defines the basic operations over a -- monad, a concept from a branch of mathematics known as -- category theory. From the perspective of a Haskell programmer, -- however, it is best to think of a monad as an abstract datatype -- of actions. Haskell's do expressions provide a convenient -- syntax for writing monadic expressions. -- -- Instances of Monad should satisfy the following laws: -- -- -- -- Furthermore, the Monad and Applicative operations should -- relate as follows: -- -- -- -- The above laws imply: -- -- -- -- and that pure and (<*>) satisfy the applicative -- functor laws. -- -- The instances of Monad for lists, Maybe and IO -- defined in the Prelude satisfy these laws. class Applicative m => Monad (m :: * -> *) -- | Sequentially compose two actions, passing any value produced by the -- first as an argument to the second. (>>=) :: Monad m => m a -> (a -> m b) -> m b -- | Sequentially compose two actions, discarding any value produced by the -- first, like sequencing operators (such as the semicolon) in imperative -- languages. (>>) :: Monad m => m a -> m b -> m b -- | Inject a value into the monadic type. return :: Monad m => a -> m a -- | Monads that also support choice and failure. class (Alternative m, Monad m) => MonadPlus (m :: * -> *) -- | the identity of mplus. It should also satisfy the equations -- --
--   mzero >>= f  =  mzero
--   v >> mzero   =  mzero
--   
mzero :: MonadPlus m => m a -- | an associative operation mplus :: MonadPlus m => m a -> m a -> m a -- | Same as >>=, but with the arguments interchanged. (=<<) :: Monad m => (a -> m b) -> m a -> m b infixr 1 =<< -- | Left-to-right Kleisli composition of monads. (>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c infixr 1 >=> -- | Right-to-left Kleisli composition of monads. -- (>=>), with the arguments flipped. -- -- Note how this operator resembles function composition -- (.): -- --
--   (.)   ::            (b ->   c) -> (a ->   b) -> a ->   c
--   (<=<) :: Monad m => (b -> m c) -> (a -> m b) -> a -> m c
--   
(<=<) :: Monad m => (b -> m c) -> (a -> m b) -> a -> m c infixr 1 <=< -- | Sequentially compose two actions, discarding any value produced by the -- first, like sequencing operators (such as the semicolon) in imperative -- languages. (>>) :: Monad m => forall a b. m a -> m b -> m b -- | forever act repeats the action infinitely. forever :: Applicative f => f a -> f b -- | The join function is the conventional monad join operator. It -- is used to remove one level of monadic structure, projecting its bound -- argument into the outer level. join :: Monad m => m (m a) -> m a -- | Direct MonadPlus equivalent of filter -- filter = (mfilter:: (a -> Bool) -> [a] -- -> [a] applicable to any MonadPlus, for example -- mfilter odd (Just 1) == Just 1 mfilter odd (Just 2) == -- Nothing mfilter :: MonadPlus m => (a -> Bool) -> m a -> m a -- | This generalizes the list-based filter function. filterM :: Applicative m => (a -> m Bool) -> [a] -> m [a] -- | The mapAndUnzipM function maps its first argument over a list, -- returning the result as a pair of lists. This function is mainly used -- with complicated data structures or a state-transforming monad. mapAndUnzipM :: Applicative m => (a -> m (b, c)) -> [a] -> m ([b], [c]) -- | The zipWithM function generalizes zipWith to arbitrary -- applicative functors. zipWithM :: Applicative m => (a -> b -> m c) -> [a] -> [b] -> m [c] -- | zipWithM_ is the extension of zipWithM which ignores the -- final result. zipWithM_ :: Applicative m => (a -> b -> m c) -> [a] -> [b] -> m () -- | The foldM function is analogous to foldl, except that -- its result is encapsulated in a monad. Note that foldM works -- from left-to-right over the list arguments. This could be an issue -- where (>>) and the `folded function' are not -- commutative. -- --
--   foldM f a1 [x1, x2, ..., xm]
--   
-- -- == -- --
--   do
--     a2 <- f a1 x1
--     a3 <- f a2 x2
--     ...
--     f am xm
--   
-- -- If right-to-left evaluation is required, the input list should be -- reversed. -- -- Note: foldM is the same as foldlM foldM :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m b -- | Like foldM, but discards the result. foldM_ :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m () -- | replicateM n act performs the action n times, -- gathering the results. replicateM :: Applicative m => Int -> m a -> m [a] -- | Like replicateM, but discards the result. replicateM_ :: Applicative m => Int -> m a -> m () concatMapM :: Monad m => (a -> m [b]) -> [a] -> m [b] -- | guard b is pure () if b is -- True, and empty if b is False. guard :: Alternative f => Bool -> f () -- | Conditional execution of Applicative expressions. For example, -- --
--   when debug (putStrLn "Debugging")
--   
-- -- will output the string Debugging if the Boolean value -- debug is True, and otherwise do nothing. when :: Applicative f => Bool -> f () -> f () -- | The reverse of when. unless :: Applicative f => Bool -> f () -> f () -- | Promote a function to a monad. liftM :: Monad m => (a1 -> r) -> m a1 -> m r -- | Promote a function to a monad, scanning the monadic arguments from -- left to right. For example, -- --
--   liftM2 (+) [0,1] [0,2] = [0,2,1,3]
--   liftM2 (+) (Just 1) Nothing = Nothing
--   
liftM2 :: Monad m => (a1 -> a2 -> r) -> m a1 -> m a2 -> m r -- | Promote a function to a monad, scanning the monadic arguments from -- left to right (cf. liftM2). liftM3 :: Monad m => (a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r -- | Promote a function to a monad, scanning the monadic arguments from -- left to right (cf. liftM2). liftM4 :: Monad m => (a1 -> a2 -> a3 -> a4 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m r -- | Promote a function to a monad, scanning the monadic arguments from -- left to right (cf. liftM2). liftM5 :: Monad m => (a1 -> a2 -> a3 -> a4 -> a5 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m a5 -> m r liftM' :: Monad m => (a -> b) -> m a -> m b liftM2' :: (Monad m) => (a -> b -> c) -> m a -> m b -> m c -- | In many situations, the liftM operations can be replaced by -- uses of ap, which promotes function application. -- --
--   return f `ap` x1 `ap` ... `ap` xn
--   
-- -- is equivalent to -- --
--   liftMn f x1 x2 ... xn
--   
ap :: Monad m => m (a -> b) -> m a -> m b -- | Strict version of <$>. (<$!>) :: Monad m => (a -> b) -> m a -> m b infixl 4 <$!> module Lemmata.Panic -- | Uncatchable exceptions thrown and never caught. data FatalError FatalError :: Text -> FatalError [fatalErrorMessage] :: FatalError -> Text panic :: Text -> a instance GHC.Show.Show Lemmata.Panic.FatalError instance GHC.Exception.Exception Lemmata.Panic.FatalError module Lemmata.Show class Print a putStr :: (Print a, MonadIO m) => a -> m () putStrLn :: (Print a, MonadIO m) => a -> m () putText :: MonadIO m => Text -> m () putLText :: MonadIO m => Text -> m () putByteString :: MonadIO m => ByteString -> m () putLByteString :: MonadIO m => ByteString -> m () instance Lemmata.Show.Print Data.Text.Internal.Text instance Lemmata.Show.Print Data.Text.Internal.Lazy.Text instance Lemmata.Show.Print Data.ByteString.Internal.ByteString instance Lemmata.Show.Print Data.ByteString.Lazy.Internal.ByteString instance Lemmata.Show.Print [GHC.Types.Char] module Lemmata.Debug undefined :: a -- | Warning: error remains in code error :: Text -> a -- | Warning: trace remains in code trace :: Print b => b -> a -> a -- | Warning: traceM remains in code traceM :: (Monad m) => Text -> m () -- | Warning: traceId remains in code traceId :: Text -> Text -- | Warning: traceIO remains in code traceIO :: Print b => b -> a -> IO a -- | Warning: traceShow remains in code traceShow :: Show a => a -> b -> b -- | Warning: traceShowId remains in code traceShowId :: Show a => a -> a -- | Warning: traceShowM remains in code traceShowM :: (Show a, Monad m) => a -> m () notImplemented :: a module Lemmata.Unsafe unsafeHead :: [a] -> a unsafeTail :: [a] -> [a] unsafeInit :: [a] -> [a] unsafeLast :: [a] -> a unsafeFromJust :: Maybe a -> a unsafeIndex :: [a] -> Int -> a unsafeThrow :: Exception e => e -> a module Lemmata.Applicative orAlt :: (Alternative f, Monoid a) => f a -> f a orEmpty :: Alternative f => Bool -> a -> f a eitherA :: (Alternative f) => f a -> f b -> f (Either a b) purer :: (Applicative f, Applicative g) => a -> f (g a) liftAA2 :: (Applicative f, Applicative g) => (a -> b -> c) -> f (g a) -> f (g b) -> f (g c) (<<*>>) :: (Applicative f, Applicative g) => f (g (a -> b)) -> f (g a) -> f (g b) module Lemmata identity :: a -> a map :: Functor f => (a -> b) -> f a -> f b uncons :: [a] -> Maybe (a, [a]) unsnoc :: [x] -> Maybe ([x], x) applyN :: Int -> (a -> a) -> a -> a print :: (MonadIO m, Show a) => a -> m () throwIO :: (MonadIO m, Exception e) => e -> m a throwTo :: (MonadIO m, Exception e) => ThreadId -> e -> m () foreach :: Functor f => f a -> (a -> b) -> f b show :: (Show a, StringConv String b) => a -> b -- | Do nothing returning unit inside applicative. pass :: Applicative f => f () guarded :: (Alternative f) => (a -> Bool) -> a -> f a guardedA :: (Functor f, Alternative t) => (a -> f Bool) -> a -> f (t a) type LText = Text type LByteString = ByteString -- | Lift an IO operation with 1 argument into another monad liftIO1 :: MonadIO m => (a -> IO b) -> a -> m b -- | Lift an IO operation with 2 arguments into another monad liftIO2 :: MonadIO m => (a -> b -> IO c) -> a -> b -> m c