semirings-0.3.1.2: two monoids as one, in holy haskimony

Copyright(C) 2018 chessai
LicenseMIT (see the file LICENSE)
Maintainerchessai <chessai1996@gmail.com>
Stabilityprovisional
Portabilityportable
Safe HaskellNone
LanguageHaskell98

Data.Semiring.Generic

Contents

Description

This module provides generic deriving tools for semirings and rings for product-like structures.

Synopsis

Documentation

class GSemiring f where Source #

Generic Semiring class, used to implement plus, times, zero, and one for product-like types implementing Generic.

Methods

gzero' :: f a Source #

gone' :: f a Source #

gplus' :: f a -> f a -> f a Source #

gtimes' :: f a -> f a -> f a Source #

Instances
GSemiring (U1 :: Type -> Type) Source # 
Instance details

Defined in Data.Semiring.Generic

Methods

gzero' :: U1 a Source #

gone' :: U1 a Source #

gplus' :: U1 a -> U1 a -> U1 a Source #

gtimes' :: U1 a -> U1 a -> U1 a Source #

Semiring a => GSemiring (K1 i a :: Type -> Type) Source # 
Instance details

Defined in Data.Semiring.Generic

Methods

gzero' :: K1 i a a0 Source #

gone' :: K1 i a a0 Source #

gplus' :: K1 i a a0 -> K1 i a a0 -> K1 i a a0 Source #

gtimes' :: K1 i a a0 -> K1 i a a0 -> K1 i a a0 Source #

(GSemiring a, GSemiring b) => GSemiring (a :*: b) Source # 
Instance details

Defined in Data.Semiring.Generic

Methods

gzero' :: (a :*: b) a0 Source #

gone' :: (a :*: b) a0 Source #

gplus' :: (a :*: b) a0 -> (a :*: b) a0 -> (a :*: b) a0 Source #

gtimes' :: (a :*: b) a0 -> (a :*: b) a0 -> (a :*: b) a0 Source #

GSemiring a => GSemiring (M1 i c a) Source # 
Instance details

Defined in Data.Semiring.Generic

Methods

gzero' :: M1 i c a a0 Source #

gone' :: M1 i c a a0 Source #

gplus' :: M1 i c a a0 -> M1 i c a a0 -> M1 i c a a0 Source #

gtimes' :: M1 i c a a0 -> M1 i c a a0 -> M1 i c a a0 Source #

gzero :: (Generic a, GSemiring (Rep a)) => a Source #

Generically generate a Semiring zero for any product-like type implementing Generic.

It is only defined for product types.

gplus gzero a = a = gplus a gzero

gone :: (Generic a, GSemiring (Rep a)) => a Source #

Generically generate a Semiring one for any product-like type implementing Generic.

It is only defined for product types.

gtimes gone a = a = gtimes a gone

gplus :: (Generic a, GSemiring (Rep a)) => a -> a -> a Source #

Generically generate a Semiring plus operation for any type implementing Generic. It is only defined for product types.

gplus a b = gplus b a

gtimes :: (Generic a, GSemiring (Rep a)) => a -> a -> a Source #

Generically generate a Semiring times operation for any type implementing Generic. It is only defined for product types.

gtimes a (gtimes b c) = gtimes (gtimes a b) c
gtimes a gzero = gzero = gtimes gzero a

class GRing f where Source #

Generic Ring class, used to implement negate for product-like types implementing Generic.

Methods

gnegate' :: f a -> f a Source #

Instances
GRing (U1 :: Type -> Type) Source # 
Instance details

Defined in Data.Semiring.Generic

Methods

gnegate' :: U1 a -> U1 a Source #

Ring a => GRing (K1 i a :: Type -> Type) Source # 
Instance details

Defined in Data.Semiring.Generic

Methods

gnegate' :: K1 i a a0 -> K1 i a a0 Source #

(GRing a, GRing b) => GRing (a :*: b) Source # 
Instance details

Defined in Data.Semiring.Generic

Methods

gnegate' :: (a :*: b) a0 -> (a :*: b) a0 Source #

GRing a => GRing (M1 i c a) Source # 
Instance details

Defined in Data.Semiring.Generic

Methods

gnegate' :: M1 i c a a0 -> M1 i c a a0 Source #

gnegate :: (Generic a, GRing (Rep a)) => a -> a Source #

Generically generate a Ring negate operation for any type implementing Generic. It is only defined for product types.

gplus a (gnegate a) = zero

newtype GenericSemiring a Source #

An Identity-style wrapper with a Generic interface to be used with '-XDerivingVia'.

Constructors

GenericSemiring a 
Instances
Generic (GenericSemiring a) Source # 
Instance details

Defined in Data.Semiring.Generic

Associated Types

type Rep (GenericSemiring a) :: Type -> Type #

Semiring a => Semiring (GenericSemiring a) Source # 
Instance details

Defined in Data.Semiring.Generic

type Rep (GenericSemiring a) Source # 
Instance details

Defined in Data.Semiring.Generic

type Rep (GenericSemiring a) = D1 (MetaData "GenericSemiring" "Data.Semiring.Generic" "semirings-0.3.1.2-6JsgtI1LNjC2TpBZyMwt2E" True) (C1 (MetaCons "GenericSemiring" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a)))

Orphan instances

(Ring a, Ring b) => Ring (a, b) Source # 
Instance details

Methods

negate :: (a, b) -> (a, b) Source #

(Semiring a, Semiring b) => Semiring (a, b) Source # 
Instance details

Methods

plus :: (a, b) -> (a, b) -> (a, b) Source #

zero :: (a, b) Source #

times :: (a, b) -> (a, b) -> (a, b) Source #

one :: (a, b) Source #

(Ring a, Ring b, Ring c) => Ring (a, b, c) Source # 
Instance details

Methods

negate :: (a, b, c) -> (a, b, c) Source #

(Semiring a, Semiring b, Semiring c) => Semiring (a, b, c) Source # 
Instance details

Methods

plus :: (a, b, c) -> (a, b, c) -> (a, b, c) Source #

zero :: (a, b, c) Source #

times :: (a, b, c) -> (a, b, c) -> (a, b, c) Source #

one :: (a, b, c) Source #

(Ring a, Ring b, Ring c, Ring d) => Ring (a, b, c, d) Source # 
Instance details

Methods

negate :: (a, b, c, d) -> (a, b, c, d) Source #

(Semiring a, Semiring b, Semiring c, Semiring d) => Semiring (a, b, c, d) Source # 
Instance details

Methods

plus :: (a, b, c, d) -> (a, b, c, d) -> (a, b, c, d) Source #

zero :: (a, b, c, d) Source #

times :: (a, b, c, d) -> (a, b, c, d) -> (a, b, c, d) Source #

one :: (a, b, c, d) Source #

(Ring a, Ring b, Ring c, Ring d, Ring e) => Ring (a, b, c, d, e) Source # 
Instance details

Methods

negate :: (a, b, c, d, e) -> (a, b, c, d, e) Source #

(Semiring a, Semiring b, Semiring c, Semiring d, Semiring e) => Semiring (a, b, c, d, e) Source # 
Instance details

Methods

plus :: (a, b, c, d, e) -> (a, b, c, d, e) -> (a, b, c, d, e) Source #

zero :: (a, b, c, d, e) Source #

times :: (a, b, c, d, e) -> (a, b, c, d, e) -> (a, b, c, d, e) Source #

one :: (a, b, c, d, e) Source #

(Ring a, Ring b, Ring c, Ring d, Ring e, Ring f) => Ring (a, b, c, d, e, f) Source # 
Instance details

Methods

negate :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) Source #

(Semiring a, Semiring b, Semiring c, Semiring d, Semiring e, Semiring f) => Semiring (a, b, c, d, e, f) Source # 
Instance details

Methods

plus :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> (a, b, c, d, e, f) Source #

zero :: (a, b, c, d, e, f) Source #

times :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> (a, b, c, d, e, f) Source #

one :: (a, b, c, d, e, f) Source #

(Ring a, Ring b, Ring c, Ring d, Ring e, Ring f, Ring g) => Ring (a, b, c, d, e, f, g) Source # 
Instance details

Methods

negate :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) Source #

(Semiring a, Semiring b, Semiring c, Semiring d, Semiring e, Semiring f, Semiring g) => Semiring (a, b, c, d, e, f, g) Source # 
Instance details

Methods

plus :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) Source #

zero :: (a, b, c, d, e, f, g) Source #

times :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) Source #

one :: (a, b, c, d, e, f, g) Source #