| Safe Haskell | None |
|---|
Algebra.Core
Contents
- data ByteString
- readFile :: FilePath -> IO ByteString
- writeFile :: FilePath -> ByteString -> IO ()
- hGetContents :: Handle -> IO ByteString
- data Void
- type :*: a b = (a, b)
- type :+: a b = Either a b
- class Semigroup m where
- (+) :: m -> m -> m
- class Semigroup m => Monoid m where
- zero :: m
- class Monoid m => Ring m where
- class (Semigroup a, Semigroup b) => SubSemi a b where
- cast :: b -> a
- class Unit f where
- pure :: a -> f a
- newtype Endo k a = Endo {
- runEndo :: k a a
- newtype StrictEndo a = StrictEndo {
- runStrictEndo :: a -> a
- newtype Dual m = Dual {
- getDual :: m
- newtype Product a = Product {
- getProduct :: a
- newtype OrdList a = OrdList {
- getOrdList :: [a]
- newtype Interleave a = Interleave {
- interleave :: [a]
- newtype Accum a = Accum {}
- newtype Max a = Max {
- getMax :: a
- newtype Id a = Id {
- getId :: a
- class Category k where
- (<<<) :: Category k => k b c -> k a b -> k a c
- (>>>) :: Category k => k a b -> k b c -> k a c
- (+++) :: Split k => (a -> k c c) -> (b -> k d d) -> (a :+: b) -> k (c, d) (c, d)
- class Category k => Choice k where
- class Category k => Split k where
- (<#>) :: k a c -> k b d -> k (a, b) (c, d)
- const :: Unit m => a -> m a
- (&) :: a -> (a -> b) -> b
- is :: a -> (a -> Bool) -> Bool
- fix :: (a -> a) -> a
- first :: Split k => k a b -> k (a, c) (b, c)
- second :: Split k => k a b -> k (c, a) (c, b)
- ifThenElse :: Bool -> a -> a -> a
- bool :: a -> a -> Bool -> a
- guard :: (Unit m, Monoid (m ())) => Bool -> m ()
- fail :: String -> a
- unit :: Unit m => m ()
- when :: Unit m => Bool -> m () -> m ()
- unless :: Unit m => Bool -> m () -> m ()
- tailSafe :: [a] -> [a]
- headDef :: a -> [a] -> a
- rmod :: (RealFrac m, Ring m) => m -> m -> m
- inside :: Ord t => t -> t -> t -> Bool
- swap :: (a, b) -> (b, a)
- class Ord t => Orderable t where
- comparing :: Ord a => (b -> a) -> b -> b -> Ordering
- insertOrd :: Orderable t => t -> [t] -> [t]
- invertOrd :: Ordering -> Ordering
- module Prelude
Raw data
data ByteString
A space-efficient representation of a Word8 vector, supporting many
efficient operations. A ByteString contains 8-bit characters only.
Instances of Eq, Ord, Read, Show, Data, Typeable
readFile :: FilePath -> IO ByteString
Read an entire file strictly into a ByteString. This is far more
efficient than reading the characters into a String and then using
pack. It also may be more efficient than opening the file and
reading it using hGet.
writeFile :: FilePath -> ByteString -> IO ()
Write a ByteString to a file.
hGetContents :: Handle -> IO ByteString
Read entire handle contents strictly into a ByteString.
This function reads chunks at a time, doubling the chunksize on each
read. The final buffer is then realloced to the appropriate size. For
files > half of available memory, this may lead to memory exhaustion.
Consider using readFile in this case.
As with hGet, the string representation in the file is assumed to
be ISO-8859-1.
The Handle is closed once the contents have been read, or if an exception is thrown.
Basic union and product types
Instances
| Monoid Void | |
| Semigroup Void | |
| Monoid a => SubSemi a Void | |
| MonadError Void [] | |
| MonadError Void Maybe | |
| Isomorphic Bool Bool (Maybe a) (Maybe Void) | |
| Isomorphic a b (Void, a) (Void, b) | |
| Monad m => MonadError Void (ListT m) | |
| (Monad m, Monoid w) => MonadError Void (ParserT w c m) | |
| Ord a => DataMap (Set a) a Void | |
| Foldable m => Foldable (RWST Void w Void m) | |
| Traversable m => Traversable (RWST Void w Void m) |
Basic group and ring structure
Classes
The class of all types that have a binary operation. Note that the operation isn't necesarily commutative (in the case of lists, for example)
Instances
class Semigroup m => Monoid m whereSource
A monoid is a semigroup with a null element such that zero + a == a + zero == a
Instances
class Monoid m => Ring m whereSource
Instances
| Ring Bool | |
| Ring Double | |
| Ring Float | |
| Ring Int | |
| Ring Integer | |
| Monoid a => Ring [a] | |
| (Ord a, Monoid a) => Ring (Set a) | |
| Ring m => Ring (Dual m) | |
| (Ord a, Bounded a) => Ring (Max a) | |
| Ord t => Ring (Time t) | The Time ring where |
| Ring b => Ring (a -> b) | |
| (Ring a, Ring b) => Ring (:*: a b) | |
| Ring (f a) => Ring (Backwards f a) | |
| Ring (m (a, s, Void)) => Ring (StateT s m a) | |
| Ring (m (a, Void, Void)) => Ring (ReaderT r m a) | |
| Ring (m (a, Void, w)) => Ring (WriterT w m a) | |
| Ring (m r) => Ring (ContT r m a) | |
| Ring (m (a, s, w)) => Ring (RWST r w s m a) |
Instances
| Unit [] | |
| Unit IO | |
| Unit Maybe | |
| Unit Tree | |
| Unit Interleave | |
| Unit OrdList | |
| Unit Id | |
| Unit Accum | |
| Unit ZipTree | |
| Unit ZipList | |
| Unit TimeVal | |
| Unit Time | |
| Unit ((->) b) | |
| Unit (Either a) | |
| Monoid w => Unit ((,) w) | |
| Monoid a => Unit (Const a) | |
| Unit f => Unit (Backwards f) | |
| Unit m => Unit (MaybeT m) | |
| Unit m => Unit (TreeT m) | |
| Unit m => Unit (ListT m) | |
| Ord t => Unit (Future t) | |
| Ord t => Unit (Reactive t) | |
| Ord t => Unit (Event t) | |
| (Unit f, Unit g) => Unit (:**: f g) | |
| (Unit f, Unit g) => Unit (:.: f g) | |
| (Unit f, Unit g) => Unit (Compose' f g) | |
| Unit m => Unit (StateT s m) | |
| Unit m => Unit (ReaderT r m) | |
| (Unit m, Monoid w) => Unit (WriterT w m) | |
| Unit m => Unit (ContT r m) | |
| Unit m => Unit (EitherT e m) | |
| (Unit m, Monoid w) => Unit (ParserT w s m) | |
| (Unit f, Monoid w) => Unit (RWST r w s f) |
Common monoids
Control monoids
A monoid on category endomorphisms under composition
newtype StrictEndo a Source
Constructors
| StrictEndo | |
Fields
| |
Instances
| Semigroup (StrictEndo a) |
Meta-monoids
The dual of a monoid is the same as the original, with arguments reversed
The Product monoid
Constructors
| Product | |
Fields
| |
Accumulating monoids
An ordered list. The semigroup instance merges two lists so that the result remains in ascending order.
Constructors
| OrdList | |
Fields
| |
newtype Interleave a Source
Constructors
| Interleave | |
Fields
| |
A monoid on Maybes, where the sum is the leftmost non-Nothing value.
The Max monoid, where (+) =~ max
The Identity Functor
Fundamental control operations
Splitting and Choosing
Misc functions
ifThenElse :: Bool -> a -> a -> aSource
Lazily ordering values
comparing :: Ord a => (b -> a) -> b -> b -> Ordering
comparing p x y = compare (p x) (p y)
Useful combinator for use in conjunction with the xxxBy family
of functions from Data.List, for example:
... sortBy (comparing fst) ...
The rest is imported from the Prelude
module Prelude