semiring-num-0.3.0.0: Basic semiring class and instances

Safe HaskellNone
LanguageHaskell2010

Data.Semiring.Free

Description

The Free semiring.

Synopsis

Documentation

newtype Free a Source #

The free semiring. Adapted from PureScript's version, available here. Only a valid semiring if treated as a multiset, as in:

>>> Free [[1],[0]] == Free [[0],[1]]
True

Constructors

Free 

Fields

Instances

Functor Free Source # 

Methods

fmap :: (a -> b) -> Free a -> Free b #

(<$) :: a -> Free b -> Free a #

Applicative Free Source # 

Methods

pure :: a -> Free a #

(<*>) :: Free (a -> b) -> Free a -> Free b #

(*>) :: Free a -> Free b -> Free b #

(<*) :: Free a -> Free b -> Free a #

Foldable Free Source # 

Methods

fold :: Monoid m => Free m -> m #

foldMap :: Monoid m => (a -> m) -> Free a -> m #

foldr :: (a -> b -> b) -> b -> Free a -> b #

foldr' :: (a -> b -> b) -> b -> Free a -> b #

foldl :: (b -> a -> b) -> b -> Free a -> b #

foldl' :: (b -> a -> b) -> b -> Free a -> b #

foldr1 :: (a -> a -> a) -> Free a -> a #

foldl1 :: (a -> a -> a) -> Free a -> a #

toList :: Free a -> [a] #

null :: Free a -> Bool #

length :: Free a -> Int #

elem :: Eq a => a -> Free a -> Bool #

maximum :: Ord a => Free a -> a #

minimum :: Ord a => Free a -> a #

sum :: Num a => Free a -> a #

product :: Num a => Free a -> a #

Traversable Free Source # 

Methods

traverse :: Applicative f => (a -> f b) -> Free a -> f (Free b) #

sequenceA :: Applicative f => Free (f a) -> f (Free a) #

mapM :: Monad m => (a -> m b) -> Free a -> m (Free b) #

sequence :: Monad m => Free (m a) -> m (Free a) #

Ord a => Eq (Free a) Source #

Extremely slow. For testing purposes.

Methods

(==) :: Free a -> Free a -> Bool #

(/=) :: Free a -> Free a -> Bool #

Ord a => Ord (Free a) Source # 

Methods

compare :: Free a -> Free a -> Ordering #

(<) :: Free a -> Free a -> Bool #

(<=) :: Free a -> Free a -> Bool #

(>) :: Free a -> Free a -> Bool #

(>=) :: Free a -> Free a -> Bool #

max :: Free a -> Free a -> Free a #

min :: Free a -> Free a -> Free a #

Read a => Read (Free a) Source # 
Show a => Show (Free a) Source # 

Methods

showsPrec :: Int -> Free a -> ShowS #

show :: Free a -> String #

showList :: [Free a] -> ShowS #

Monoid (Free a) Source # 

Methods

mempty :: Free a #

mappend :: Free a -> Free a -> Free a #

mconcat :: [Free a] -> Free a #

Semiring (Free a) Source # 

Methods

zero :: Free a Source #

one :: Free a Source #

(<.>) :: Free a -> Free a -> Free a Source #

(<+>) :: Free a -> Free a -> Free a Source #

liftFree :: Semiring s => (a -> s) -> Free a -> s Source #

Run a Free.

unFree :: Semiring s => Free s -> s Source #

Run a Free, interpreting it in the underlying semiring.