Copyright | (c) 2020 Reed Mullanix Emily Pillmore Koji Miyazato |
---|---|
License | BSD-style |
Maintainer | Reed Mullanix <reedmullanix@gmail.com>, Emily Pillmore <emilypi@cohomolo.gy> |
Stability | stable |
Portability | non-portable |
Safe Haskell | Unsafe |
Language | Haskell2010 |
This module exposes internals of FreeAbelianGroup
.
Synopsis
- newtype FreeAbelianGroup a = MkFreeAbelianGroup (Map a Integer)
Free abelian groups
newtype FreeAbelianGroup a Source #
A representation of a free abelian group over an alphabet a
.
The intuition here is group elements correspond with their positive or negative multiplicities, and as such are simplified by construction.
Examples:
>>>
let single a = MkFreeAbelianGroup $ Map.singleton a 1
>>>
a = single 'a'
>>>
b = single 'b'
>>>
a
FreeAbelianGroup $ fromList [('a',1)]>>>
a <> b
FreeAbelianGroup $ fromList [('a',1),('b',1)]>>>
a <> b == b <> a
True>>>
invert a
FreeAbelianGroup $ fromList [('a',-1)]>>>
a <> b <> invert a
FreeAbelianGroup $ fromList [('b',1)]>>>
gtimes 5 (a <> b)
FreeAbelianGroup $ fromList [('a',5),('b',5)]
MkFreeAbelianGroup (Map a Integer) | Unsafe "raw" constructor, which does not do normalization work.
Please use |