Copyright | (C) 2018 chessai |
---|---|
License | MIT (see the file LICENSE) |
Maintainer | chessai <chessai1996@gmail.com> |
Stability | provisional |
Portability | portable |
Safe Haskell | Safe-Inferred |
Language | Haskell98 |
This module provides generic deriving tools for semirings and rings for product-like structures.
Synopsis
- class GSemiring f where
- gzero :: (Generic a, GSemiring (Rep a)) => a
- gone :: (Generic a, GSemiring (Rep a)) => a
- gplus :: (Generic a, GSemiring (Rep a)) => a -> a -> a
- gtimes :: (Generic a, GSemiring (Rep a)) => a -> a -> a
- gfromNatural :: (Generic a, GSemiring (Rep a)) => Natural -> a
- class GRing f where
- gnegate' :: f a -> f a
- gnegate :: (Generic a, GRing (Rep a)) => a -> a
- newtype GenericSemiring a = GenericSemiring a
Documentation
class GSemiring f where Source #
Generic Semiring
class, used to implement plus
, times
, zero
,
and one
for product-like types implementing Generic
.
gplus' :: f a -> f a -> f a Source #
gtimes' :: f a -> f a -> f a Source #
gfromNatural' :: Natural -> f a Source #
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.
newtype GenericSemiring a Source #
An Identity-style wrapper with a Generic
interface
to be used with '-XDerivingVia'.
Instances
(Generic a, GSemiring (Rep a)) => Semiring (GenericSemiring a) Source # | |
Defined in Data.Semiring.Generic plus :: GenericSemiring a -> GenericSemiring a -> GenericSemiring a Source # zero :: GenericSemiring a Source # times :: GenericSemiring a -> GenericSemiring a -> GenericSemiring a Source # one :: GenericSemiring a Source # fromNatural :: Natural -> GenericSemiring a Source # |