semirings-0.7: two monoids as one, in holy haskimony
Copyright(C) 2018 chessai
LicenseMIT (see the file LICENSE)
Maintainerchessai <chessai1996@gmail.com>
Stabilityprovisional
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell98

Data.Semiring.Generic

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 #

gfromNatural' :: Natural -> f a Source #

Instances

Instances details
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 #

gfromNatural' :: Natural -> U1 a 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 #

gfromNatural' :: Natural -> (a :*: b) a0 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 #

gfromNatural' :: Natural -> K1 i a 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 #

gfromNatural' :: Natural -> 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

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

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

It is only defined for product types.

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

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

Defined in Data.Semiring.Generic

Methods

gnegate' :: U1 a -> U1 a 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 #

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 (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