| Safe Haskell | Safe-Inferred |
|---|
Lvm.Common.Byte
- type Byte = Word8
- data Bytes
- class Monoid a where
- unit :: Byte -> Bytes
- isEmpty :: Bytes -> Bool
- bytesLength :: Bytes -> Int
- writeBytes :: FilePath -> Bytes -> IO ()
- bytesFromList :: [Byte] -> Bytes
- listFromBytes :: Bytes -> [Byte]
- bytesFromString :: String -> Bytes
- stringFromBytes :: Bytes -> String
- bytesFromInt32 :: Int -> Bytes
- byteFromInt8 :: Int -> Byte
- readByteList :: FilePath -> IO [Byte]
- int32FromByteList :: [Byte] -> (Int, [Byte])
- stringFromByteList :: [Byte] -> String
- bytesFromByteList :: [Byte] -> Bytes
Documentation
class Monoid a where
The class of monoids (types with an associative binary operation that has an identity). Instances should satisfy the following laws:
mappend mempty x = x
mappend x mempty = x
mappend x (mappend y z) = mappend (mappend x y) z
mconcat =
foldrmappend mempty
The method names refer to the monoid of lists under concatenation, but there are many other instances.
Minimal complete definition: mempty and mappend.
Some types can be viewed as a monoid in more than one way,
e.g. both addition and multiplication on numbers.
In such cases we often define newtypes and make those instances
of Monoid, e.g. Sum and Product.
Methods
mempty :: a
Identity of mappend
mappend :: a -> a -> a
An associative operation
mconcat :: [a] -> a
Fold a list using the monoid.
For most types, the default definition for mconcat will be
used, but the function is included in the class definition so
that an optimized version can be provided for specific types.
Instances
| Monoid Ordering | |
| Monoid () | |
| Monoid All | |
| Monoid Any | |
| Monoid IntSet | |
| Monoid Bytes | |
| Monoid [a] | |
| Monoid a => Monoid (Dual a) | |
| Monoid (Endo a) | |
| Num a => Monoid (Sum a) | |
| Num a => Monoid (Product a) | |
| Monoid (First a) | |
| Monoid (Last a) | |
| Monoid a => Monoid (Maybe a) | Lift a semigroup into |
| Monoid (IntMap a) | |
| Ord a => Monoid (Set a) | |
| Monoid b => Monoid (a -> b) | |
| (Monoid a, Monoid b) => Monoid (a, b) | |
| (Monoid a, Monoid b, Monoid c) => Monoid (a, b, c) | |
| (Monoid a, Monoid b, Monoid c, Monoid d) => Monoid (a, b, c, d) | |
| (Monoid a, Monoid b, Monoid c, Monoid d, Monoid e) => Monoid (a, b, c, d, e) |
bytesLength :: Bytes -> IntSource
writeBytes :: FilePath -> Bytes -> IO ()Source
bytesFromList :: [Byte] -> BytesSource
listFromBytes :: Bytes -> [Byte]Source
bytesFromString :: String -> BytesSource
stringFromBytes :: Bytes -> StringSource
bytesFromInt32 :: Int -> BytesSource
byteFromInt8 :: Int -> ByteSource
readByteList :: FilePath -> IO [Byte]Source
int32FromByteList :: [Byte] -> (Int, [Byte])Source
stringFromByteList :: [Byte] -> StringSource
bytesFromByteList :: [Byte] -> BytesSource