semiring-num-1.1.0.0: Basic semiring class and instances

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

Constructors

 Free FieldsgetFree :: [[a]]

Instances

 Source # Methodsfmap :: (a -> b) -> Free a -> Free b #(<\$) :: a -> Free b -> Free a # Source # Methodspure :: a -> Free a #(<*>) :: Free (a -> b) -> Free a -> Free b #(*>) :: Free a -> Free b -> Free b #(<*) :: Free a -> Free b -> Free a # Source # Methodsfold :: 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 # Source # Methodstraverse :: 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) # Read a => Read (Free a) Source # MethodsreadsPrec :: Int -> ReadS (Free a) #readList :: ReadS [Free a] # Show a => Show (Free a) Source # MethodsshowsPrec :: Int -> Free a -> ShowS #show :: Free a -> String #showList :: [Free a] -> ShowS # Monoid (Free a) Source # Methodsmempty :: Free a #mappend :: Free a -> Free a -> Free a #mconcat :: [Free a] -> Free a # Semiring (Free a) Source # Methods(<.>) :: 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.