From 5de8f471389d0d0892d3551b57478aa502a3e8fd Mon Sep 17 00:00:00 2001 From: Stephen Diehl Date: Fri, 29 Jul 2016 12:07:32 -0400 Subject: [PATCH] Stubs. --- docs/Applicative.md | 78 ++++++++++++++++++++++++++++++++++ docs/Exceptions.md | 62 +++++++++++++++++++++++++++ docs/Function.md | 50 ++++++++++++++++++++++ docs/Index.md | 8 ++++ docs/List.md | 100 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 298 insertions(+) create mode 100644 docs/Applicative.md create mode 100644 docs/Exceptions.md create mode 100644 docs/Function.md create mode 100644 docs/List.md diff --git a/docs/Applicative.md b/docs/Applicative.md new file mode 100644 index 000000000..1474840bc --- /dev/null +++ b/docs/Applicative.md @@ -0,0 +1,78 @@ +Applicative +=========== + +#### Functor + +```haskell +class Functor (f :: * -> *) where + fmap :: (a -> b) -> f a -> f b + (<$) :: a -> f b -> f a +``` + +```haskell +(<$>) :: Functor f => (a -> b) -> f a -> f b +``` + +```haskell +($>) :: Functor f => f a -> b -> f b +``` + +#### Applicatives + +```haskell +class Functor f => Applicative (f :: * -> *) where + pure :: a -> f a + (<*>) :: f (a -> b) -> f a -> f b + (*>) :: f a -> f b -> f b + (<*) :: f a -> f b -> f a +``` + +```haskell +(<$>) :: Functor f => (a -> b) -> f a -> f b +``` + +```haskell +orAlt :: (Alternative f, Monoid a) => f a -> f a +``` + +```haskell +orEmpty :: Alternative f => Bool -> a -> f a +``` + +```haskell +eitherA :: (Alternative f) => f a -> f b -> f (Either a b) +``` + +#### Alternative + +```haskell +class Applicative f => Alternative (f :: * -> *) where + empty :: f a + (<|>) :: f a -> f a -> f a + some :: f a -> f [a] + many :: f a -> f [a] +``` + +```haskell +(<|>) :: Alternative f => f a -> f a -> f a +``` + +```haskell +many :: Alternative f => f a -> f [a] +``` + +```haskell +some :: Alternative f => f a -> f [a] +``` + +```haskell +optional :: Alternative f => f a -> f (Maybe a) +``` + +```haskell +liftA :: Applicative f => (a -> b) -> f a -> f b +``` + +```haskell +empty :: Alternative f => f a +``` diff --git a/docs/Exceptions.md b/docs/Exceptions.md new file mode 100644 index 000000000..99a3d1585 --- /dev/null +++ b/docs/Exceptions.md @@ -0,0 +1,62 @@ +Exception Handling +================== + +#### MonadError + +```haskell +class Monad m => MonadError e (m :: * -> *) | m -> e where + throwError :: e -> m a + catchError :: m a -> (e -> m a) -> m a +``` + +```haskell +type Except e = ExceptT e Identity +``` + + +```haskell +newtype ExceptT e (m :: * -> *) a + = Control.Monad.Trans.Except.ExceptT (m (Either e a)) +``` + + +```haskell +throwError :: MonadError e m => e -> m a +``` + +```haskell +catchError :: MonadError e m => m a -> (e -> m a) -> m a +``` + +```haskell +runExcept :: Except e a -> Either e a +``` + +```haskell +runExceptT :: ExceptT e m a -> m (Either e a) +``` + +#### Exceptions + +```haskell +class (Typeable e, Show e) => Exception e where + toException :: e -> SomeException + fromException :: SomeException -> Maybe e + GHC.Exception.displayException :: e -> String +``` + +```haskell +throwIO :: (MonadIO m, Exception e) => e -> m a +``` + +```haskell +throwTo :: (MonadIO m, Exception e) => ThreadId -> e -> m () +``` + +```haskell +throwSTM :: Exception e => e -> STM a +``` + +```haskell +throwError :: MonadError e m => e -> m a +``` diff --git a/docs/Function.md b/docs/Function.md new file mode 100644 index 000000000..a8f23e8cd --- /dev/null +++ b/docs/Function.md @@ -0,0 +1,50 @@ +Functions +========= + +```haskell +($) :: (a -> b) -> a -> b +``` + +```haskell +(&) :: a -> (a -> b) -> b +``` + +```haskell +(.) :: (b -> c) -> (a -> b) -> a -> c +``` + +```haskell +flip :: (a -> b -> c) -> b -> a -> c +``` + +```haskell +on :: (b -> b -> c) -> (a -> b) -> a -> a -> c +``` + +```haskell +const :: a -> b -> a +``` + +```haskell +fix :: (a -> a) -> a +``` + +```haskell +($!) :: (a -> b) -> a -> b +``` + +```haskell +identity :: a -> a +``` + +```haskell +($!!) :: NFData a => (a -> b) -> a -> b +``` + +```haskell +($!!) :: NFData a => (a -> b) -> a -> b +``` + +```haskell +force :: NFData a => a -> a +``` diff --git a/docs/Index.md b/docs/Index.md index 92adb1fff..a441e740f 100644 --- a/docs/Index.md +++ b/docs/Index.md @@ -1,3 +1,11 @@ Welcome to project documentation. +- [Functions](Function.md) +- [Functors](Applicative.md) - [Monad](Monad.md) +- [Maybe](Maybe.md) +- [Lists](List.md) +- [Folds](Folds.md) +- [Dictionaries](Map.md) +- [Sets](Set.md) +- [Exception Handling](Exceptions.md) diff --git a/docs/List.md b/docs/List.md new file mode 100644 index 000000000..3c4057d0a --- /dev/null +++ b/docs/List.md @@ -0,0 +1,100 @@ +List +==== + +#### Slicing + +```haskell +head :: Foldable f => f a -> Maybe a +``` + +```haskell +tailMay :: [a] -> Maybe [a] +``` + +```haskell +tailSafe :: [a] -> [a] +``` + +```haskell +initMay :: [a] -> Maybe [a] +``` + +```haskell +initSafe :: [a] -> [a] +``` + +```haskell +initDef :: [a] -> [a] -> [a] +``` + +```haskell +lastMay :: [a] -> Maybe a +``` + +```haskell +lastDef :: a -> [a] -> a +``` + +```haskell +list :: [b] -> (a -> b) -> [a] -> [b] +``` + +```haskell +drop :: Int -> [a] -> [a] +``` + +```haskell +take :: Int -> [a] -> [a] +``` + +#### Unpacking + +```haskell +uncons :: [a] -> Maybe (a, [a]) +``` + +```haskell +unsnoc :: [x] -> Maybe ([x],x) +``` + +#### Sorting + +```haskell +sortOn :: Ord o => (a -> o) -> [a] -> [a] +``` + +#### Removing + +```haskell +ordNub :: Ord a => [a] -> [a] +``` + +#### Splitting + +```haskell +splitAt :: Int -> [a] -> ([a], [a]) +``` + +```haskell +splitAt :: Int -> [a] -> ([a], [a]) +``` + +```haskell +intercalate :: [a] -> [[a]] -> [a] +``` + +#### Comparison + +```haskell +isPrefixOf :: Eq a => [a] -> [a] -> Bool +``` + +#### Filter + +```haskell +filter :: (a -> Bool) -> [a] -> [a] +``` + +```haskell +replicate :: Int -> a -> [a] +```