Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Class interface to different free module implementations.
Free modules are like maps from a base type to a numeric type, with the additional invariant that the values are never zero.
- baseMap :: (FreeModule x, FreeModule y, Coeff x ~ Coeff y) => (Base x -> Base y) -> x -> y
- coeffMap :: (FreeModule x, FreeModule y, Base x ~ Base y) => (Coeff x -> Coeff y) -> x -> y
- class (Ord (Base a), Eq (Coeff a), Num (Coeff a)) => FreeModule a where
- (*^) :: FreeModule a => Coeff a -> a -> a
- (^*) :: FreeModule a => a -> Coeff a -> a
- lookupTerm :: FreeModule a => Base a -> a -> Maybe (Base a, Coeff a)
- minTermMaybe :: FreeModule a => a -> Maybe (Base a, Coeff a)
- maxTermMaybe :: FreeModule a => a -> Maybe (Base a, Coeff a)
Documentation
baseMap :: (FreeModule x, FreeModule y, Coeff x ~ Coeff y) => (Base x -> Base y) -> x -> y Source #
generic baseMap implementation, converts to list and back.
coeffMap :: (FreeModule x, FreeModule y, Base x ~ Base y) => (Coeff x -> Coeff y) -> x -> y Source #
generic coeffMap implementation, converts to list and back.
class (Ord (Base a), Eq (Coeff a), Num (Coeff a)) => FreeModule a where Source #
fromBase :: Base a -> a Source #
fromTerm :: Base a -> Coeff a -> a Source #
(^+^) :: a -> a -> a infixl 6 Source #
(^-^) :: a -> a -> a infixl 6 Source #
scalarMul :: Coeff a -> a -> a Source #
unionWith :: (Coeff a -> Coeff a -> Coeff a) -> a -> a -> a Source #
We should call the function even when the given base is present
only in one of the arguments! So that unionWith (-)
works correctly.
coeff :: Base a -> a -> Coeff a Source #
minTerm :: a -> (Base a, Coeff a) Source #
maxTerm :: a -> (Base a, Coeff a) Source #
split into two approximately equal parts x
and y
, such that
maxTerm x < minTerm y
unsafeJoin :: a -> a -> a Source #
we assume that maxTerm x < minTerm y
toList :: a -> [(Base a, Coeff a)] Source #
fromList :: [(Base a, Coeff a)] -> a Source #
fromAscendingList :: [(Base a, Coeff a)] -> a Source #
(*^) :: FreeModule a => Coeff a -> a -> a infixl 7 Source #
(^*) :: FreeModule a => a -> Coeff a -> a infixl 7 Source #
lookupTerm :: FreeModule a => Base a -> a -> Maybe (Base a, Coeff a) Source #
minTermMaybe :: FreeModule a => a -> Maybe (Base a, Coeff a) Source #
maxTermMaybe :: FreeModule a => a -> Maybe (Base a, Coeff a) Source #