packages feed

foundation 0.0.2 → 0.0.3

raw patch · 13 files changed

+283/−42 lines, 13 filesdep ~ghc-primPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: ghc-prim

API changes (from Hackage documentation)

+ Foundation.Monad: catch :: (MonadCatch m, Exception e) => m a -> (e -> m a) -> m a
+ Foundation.Monad: class MonadThrow m => MonadCatch m
+ Foundation.Monad: class Monad m => MonadFailure m where type Failure m where {
+ Foundation.Monad: class Monad m => MonadIO (m :: * -> *)
+ Foundation.Monad: class Monad m => MonadThrow m
+ Foundation.Monad: class MonadTrans trans
+ Foundation.Monad: lift :: (MonadTrans trans, Monad m) => m a -> trans m a
+ Foundation.Monad: liftIO :: MonadIO m => IO a -> m a
+ Foundation.Monad: mFail :: MonadFailure m => Failure m -> m ()
+ Foundation.Monad: throw :: (MonadThrow m, Exception e) => e -> m a
+ Foundation.Monad: type family Failure m;
+ Foundation.Monad: }
+ Foundation.Monad.Reader: data ReaderT r m a
+ Foundation.Monad.Reader: instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Foundation.Monad.Reader.ReaderT r m)
+ Foundation.Monad.Reader: instance Foundation.Monad.Exception.MonadCatch m => Foundation.Monad.Exception.MonadCatch (Foundation.Monad.Reader.ReaderT r m)
+ Foundation.Monad.Reader: instance Foundation.Monad.Exception.MonadFailure m => Foundation.Monad.Exception.MonadFailure (Foundation.Monad.Reader.ReaderT r m)
+ Foundation.Monad.Reader: instance Foundation.Monad.Exception.MonadThrow m => Foundation.Monad.Exception.MonadThrow (Foundation.Monad.Reader.ReaderT r m)
+ Foundation.Monad.Reader: instance Foundation.Monad.Transformer.MonadTrans (Foundation.Monad.Reader.ReaderT r)
+ Foundation.Monad.Reader: instance GHC.Base.Applicative m => GHC.Base.Applicative (Foundation.Monad.Reader.ReaderT r m)
+ Foundation.Monad.Reader: instance GHC.Base.Functor m => GHC.Base.Functor (Foundation.Monad.Reader.ReaderT r m)
+ Foundation.Monad.Reader: instance GHC.Base.Monad m => GHC.Base.Monad (Foundation.Monad.Reader.ReaderT r m)
+ Foundation.Monad.State: data StateT s m a
+ Foundation.Monad.State: instance (GHC.Base.Applicative m, GHC.Base.Monad m) => GHC.Base.Applicative (Foundation.Monad.State.StateT s m)
+ Foundation.Monad.State: instance (GHC.Base.Functor m, Control.Monad.IO.Class.MonadIO m) => Control.Monad.IO.Class.MonadIO (Foundation.Monad.State.StateT s m)
+ Foundation.Monad.State: instance (GHC.Base.Functor m, Foundation.Monad.Exception.MonadCatch m) => Foundation.Monad.Exception.MonadCatch (Foundation.Monad.State.StateT s m)
+ Foundation.Monad.State: instance (GHC.Base.Functor m, Foundation.Monad.Exception.MonadFailure m) => Foundation.Monad.Exception.MonadFailure (Foundation.Monad.State.StateT s m)
+ Foundation.Monad.State: instance (GHC.Base.Functor m, Foundation.Monad.Exception.MonadThrow m) => Foundation.Monad.Exception.MonadThrow (Foundation.Monad.State.StateT s m)
+ Foundation.Monad.State: instance (GHC.Base.Functor m, GHC.Base.Monad m) => GHC.Base.Monad (Foundation.Monad.State.StateT s m)
+ Foundation.Monad.State: instance Foundation.Monad.Transformer.MonadTrans (Foundation.Monad.State.StateT s)
+ Foundation.Monad.State: instance GHC.Base.Functor m => GHC.Base.Functor (Foundation.Monad.State.StateT s m)
- Foundation: (*>) :: f a -> f b -> f b
+ Foundation: (*>) :: Applicative f => f a -> f b -> f b
- Foundation: (/=) :: a -> a -> Bool
+ Foundation: (/=) :: Eq a => a -> a -> Bool
- Foundation: (<$) :: a -> f b -> f a
+ Foundation: (<$) :: Functor f => a -> f b -> f a
- Foundation: (<) :: a -> a -> Bool
+ Foundation: (<) :: Ord a => a -> a -> Bool
- Foundation: (<*) :: f a -> f b -> f a
+ Foundation: (<*) :: Applicative f => f a -> f b -> f a
- Foundation: (<*>) :: f (a -> b) -> f a -> f b
+ Foundation: (<*>) :: Applicative f => f (a -> b) -> f a -> f b
- Foundation: (<=) :: a -> a -> Bool
+ Foundation: (<=) :: Ord a => a -> a -> Bool
- Foundation: (==) :: a -> a -> Bool
+ Foundation: (==) :: Eq a => a -> a -> Bool
- Foundation: (>) :: a -> a -> Bool
+ Foundation: (>) :: Ord a => a -> a -> Bool
- Foundation: (>=) :: a -> a -> Bool
+ Foundation: (>=) :: Ord a => a -> a -> Bool
- Foundation: (>>) :: m a -> m b -> m b
+ Foundation: (>>) :: Monad m => m a -> m b -> m b
- Foundation: (>>=) :: m a -> (a -> m b) -> m b
+ Foundation: (>>=) :: Monad m => m a -> (a -> m b) -> m b
- Foundation: bimap :: (a -> b) -> (c -> d) -> p a c -> p b d
+ Foundation: bimap :: Bifunctor p => (a -> b) -> (c -> d) -> p a c -> p b d
- Foundation: compare :: a -> a -> Ordering
+ Foundation: compare :: Ord a => a -> a -> Ordering
- Foundation: displayException :: e -> String
+ Foundation: displayException :: Exception e => e -> String
- Foundation: enumFrom :: a -> [a]
+ Foundation: enumFrom :: Enum a => a -> [a]
- Foundation: enumFromThen :: a -> a -> [a]
+ Foundation: enumFromThen :: Enum a => a -> a -> [a]
- Foundation: enumFromThenTo :: a -> a -> a -> [a]
+ Foundation: enumFromThenTo :: Enum a => a -> a -> a -> [a]
- Foundation: enumFromTo :: a -> a -> [a]
+ Foundation: enumFromTo :: Enum a => a -> a -> [a]
- Foundation: fail :: String -> m a
+ Foundation: fail :: Monad m => String -> m a
- Foundation: first :: (a -> b) -> p a c -> p b c
+ Foundation: first :: Bifunctor p => (a -> b) -> p a c -> p b c
- Foundation: fmap :: (a -> b) -> f a -> f b
+ Foundation: fmap :: Functor f => (a -> b) -> f a -> f b
- Foundation: fromEnum :: a -> Int
+ Foundation: fromEnum :: Enum a => a -> Int
- Foundation: fromException :: SomeException -> Maybe e
+ Foundation: fromException :: Exception e => SomeException -> Maybe e
- Foundation: fromList :: [Item l] -> l
+ Foundation: fromList :: IsList l => [Item l] -> l
- Foundation: fromListN :: Int -> [Item l] -> l
+ Foundation: fromListN :: IsList l => Int -> [Item l] -> l
- Foundation: fromString :: String -> a
+ Foundation: fromString :: IsString a => String -> a
- Foundation: mappend :: a -> a -> a
+ Foundation: mappend :: Monoid a => a -> a -> a
- Foundation: max :: a -> a -> a
+ Foundation: max :: Ord a => a -> a -> a
- Foundation: maxBound :: a
+ Foundation: maxBound :: Bounded a => a
- Foundation: mconcat :: [a] -> a
+ Foundation: mconcat :: Monoid a => [a] -> a
- Foundation: mempty :: a
+ Foundation: mempty :: Monoid a => a
- Foundation: min :: a -> a -> a
+ Foundation: min :: Ord a => a -> a -> a
- Foundation: minBound :: a
+ Foundation: minBound :: Bounded a => a
- Foundation: pred :: a -> a
+ Foundation: pred :: Enum a => a -> a
- Foundation: pure :: a -> f a
+ Foundation: pure :: Applicative f => a -> f a
- Foundation: return :: a -> m a
+ Foundation: return :: Monad m => a -> m a
- Foundation: second :: (b -> c) -> p a b -> p a c
+ Foundation: second :: Bifunctor p => (b -> c) -> p a b -> p a c
- Foundation: succ :: a -> a
+ Foundation: succ :: Enum a => a -> a
- Foundation: toEnum :: Int -> a
+ Foundation: toEnum :: Enum a => Int -> a
- Foundation: toException :: e -> SomeException
+ Foundation: toException :: Exception e => e -> SomeException
- Foundation: toList :: l -> [Item l]
+ Foundation: toList :: IsList l => l -> [Item l]
- Foundation.Class.Bifunctor: bimap :: (a -> b) -> (c -> d) -> p a c -> p b d
+ Foundation.Class.Bifunctor: bimap :: Bifunctor p => (a -> b) -> (c -> d) -> p a c -> p b d
- Foundation.Class.Bifunctor: first :: (a -> b) -> p a c -> p b c
+ Foundation.Class.Bifunctor: first :: Bifunctor p => (a -> b) -> p a c -> p b c
- Foundation.Class.Bifunctor: second :: (b -> c) -> p a b -> p a c
+ Foundation.Class.Bifunctor: second :: Bifunctor p => (b -> c) -> p a b -> p a c
- Foundation.String.ASCII: fromBytesUnsafe :: UArray CChar -> AsciiString
+ Foundation.String.ASCII: fromBytesUnsafe :: UArray CUChar -> AsciiString
- Foundation.String.ASCII: replicate :: Int -> CChar -> AsciiString
+ Foundation.String.ASCII: replicate :: Int -> CUChar -> AsciiString
- Foundation.String.ASCII: toBytes :: AsciiString -> UArray CChar
+ Foundation.String.ASCII: toBytes :: AsciiString -> UArray CUChar

Files

Foundation/Internal/CallStack.hs view
@@ -9,7 +9,7 @@  import GHC.Stack (HasCallStack) -#elif MIN_VERSION_base(4,8,0)+#elif MIN_VERSION_base(4,8,1)  import qualified GHC.Stack 
+ Foundation/Monad.hs view
@@ -0,0 +1,11 @@+module Foundation.Monad+    ( MonadIO(..)+    , MonadFailure(..)+    , MonadThrow(..)+    , MonadCatch(..)+    , MonadTrans(..)+    ) where++import Foundation.Monad.MonadIO+import Foundation.Monad.Exception+import Foundation.Monad.Transformer
+ Foundation/Monad/Base.hs view
@@ -0,0 +1,17 @@+module Foundation.Monad.Base+    ( Functor(..)+    , Applicative(..)+    , Monad(..)+    , MonadIO(..)+    , MonadFailure(..)+    , MonadThrow(..)+    , MonadCatch(..)+    , MonadTrans(..)+    , IdentityT+    ) where++import Foundation.Internal.Base (Functor(..), Applicative(..), Monad(..))+import Foundation.Monad.MonadIO+import Foundation.Monad.Exception+import Foundation.Monad.Transformer+import Foundation.Monad.Identity
+ Foundation/Monad/Exception.hs view
@@ -0,0 +1,42 @@++module Foundation.Monad.Exception+    ( MonadFailure(..)+    , MonadThrow(..)+    , MonadCatch(..)+    ) where++import           Foundation.Internal.Base+import qualified Control.Exception (throwIO, catch)++-- | Monad that can represent failure+--+-- Similar to MonadFail but with a parametrized Failure linked to the Monad+class Monad m => MonadFailure m where+    -- | The associated type with the MonadFailure, representing what+    -- failure can be encoded in this monad+    type Failure m++    -- | Raise a Failure through a monad.+    mFail :: Failure m -> m ()++-- | Monad that can throw exception+class Monad m => MonadThrow m where+    -- | Throw immediatity an exception.+    -- Only a 'MonadCatch' monad will be able to catch the exception using 'catch'+    throw :: Exception e => e -> m a++-- | Monad that can catch exception+class MonadThrow m => MonadCatch m where+    catch :: Exception e => m a -> (e -> m a) -> m a++instance MonadFailure Maybe where+    type Failure Maybe = ()+    mFail _ = Nothing+instance MonadFailure (Either a) where+    type Failure (Either a) = a+    mFail a = Left a++instance MonadThrow IO where+    throw = Control.Exception.throwIO+instance MonadCatch IO where+    catch = Control.Exception.catch
+ Foundation/Monad/Identity.hs view
@@ -0,0 +1,44 @@+module Foundation.Monad.Identity+    ( IdentityT+    ) where++import Foundation.Internal.Base hiding (throw)+import Foundation.Monad.MonadIO+import Foundation.Monad.Exception+import Foundation.Monad.Transformer++newtype IdentityT m a = IdentityT { runIdentityT :: m a }++instance Functor m => Functor (IdentityT m) where+    fmap f (IdentityT m) = IdentityT (f `fmap` m)+    {-# INLINE fmap #-}++instance Applicative m => Applicative (IdentityT m) where+    pure x = IdentityT (pure x)+    {-# INLINE pure #-}+    fab <*> fa = IdentityT (runIdentityT fab <*> runIdentityT fa)+    {-# INLINE (<*>) #-}++instance Monad m => Monad (IdentityT m) where+    return x = IdentityT (return x)+    {-# INLINE return #-}+    ma >>= mb = IdentityT $ runIdentityT ma >>= runIdentityT . mb+    {-# INLINE (>>=) #-}++instance MonadTrans IdentityT where+    lift = IdentityT+    {-# INLINE lift #-}++instance MonadIO m => MonadIO (IdentityT m) where+    liftIO f = lift (liftIO f)+    {-# INLINE liftIO #-}++instance MonadFailure m => MonadFailure (IdentityT m) where+    type Failure (IdentityT m) = Failure m+    mFail = IdentityT . mFail++instance MonadThrow m => MonadThrow (IdentityT m) where+    throw e = IdentityT (throw e)++instance MonadCatch m => MonadCatch (IdentityT m) where+    catch (IdentityT m) c = IdentityT $ m `catch` (runIdentityT . c)
+ Foundation/Monad/MonadIO.hs view
@@ -0,0 +1,19 @@+{-# LANGUAGE CPP #-}+module Foundation.Monad.MonadIO+    ( MonadIO(..)+    ) where++#if MIN_VERSION_base(4,9,0)+import Control.Monad.IO.Class+#else+import Foundation.Internal.Base++-- | Monads in which 'IO' computations may be embedded.+class Monad m => MonadIO m where+    -- | Lift a computation from the 'IO' monad.+    liftIO :: IO a -> m a++instance MonadIO IO where+    liftIO io = io++#endif
+ Foundation/Monad/Reader.hs view
@@ -0,0 +1,43 @@+module Foundation.Monad.Reader+    ( ReaderT+    ) where++import Foundation.Internal.Base (($), (.), const)+import Foundation.Monad.Base++-- | Reader Transformer+newtype ReaderT r m a = ReaderT { runReaderT :: r -> m a }++instance Functor m => Functor (ReaderT r m) where+    fmap f m = ReaderT $ fmap f . runReaderT m+    {-# INLINE fmap #-}++instance Applicative m => Applicative (ReaderT r m) where+    pure a     = ReaderT $ const (pure a)+    {-# INLINE pure #-}+    fab <*> fa = ReaderT $ \r -> runReaderT fab r <*> runReaderT fa r+    {-# INLINE (<*>) #-}++instance Monad m => Monad (ReaderT r m) where+    return a = ReaderT $ const (return a)+    {-# INLINE return #-}+    ma >>= mab = ReaderT $ \r -> runReaderT ma r >>= \a -> runReaderT (mab a) r+    {-# INLINE (>>=) #-}++instance MonadTrans (ReaderT r) where+    lift f = ReaderT $ \_ -> f+    {-# INLINE lift #-}++instance MonadIO m => MonadIO (ReaderT r m) where+    liftIO f = lift (liftIO f)+    {-# INLINE liftIO #-}++instance MonadFailure m => MonadFailure (ReaderT r m) where+    type Failure (ReaderT r m) = Failure m+    mFail e = ReaderT $ \_ -> mFail e++instance MonadThrow m => MonadThrow (ReaderT r m) where+    throw e = ReaderT $ \_ -> throw e ++instance MonadCatch m => MonadCatch (ReaderT r m) where+    catch (ReaderT m) c = ReaderT $ \r -> m r `catch` (\e -> runReaderT (c e) r)
+ Foundation/Monad/State.hs view
@@ -0,0 +1,47 @@+{-# LANGUAGE TupleSections #-}+module Foundation.Monad.State+    ( StateT+    ) where++import Foundation.Internal.Base (($), (.))+import Foundation.Monad.Base++-- | State Transformer+newtype StateT s m a = StateT { runStateT :: s -> m (a, s) }++instance Functor m => Functor (StateT s m) where+    fmap f m = StateT $ \s1 -> (\(a, s2) -> (f a, s2)) `fmap` runStateT m s1+    {-# INLINE fmap #-}++instance (Applicative m, Monad m) => Applicative (StateT s m) where+    pure a     = StateT $ \s -> (,s) `fmap` pure a+    {-# INLINE pure #-}+    fab <*> fa = StateT $ \s1 -> do+        (ab,s2) <- runStateT fab s1+        (a, s3) <- runStateT fa s2+        return (ab a, s3)+    {-# INLINE (<*>) #-}++instance (Functor m, Monad m) => Monad (StateT s m) where+    return a = StateT $ \s -> (,s) `fmap` return a+    {-# INLINE return #-}+    ma >>= mab = StateT $ \s1 -> runStateT ma s1 >>= \(a, s2) -> runStateT (mab a) s2+    {-# INLINE (>>=) #-}++instance MonadTrans (StateT s) where+    lift f = StateT $ \s -> f >>= return . (,s)+    {-# INLINE lift #-}++instance (Functor m, MonadIO m) => MonadIO (StateT s m) where+    liftIO f = lift (liftIO f)+    {-# INLINE liftIO #-}++instance (Functor m, MonadFailure m) => MonadFailure (StateT s m) where+    type Failure (StateT s m) = Failure m+    mFail e = StateT $ \s -> ((,s) `fmap` mFail e)++instance (Functor m, MonadThrow m) => MonadThrow (StateT s m) where+    throw e = StateT $ \_ -> throw e ++instance (Functor m, MonadCatch m) => MonadCatch (StateT s m) where+    catch (StateT m) c = StateT $ \s1 -> m s1 `catch` (\e -> runStateT (c e) s1)
+ Foundation/Monad/Transformer.hs view
@@ -0,0 +1,10 @@+module Foundation.Monad.Transformer+    ( MonadTrans(..)+    ) where++import Foundation.Internal.Base++-- | Basic Transformer class+class MonadTrans trans where+    -- | Lift a computation from an inner monad to the current transformer monad+    lift :: Monad m => m a -> trans m a
Foundation/Primitive/Types.hs view
@@ -360,15 +360,15 @@ instance PrimType CChar where     primSizeInBytes _ = Size 1     {-# INLINE primSizeInBytes #-}-    primBaUIndex ba (Offset n) = CChar (primBaUIndex ba (Offset n :: Offset Int8))+    primBaUIndex ba (Offset n) = CChar (primBaUIndex ba (Offset n))     {-# INLINE primBaUIndex #-}-    primMbaURead mba (Offset n) = CChar <$> primMbaURead mba (Offset n :: Offset Int8)+    primMbaURead mba (Offset n) = CChar <$> primMbaURead mba (Offset n)     {-# INLINE primMbaURead #-}     primMbaUWrite mba (Offset n) (CChar int8) = primMbaUWrite mba (Offset n) int8     {-# INLINE primMbaUWrite #-}-    primAddrIndex addr (Offset n) = CChar $ primAddrIndex addr (Offset n :: Offset Int8)+    primAddrIndex addr (Offset n) = CChar $ primAddrIndex addr (Offset n)     {-# INLINE primAddrIndex #-}-    primAddrRead addr (Offset n) = CChar <$> primAddrRead addr (Offset n :: Offset Int8)+    primAddrRead addr (Offset n) = CChar <$> primAddrRead addr (Offset n)     {-# INLINE primAddrRead #-}     primAddrWrite addr (Offset n) (CChar int8) = primAddrWrite addr (Offset n) int8     {-# INLINE primAddrWrite #-}
Foundation/String/ASCII.hs view
@@ -42,7 +42,7 @@ import           Foundation.Primitive.Monad import           Foundation.Foreign -import GHC.Int+import GHC.Word import GHC.Types import GHC.Prim @@ -51,31 +51,31 @@ import qualified Prelude import Foundation.Class.Bifunctor -ccharToChar :: CChar -> Char-ccharToChar (CChar (I8# i)) = C# (chr# i)-charToCChar :: Char -> CChar-charToCChar (C# i) = CChar (I8# (ord# i))+cucharToChar :: CUChar -> Char+cucharToChar (CUChar (W8# i)) = C# (chr# (word2Int# i))+charToCUChar :: Char -> CUChar+charToCUChar (C# i) = CUChar (W8# (int2Word# (ord# i)))  -- | Opaque packed array of characters in the ASCII encoding-newtype AsciiString = AsciiString { toBytes :: UArray CChar }+newtype AsciiString = AsciiString { toBytes :: UArray CUChar }     deriving (Typeable, Monoid, Eq, Ord) -newtype MutableAsciiString st = MutableAsciiString (MVec.MUArray CChar st)+newtype MutableAsciiString st = MutableAsciiString (MVec.MUArray CUChar st)     deriving (Typeable)  instance Show AsciiString where-    show = fmap ccharToChar . toList+    show = fmap cucharToChar . toList instance IsString AsciiString where-    fromString = fromList . fmap charToCChar+    fromString = fromList . fmap charToCUChar instance IsList AsciiString where-    type Item AsciiString = CChar+    type Item AsciiString = CUChar     fromList = sFromList     toList = sToList -type instance C.Element AsciiString = CChar+type instance C.Element AsciiString = CUChar  instance C.InnerFunctor AsciiString where-    imap = ccharMap+    imap = cucharMap instance C.Collection AsciiString where     null = null     length = length@@ -109,7 +109,7 @@   -- TODO Use a string builder once available   zipWith f a b = sFromList (C.zipWith f a b) -next :: AsciiString -> Offset CChar -> (# CChar, Offset CChar #)+next :: AsciiString -> Offset CUChar -> (# CUChar, Offset CUChar #) next (AsciiString ba) (Offset n) = (# h, Offset (n + 1) #)   where     !h = Vec.unsafeIndex ba n@@ -121,10 +121,10 @@ ------------------------------------------------------------------------ -- real functions -sToList :: AsciiString -> [CChar]+sToList :: AsciiString -> [CUChar] sToList s = loop azero   where-    nbBytes :: Size CChar+    nbBytes :: Size CUChar     !nbBytes = size s     !end = azero `offsetPlusE` nbBytes     loop idx@@ -132,7 +132,7 @@         | otherwise  =             let (# c , idx' #) = next s idx in c : loop idx' -sFromList :: [CChar] -> AsciiString+sFromList :: [CUChar] -> AsciiString sFromList = AsciiString . fromList {-# INLINE [0] sFromList #-} @@ -179,34 +179,34 @@ -- > splitOn (== ':') "abc::def"   == ["abc","","def"] -- > splitOn (== ':') "::abc::def" == ["","","abc","","def"] ---splitOn :: (CChar -> Bool) -> AsciiString -> [AsciiString]+splitOn :: (CUChar -> Bool) -> AsciiString -> [AsciiString] splitOn predicate = fmap AsciiString . Vec.splitOn predicate . toBytes -break :: (CChar -> Bool) -> AsciiString -> (AsciiString, AsciiString)+break :: (CUChar -> Bool) -> AsciiString -> (AsciiString, AsciiString) break predicate = bimap AsciiString AsciiString . Vec.break predicate . toBytes {-# INLINE[0] break #-}  {-# RULES "break (== 'c')" [3] forall c . break (== c) = breakElem c #-} -breakElem :: CChar -> AsciiString -> (AsciiString, AsciiString)+breakElem :: CUChar -> AsciiString -> (AsciiString, AsciiString) breakElem !el (AsciiString ba) =     let (# v1,v2 #) = Vec.splitElem el ba in (AsciiString v1, AsciiString v2) {-# INLINE breakElem #-} -intersperse :: CChar -> AsciiString -> AsciiString+intersperse :: CUChar -> AsciiString -> AsciiString intersperse sep = AsciiString . Vec.intersperse sep . toBytes -span :: (CChar -> Bool) -> AsciiString -> (AsciiString, AsciiString)+span :: (CUChar -> Bool) -> AsciiString -> (AsciiString, AsciiString) span predicate = break (not . predicate)  -- | size in bytes-size :: AsciiString -> Size CChar+size :: AsciiString -> Size CUChar size = Size . C.length . toBytes  length :: AsciiString -> Int length s = let (Size l) = size s in l -replicate :: Int -> CChar -> AsciiString+replicate :: Int -> CUChar -> AsciiString replicate n c = AsciiString $ Vec.create n (const c)  -- | Copy the AsciiString@@ -215,7 +215,7 @@  -- | Allocate a MutableAsciiString of a specific size in bytes. new :: PrimMonad prim-    => Size CChar -- ^ in number of bytes, not of elements.+    => Size CUChar -- ^ in number of bytes, not of elements.     -> prim (MutableAsciiString (PrimState prim)) new n = MutableAsciiString `fmap` MVec.new n @@ -227,28 +227,28 @@         then freeze ms         else C.take filled `fmap` freeze ms -ccharMap :: (CChar -> CChar) -> AsciiString -> AsciiString-ccharMap f = AsciiString . Vec.map f . toBytes+cucharMap :: (CUChar -> CUChar) -> AsciiString -> AsciiString+cucharMap f = AsciiString . Vec.map f . toBytes -snoc :: AsciiString -> CChar -> AsciiString+snoc :: AsciiString -> CUChar -> AsciiString snoc (AsciiString ba) = AsciiString . Vec.snoc ba -cons :: CChar -> AsciiString -> AsciiString+cons :: CUChar -> AsciiString -> AsciiString cons c = AsciiString . Vec.cons c . toBytes -unsnoc :: AsciiString -> Maybe (AsciiString, CChar)+unsnoc :: AsciiString -> Maybe (AsciiString, CUChar) unsnoc str = first AsciiString <$> Vec.unsnoc (toBytes str) -uncons :: AsciiString -> Maybe (CChar, AsciiString)+uncons :: AsciiString -> Maybe (CUChar, AsciiString) uncons str = second AsciiString <$> Vec.uncons (toBytes str) -find :: (CChar -> Bool) -> AsciiString -> Maybe CChar+find :: (CUChar -> Bool) -> AsciiString -> Maybe CUChar find predicate = Vec.find predicate . toBytes -sortBy :: (CChar -> CChar -> Ordering) -> AsciiString -> AsciiString+sortBy :: (CUChar -> CUChar -> Ordering) -> AsciiString -> AsciiString sortBy sortF = AsciiString . Vec.sortBy sortF . toBytes -filter :: (CChar -> Bool) -> AsciiString -> AsciiString+filter :: (CUChar -> Bool) -> AsciiString -> AsciiString filter p s = fromList $ Data.List.filter p $ toList s  reverse :: AsciiString -> AsciiString@@ -259,7 +259,7 @@ -- If the input contains invalid sequences, it will trigger runtime async errors when processing data. -- -- In doubt, use 'fromBytes'-fromBytesUnsafe :: UArray CChar -> AsciiString+fromBytesUnsafe :: UArray CUChar -> AsciiString fromBytesUnsafe = AsciiString  lines :: AsciiString -> [AsciiString]
foundation.cabal view
@@ -1,5 +1,5 @@ Name:                foundation-Version:             0.0.2+Version:             0.0.3 Synopsis:            Alternative prelude with batteries and no dependencies Description:     A custom prelude with no dependencies apart from base.@@ -30,7 +30,7 @@ Homepage:            https://github.com/haskell-foundation/foundation Bug-Reports:         https://github.com/haskell-foundation/foundation/issues Cabal-Version:       >=1.10-tested-with:         GHC == 7.4.2, GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.1+tested-with:         GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.1 extra-source-files:  README.md                      cbits/*.h @@ -70,6 +70,9 @@                      Foundation.Foreign                      Foundation.Collection                      Foundation.Primitive+                     Foundation.Monad+                     Foundation.Monad.Reader+                     Foundation.Monad.State                      Foundation.System.Info                      Foundation.Strict                      Foundation.Parser@@ -124,6 +127,11 @@                      Foundation.Primitive.Monad                      Foundation.Primitive.Utils                      Foundation.Primitive.FinalPtr+                     Foundation.Monad.MonadIO+                     Foundation.Monad.Exception+                     Foundation.Monad.Transformer+                     Foundation.Monad.Identity+                     Foundation.Monad.Base                      Foundation.Array.Chunked.Unboxed                      Foundation.Array.Common                      Foundation.Array.Unboxed
tests/Test/Data/ASCII.hs view
@@ -13,5 +13,5 @@ import Test.Tasty.QuickCheck  -- | a better generator for unicode Character-genAsciiChar :: Gen CChar+genAsciiChar :: Gen CUChar genAsciiChar = toEnum <$> choose (1, 127)