diff --git a/CHANGES.md b/CHANGES.md index 529ff542a..0c9f7da8f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,10 +1,12 @@ -0.1.11 +0.2 ==== * Expose `Symbol` and `Nat` types from `GHC.TypeLits` by default. * Switch exported `(<>)` to be from `Data.Monoid` instead of Semigroup. * Expose `putByteString` and `putLByteString` monomorphic versions of `putStrLn` functions * Export `genericLength` and other generic list return functions. +* Export `ExceptT`, `ReaderT`, and `StateT` constructors. +* Export `NonEmpty` type and constructor for GHC 8.0. 0.1.9 ==== diff --git a/LICENSE b/LICENSE index 4c9be4152..fd522c54c 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2016, Stephen Diehl +Copyright (c) 2016-2017, Stephen Diehl Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to diff --git a/README.md b/README.md index 6569908ec..128b71c9e 100644 --- a/README.md +++ b/README.md @@ -92,9 +92,8 @@ tracks Stack LTS resolver. | Dependencies | Lower | Upper | | ----------- | -------- | -------- | | array | | 0.5 | -| async | 2.1 | 2.2 | +| async | 2.0 | 2.2 | | base | 4.6 | 4.10 | -| binary | | 0.7 | | bytestring | 0.10 | 0.11 | | containers | 0.5 | 0.6 | | deepseq | 1.3 | 1.5 | @@ -104,6 +103,7 @@ tracks Stack LTS resolver. | safe | 0.3 | 0.4 | | stm | 2.4 | 2.5 | | text | 1.2 | 1.3 | +| hashable | 1.2 | 1.3 | | transformers | 0.4 | 0.6 | FAQs @@ -161,4 +161,4 @@ License ------- Released under the MIT License. -Copyright (c) 2016, Stephen Diehl +Copyright (c) 2016-2017, Stephen Diehl diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 000000000..e35d8850c --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1 @@ +_build diff --git a/docs/Applicative.md b/docs/Applicative.md index 1474840bc..d21dd9b99 100644 --- a/docs/Applicative.md +++ b/docs/Applicative.md @@ -1,7 +1,8 @@ Applicative =========== -#### Functor +Functor +------- ```haskell class Functor (f :: * -> *) where @@ -17,7 +18,8 @@ class Functor (f :: * -> *) where ($>) :: Functor f => f a -> b -> f b ``` -#### Applicatives +Applicatives +------- ```haskell class Functor f => Applicative (f :: * -> *) where @@ -27,10 +29,6 @@ class Functor f => Applicative (f :: * -> *) where (<*) :: 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 ``` @@ -43,7 +41,13 @@ orEmpty :: Alternative f => Bool -> a -> f a eitherA :: (Alternative f) => f a -> f b -> f (Either a b) ``` -#### Alternative +```haskell +pass :: Applicative f => f () +``` + + +Alternative +------- ```haskell class Applicative f => Alternative (f :: * -> *) where @@ -76,3 +80,11 @@ liftA :: Applicative f => (a -> b) -> f a -> f b ```haskell empty :: Alternative f => f a ``` + +```haskell +guarded :: (Alternative f) => (a -> Bool) -> a -> f a +``` + +```haskell +guardedA :: (Functor f, Alternative t) => (a -> f Bool) -> a -> f (t a) +``` diff --git a/docs/Bifunctor.md b/docs/Bifunctor.md new file mode 100644 index 000000000..a3878ece5 --- /dev/null +++ b/docs/Bifunctor.md @@ -0,0 +1,2 @@ +Bifunctor +========= diff --git a/docs/Bits.md b/docs/Bits.md new file mode 100644 index 000000000..9fd8afc4e --- /dev/null +++ b/docs/Bits.md @@ -0,0 +1,202 @@ +Bits +==== + +```haskell +{-# LANGUAGE BinaryLiterals #-} +``` + +```python +42 = 0b101010 +``` + +Bit Operations +-------------- + +#### .&. + +```haskell +(.&.) :: Bits a => a -> a -> a +``` + +*Example*: + +#### .|. + +```haskell +(.|.) :: Bits a => a -> a -> a +``` + +*Example*: + +#### xor + +```haskell +xor :: Bits a => a -> a -> a +``` + +*Example*: + +```haskell +> True `xor` False +True + +> True `xor` True +False + +> 0b101 `xor` 0b011 +6 -- 0b110 +``` + +#### complement + +```haskell +complement :: Bits a => a -> a +``` + +```haskell +> complement True +False + +> complement 0b101 +-2 -- -0b010 +``` + +*Example*: + +#### shift + +*Example*: + +```haskell +shift :: Bits a => a -> Int -> a +``` + +*Example*: + +#### rotate + +```haskell +rotate :: Bits a => a -> Int -> a +``` + +*Example*: + +#### zeroBits + +```haskell +zeroBits :: Bits a => a +``` + +*Example*: + +#### bit + +```haskell +bit :: Bits a => Int -> a +``` + +*Example*: + +Bit Testing +------------ + +```haskell +setBit :: Bits a => a -> Int -> a +``` + +```haskell +clearBit :: Bits a => a -> Int -> a +``` + +#### complementBit + +```haskell +complementBit :: Bits a => a -> Int -> a +``` + +*Example*: + +```haskell +λ> 0b100 `complementBit` 1 +6 -- 0b110 +``` + +#### testBit + +```haskell +testBit :: Bits a => a -> Int -> Bool +``` + +*Example*: + +```haskell +> 0b10 `testBit` 0 +False +> 0b10 `testBit` 1 +True +``` + +#### isSigned + +```haskell +isSigned :: Bits a => a -> Bool +``` + +```haskell +> isSigned 42 +True +> isSigned True +False +``` + +Bit Size +------------ + +```haskell +bitSize :: Bits a => a -> Int +``` + +```haskell +popCount :: Bits a => a -> Int +``` + +Bit Shifting +------------ + +```haskell +shiftL :: Bits a => a -> Int -> a +``` + +```haskell +shiftR :: Bits a => a -> Int -> a +``` + +Bit Rotation +------------ + +```haskell +rotate :: Bits a => a -> Int -> a +``` + +```haskell +rotateL :: Bits a => a -> Int -> a +``` + +```haskell +rotateR :: Bits a => a -> Int -> a +``` + +Byte Swapping +------------ + +```haskell +byteSwap16 :: Word16 -> Word16 +``` + +```haskell +byteSwap32 :: Word32 -> Word32 +``` + +```haskell +byteSwap64 :: Word64 -> Word64 +``` diff --git a/docs/Bool.md b/docs/Bool.md new file mode 100644 index 000000000..d1ea2ca21 --- /dev/null +++ b/docs/Bool.md @@ -0,0 +1,6 @@ +Bool +===== + +```haskell +bool :: a -> a -> Bool -> a +``` diff --git a/docs/Concurrency.md b/docs/Concurrency.md new file mode 100644 index 000000000..92c552d0e --- /dev/null +++ b/docs/Concurrency.md @@ -0,0 +1,2 @@ +Concurrency +=========== diff --git a/docs/Debug.md b/docs/Debug.md new file mode 100644 index 000000000..37363798c --- /dev/null +++ b/docs/Debug.md @@ -0,0 +1,96 @@ +Debug +===== + +Stubbing +-------- + +#### undefined + +```haskell +undefined :: a +``` + +An undefined expression standing in for an incomplete program, unevaluated type +witness, or unreachable code branch. + +*Example*: + +```haskell +> import Foreign.Storable +> print (sizeOf (undefined :: Int)) +8 +``` + +#### notImplemented + +```haskell +notImplemented :: a +``` + +An undefined expression standing in for a yet to completed program. + +*Example*: + +```haskell +main :: IO () +main = notImplemented +``` + +Tracing +------- + +#### trace + +```haskell +trace :: Print b => b -> a -> a +``` + +*Example*: + +#### traceM + +```haskell +traceM :: (Monad m) => Text -> m () +``` + +*Example*: + +#### traceId + +```haskell +traceId :: Text -> Text +``` + +*Example*: + +#### traceShowM + +```haskell +traceShowM :: (P.Show a, Monad m) => a -> m () +``` + +*Example*: + +#### traceShowId + +```haskell +traceShowId :: P.Show a => a -> a +``` + +*Example*: + +#### traceShow + +```haskell +traceShow :: P.Show a => a -> b -> b +``` + +*Example*: + +#### traceIO + +```haskell +traceIO :: Print b => b -> a -> IO a +``` + +*Example*: diff --git a/docs/Either.md b/docs/Either.md new file mode 100644 index 000000000..4b0819784 --- /dev/null +++ b/docs/Either.md @@ -0,0 +1,2 @@ +Either +====== diff --git a/docs/Exceptions.md b/docs/Exceptions.md index 6a33cef03..ec0eae09c 100644 --- a/docs/Exceptions.md +++ b/docs/Exceptions.md @@ -1,7 +1,8 @@ -Exception Handling -================== +Exceptions +========== -#### MonadError +MonadError +---------- ```haskell class Monad m => MonadError e (m :: * -> *) | m -> e where @@ -9,34 +10,55 @@ class Monad m => MonadError e (m :: * -> *) | m -> e where catchError :: m a -> (e -> m a) -> m a ``` +#### Except + ```haskell type Except e = ExceptT e Identity ``` +*Example*: + +```haskell +``` + +#### ExceptT ```haskell newtype ExceptT e (m :: * -> *) a = Control.Monad.Trans.Except.ExceptT (m (Either e a)) ``` +*Example*: + +```haskell +``` + +#### throwError ```haskell throwError :: MonadError e m => e -> m a ``` +#### catchError + ```haskell catchError :: MonadError e m => m a -> (e -> m a) -> m a ``` +#### runExcept + ```haskell runExcept :: Except e a -> Either e a ``` +#### runExceptT + ```haskell runExceptT :: ExceptT e m a -> m (Either e a) ``` -#### Exceptions +Exceptions +---------- ```haskell class (Typeable e, Show e) => Exception e where @@ -45,28 +67,60 @@ class (Typeable e, Show e) => Exception e where GHC.Exception.displayException :: e -> String ``` +#### throwIO + ```haskell throwIO :: (MonadIO m, Exception e) => e -> m a ``` -```haskell -throwTo :: (MonadIO m, Exception e) => ThreadId -> e -> m () -``` +#### throwSTM ```haskell throwSTM :: Exception e => e -> STM a ``` +#### throwTo + ```haskell -throwError :: MonadError e m => e -> m a +throwTo :: (MonadIO m, Exception e) => ThreadId -> e -> m () ``` -#### Panic +Utilities +--------- + +#### hush + +```haskell +hush :: Alternative m => Either e a -> m a +``` + +#### note + +```haskell +note :: (MonadError e m, Applicative m) => e -> Maybe a -> m a +``` + +#### tryIO + +```haskell +tryIO :: MonadIO m => IO a -> ExceptT IOException m a +``` + +Fatal Errors +------------ ```haskell data FatalError = FatalError {msg :: Text} ``` +#### panic + ```haskell panic :: Text -> a ``` + +Terminate with an uncatchable fatal error. + +```haskell +> panic "Fatal error occured. +``` diff --git a/docs/Files.md b/docs/Files.md new file mode 100644 index 000000000..eb39fa488 --- /dev/null +++ b/docs/Files.md @@ -0,0 +1,74 @@ +Files +===== + +Basic IO +-------- + +#### readFile + +```haskell +readFile :: FilePath -> IO Text +``` + +#### writeFile + +```haskell +writeFile :: FilePath -> Text -> IO () +``` + +#### appendFile + +```haskell +appendFile :: FilePath -> Text -> IO () +``` + +Console +------- + +#### getLine + +```haskell +getLine :: IO Text +``` + +#### getContents + +```haskell +getContents :: IO Text +``` + +#### interact + +```haskell +interact :: (Text -> Text) -> IO () +``` + +File Handles +------------ + +```haskell +data IOMode + = ReadMode + | WriteMode + | AppendMode + | ReadWriteMode +``` + +#### openFile + +```haskell +openFile :: FilePath -> IOMode -> IO Handle +``` + +#### withFile + +```haskell +withFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r +``` + + +#### stdin +#### stdout +#### stderr +#### Handle +#### FilePath diff --git a/docs/Folds.md b/docs/Folds.md new file mode 100644 index 000000000..80f579121 --- /dev/null +++ b/docs/Folds.md @@ -0,0 +1,171 @@ +Folds +===== + +Basic Folds +----------- + +```haskell +foldMap :: (Foldable t, Monoid m) => (a -> m) -> t a -> m +``` + +```haskell +foldr :: Foldable t => (a -> b -> b) -> b -> t a -> b +``` + +```haskell +foldl :: Foldable t => (b -> a -> b) -> b -> t a -> b +``` + +```haskell +foldr' :: Foldable t => (a -> b -> b) -> b -> t a -> b +``` + +```haskell +foldl' :: Foldable t => (b -> a -> b) -> b -> t a -> b +``` + +```haskell +fold :: Foldable t => Monoid m => t m -> m +``` + +```haskell +toList :: Foldable t => t a -> [a] +``` + +```haskell +null :: Foldable t => t a -> Bool +``` + +```haskell +length :: Foldable t => t a -> Int +``` + +```haskell +elem :: (Eq a, Foldable t) => a -> t a -> Bool +``` + +```haskell +maximum :: (Ord a, Foldable t) => t a -> a +``` + +```haskell +minimum :: (Ord a, Foldable t) => t a -> a +``` + +```haskell +sum :: (Num a, Foldable f) => f a -> a +``` + +```haskell +product :: (Num a, Foldable f) => f a -> a +``` + +#### Folding actions + +```haskell +traverse_ :: (Foldable t, Applicative f) => (a -> f b) -> t a -> f () +``` + +```haskell +for_ :: (Foldable t, Applicative f) => t a -> (a -> f b) -> f () +``` + +*Example*: + +```haskell +>>> for_ [1..4] print +1 +2 +3 +4 +``` + + +#### Applicative Folds + +```haskell +sequenceA_ :: (Foldable t, Applicative f) => t (f a) -> f () +``` + +```haskell +asum :: (Foldable t, Alternative f) => t (f a) -> f a +``` + +#### Monadic Folds + +```haskell +mapM_ :: (Foldable t, Monad m) => (a -> m b) -> t a -> m () +``` + +```haskell +forM_ :: (Foldable t, Monad m) => t a -> (a -> m b) -> m () +``` + +```haskell +sequence_ :: (Foldable t, Monad m) => t (m a) -> m () +``` + +```haskell +msum :: (Foldable t, MonadPlus m) => t (m a) -> m a +``` + +```haskell +foldrM :: (Foldable t, Monad m) => (a -> b -> m b) -> b -> t a -> m b +``` + +```haskell +foldlM :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m b +``` + +#### Specialized folds + +```haskell +concat :: Foldable t => t [a] -> [a] +``` + +```haskell +concatMap :: Foldable t => (a -> [b]) -> t a -> [b] +``` + +```haskell +and :: Foldable t => t Bool -> Bool +``` + +```haskell +or :: Foldable t => t Bool -> Bool +``` + +```haskell +any :: Foldable t => (a -> Bool) -> t a -> Bool +``` + +```haskell +all :: Foldable t => (a -> Bool) -> t a -> Bool +``` + +```haskell +maximumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a +``` + +```haskell +minimumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a +``` + +#### Searches + +```haskell +notElem :: (Foldable t, Eq a) => a -> t a -> Bool +``` + +```haskell +find :: Foldable t => (a -> Bool) -> t a -> Maybe a +``` + + +```haskell +foldr1May :: (a -> a -> a) -> [a] -> Maybe a +``` + +```haskell +foldl1May :: (a -> a -> a) -> [a] -> Maybe a +``` diff --git a/docs/Function.md b/docs/Function.md index a8f23e8cd..668591455 100644 --- a/docs/Function.md +++ b/docs/Function.md @@ -1,50 +1,153 @@ Functions ========= +Composition +----------- + +#### $ + ```haskell ($) :: (a -> b) -> a -> b ``` +Infix form of function application. Applies a function from ``a → b`` to an +argument ``a``. + +*Example*: + ```haskell -(&) :: a -> (a -> b) -> b +> take 2 $ [1,2,3] +[1,2] ``` +#### . + ```haskell (.) :: (b -> c) -> (a -> b) -> a -> c ``` +Function composition. Composes a function ``f`` (``b → c``) with a function +``g`` (``a → b``) yielding ``f ∘ g``. + +*Example*: + +```haskell +> map (negate . abs) [-1,0,1] +[-1,0,-1] +``` + +#### & + +```haskell +(&) :: a -> (a -> b) -> b +``` + +Flipped form of ``($)`` which applies an argument ``a`` to a function ``a → b``. + +*Example*: + +```haskell +> [1,2,3] & take 2 +[1,2] + +> replicate 10 3 & take 5 & tail +[3,3,3,3] +``` + +#### flip + ```haskell flip :: (a -> b -> c) -> b -> a -> c ``` +Flip takes a function of two arguments and returns a function taking the them in +reverse order. + +*Example*: + +```haskell +λ> flip take [1,2,3] 2 +[1,2] +``` + +#### on + ```haskell on :: (b -> b -> c) -> (a -> b) -> a -> a -> c ``` +*Example*: + +```haskell +> sortBy (compare `on` fst) [(1,2), (3,4), (0,1)] +[(0,1),(1,2),(3,4)] +``` + +#### const + ```haskell const :: a -> b -> a ``` +*Example*: + +#### fix + ```haskell fix :: (a -> a) -> a ``` -```haskell -($!) :: (a -> b) -> a -> b -``` +*Example*: + +#### identity ```haskell identity :: a -> a ``` +The identity function maps any value to itself. + +#### applyN + +Apply a function to a value `n` times. + +*Example*: + ```haskell -($!!) :: NFData a => (a -> b) -> a -> b +applyN :: Int -> (a -> a) -> a -> a ``` +```haskell +> applyN 25 (+2) 0 +50 + +> applyN 3 (1:) [] +[1,1,1] +``` + +Strictness +----------- + +#### $! + +```haskell +($!) :: NFData a => (a -> b) -> a -> b +``` + +*Example*: + +#### $!! + ```haskell ($!!) :: NFData a => (a -> b) -> a -> b ``` +*Example*: + +#### force + ```haskell force :: NFData a => a -> a ``` + +*Example*: diff --git a/docs/Functor.md b/docs/Functor.md new file mode 100644 index 000000000..44c441905 --- /dev/null +++ b/docs/Functor.md @@ -0,0 +1,40 @@ +Functor +======= + +#### map + +```haskell +map :: Functor f => (a -> b) -> f a -> f b +``` + +#### $> + +```haskell +($>) :: Functor f => f a -> b -> f b +``` + +#### <$> + +```haskell +(<$>) :: Functor f => (a -> b) -> f a -> f b +``` + +#### <<$>> + +```haskell +(<<$>>) :: (Functor f, Functor g) => (a -> b) -> f (g a) -> f (g b) +``` + +#### void + +```haskell +void :: Functor f => f a -> f () +``` + +#### foreach + +```haskell +foreach :: Functor f => f a -> (a -> b) -> f b +``` + + diff --git a/docs/Generics.md b/docs/Generics.md new file mode 100644 index 000000000..ab46d3cda --- /dev/null +++ b/docs/Generics.md @@ -0,0 +1,2 @@ +Generics +======== diff --git a/docs/Hashing.md b/docs/Hashing.md new file mode 100644 index 000000000..db193d977 --- /dev/null +++ b/docs/Hashing.md @@ -0,0 +1,14 @@ +Hashing +======= + +```haskell +hashWithSalt :: Hashable a => Int -> a -> Int +``` + +```haskell +hash :: Hashable a => a -> Int +``` + +```haskell +hashUsing :: Hashable b => (a -> b) -> Int -> a -> Int +``` diff --git a/docs/Index.md b/docs/Index.md deleted file mode 100644 index 1b1b3dab7..000000000 --- a/docs/Index.md +++ /dev/null @@ -1,32 +0,0 @@ -Welcome to project documentation. - -- [Printing](Printing.md) -- [File Handling](Files.md) -- [Strings](Strings.md) -- [Functions](Function.md) -- [Functors](Applicative.md) -- [Monad](Monad.md) -- [Maybe](Maybe.md) -- [Either](Either.md) -- [Booleans](Bool.md) -- [Numbers](Numbers.md) -- [Monoid](Monoid.md) -- [Semigroup](Semigroup.md) -- [Bifunctor](Bifunctor.md) -- [Lists](List.md) -- [Folds](Folds.md) -- [Traversals](Traversals.md) -- [Transformers](Transformers.md) -- [Reader](Reader.md) -- [State](State.md) -- [Exception Handling](Exceptions.md) -- [ST](ST.md) -- [Async & Concurrency](Concurrency.md) -- [Storable & Bytes](Storable.md) -- [System](Systsem.md) -- [Dictionaries](Map.md) -- [Sets](Set.md) -- [Tuples](Tuples.md) -- [Generics](Generics.md) -- [Type Level Programming](TypeLevel.md) -- [Unsafe](Unsafe.md) diff --git a/docs/List.md b/docs/List.md index 3135a4926..7c39f02b2 100644 --- a/docs/List.md +++ b/docs/List.md @@ -1,104 +1,158 @@ List ==== -#### Slicing +Slicing +------- + +#### head ```haskell head :: Foldable f => f a -> Maybe a ``` +#### tailMay + ```haskell tailMay :: [a] -> Maybe [a] ``` +#### tailSafe + ```haskell tailSafe :: [a] -> [a] ``` +#### initMay + ```haskell initMay :: [a] -> Maybe [a] ``` +#### initSafe + ```haskell initSafe :: [a] -> [a] ``` +#### initDef + ```haskell initDef :: [a] -> [a] -> [a] ``` +#### lastMay + ```haskell lastMay :: [a] -> Maybe a ``` +#### lastDef + ```haskell lastDef :: a -> [a] -> a ``` -```haskell -list :: [b] -> (a -> b) -> [a] -> [b] -``` +#### drop ```haskell drop :: Int -> [a] -> [a] ``` +#### take + ```haskell take :: Int -> [a] -> [a] ``` -#### Unpacking +Unpacking +--------- + +#### uncons ```haskell uncons :: [a] -> Maybe (a, [a]) ``` +#### unsnoc + ```haskell unsnoc :: [x] -> Maybe ([x],x) ``` -#### Sorting +#### list + +```haskell +list :: [b] -> (a -> b) -> [a] -> [b] +``` + +Sorting +--------- + +#### sortOn ```haskell sortOn :: Ord o => (a -> o) -> [a] -> [a] ``` -#### Removing +Removing +--------- + +#### ordNub ```haskell ordNub :: Ord a => [a] -> [a] ``` -#### Splitting +Splitting +--------- + +#### splitAt ```haskell splitAt :: Int -> [a] -> ([a], [a]) ``` -```haskell -splitAt :: Int -> [a] -> ([a], [a]) -``` +#### intercalate ```haskell intercalate :: [a] -> [[a]] -> [a] ``` -#### Comparison +Comparison +--------- + +#### isPrefixOf ```haskell isPrefixOf :: Eq a => [a] -> [a] -> Bool ``` -#### Filter +Filtering +--------- + +#### filter ```haskell filter :: (a -> Bool) -> [a] -> [a] ``` +#### replicate + ```haskell replicate :: Int -> a -> [a] ``` +Indexing +-------- + +#### atMay + ```haskell -map :: Functor f => (a -> b) -> f a -> f b +atMay :: [a] -> Int -> Maybe a +``` + +#### atDef + +```haskell +atDef :: a -> [a] -> Int -> a ``` diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 000000000..e0d0d9ad3 --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,225 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +PAPER = +BUILDDIR = _build + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . +# the i18n builder cannot share the environment and doctrees with the others +I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . + +.PHONY: help +help: + @echo "Please use \`make ' where is one of" + @echo " html to make standalone HTML files" + @echo " dirhtml to make HTML files named index.html in directories" + @echo " singlehtml to make a single large HTML file" + @echo " pickle to make pickle files" + @echo " json to make JSON files" + @echo " htmlhelp to make HTML files and a HTML help project" + @echo " qthelp to make HTML files and a qthelp project" + @echo " applehelp to make an Apple Help Book" + @echo " devhelp to make HTML files and a Devhelp project" + @echo " epub to make an epub" + @echo " epub3 to make an epub3" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " latexpdf to make LaTeX files and run them through pdflatex" + @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" + @echo " text to make text files" + @echo " man to make manual pages" + @echo " texinfo to make Texinfo files" + @echo " info to make Texinfo files and run them through makeinfo" + @echo " gettext to make PO message catalogs" + @echo " changes to make an overview of all changed/added/deprecated items" + @echo " xml to make Docutils-native XML files" + @echo " pseudoxml to make pseudoxml-XML files for display purposes" + @echo " linkcheck to check all external links for integrity" + @echo " doctest to run all doctests embedded in the documentation (if enabled)" + @echo " coverage to run coverage check of the documentation (if enabled)" + @echo " dummy to check syntax errors of document sources" + +.PHONY: clean +clean: + rm -rf $(BUILDDIR)/* + +.PHONY: html +html: + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + +.PHONY: dirhtml +dirhtml: + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." + +.PHONY: singlehtml +singlehtml: + $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml + @echo + @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." + +.PHONY: pickle +pickle: + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle + @echo + @echo "Build finished; now you can process the pickle files." + +.PHONY: json +json: + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json + @echo + @echo "Build finished; now you can process the JSON files." + +.PHONY: htmlhelp +htmlhelp: + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp + @echo + @echo "Build finished; now you can run HTML Help Workshop with the" \ + ".hhp project file in $(BUILDDIR)/htmlhelp." + +.PHONY: qthelp +qthelp: + $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp + @echo + @echo "Build finished; now you can run "qcollectiongenerator" with the" \ + ".qhcp project file in $(BUILDDIR)/qthelp, like this:" + @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/protolude.qhcp" + @echo "To view the help file:" + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/protolude.qhc" + +.PHONY: applehelp +applehelp: + $(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp + @echo + @echo "Build finished. The help book is in $(BUILDDIR)/applehelp." + @echo "N.B. You won't be able to view it unless you put it in" \ + "~/Library/Documentation/Help or install it in your application" \ + "bundle." + +.PHONY: devhelp +devhelp: + $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp + @echo + @echo "Build finished." + @echo "To view the help file:" + @echo "# mkdir -p $$HOME/.local/share/devhelp/protolude" + @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/protolude" + @echo "# devhelp" + +.PHONY: epub +epub: + $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub + @echo + @echo "Build finished. The epub file is in $(BUILDDIR)/epub." + +.PHONY: epub3 +epub3: + $(SPHINXBUILD) -b epub3 $(ALLSPHINXOPTS) $(BUILDDIR)/epub3 + @echo + @echo "Build finished. The epub3 file is in $(BUILDDIR)/epub3." + +.PHONY: latex +latex: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo + @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." + @echo "Run \`make' in that directory to run these through (pdf)latex" \ + "(use \`make latexpdf' here to do that automatically)." + +.PHONY: latexpdf +latexpdf: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through pdflatex..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +.PHONY: latexpdfja +latexpdfja: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through platex and dvipdfmx..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +.PHONY: text +text: + $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text + @echo + @echo "Build finished. The text files are in $(BUILDDIR)/text." + +.PHONY: man +man: + $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man + @echo + @echo "Build finished. The manual pages are in $(BUILDDIR)/man." + +.PHONY: texinfo +texinfo: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo + @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." + @echo "Run \`make' in that directory to run these through makeinfo" \ + "(use \`make info' here to do that automatically)." + +.PHONY: info +info: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo "Running Texinfo files through makeinfo..." + make -C $(BUILDDIR)/texinfo info + @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." + +.PHONY: gettext +gettext: + $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale + @echo + @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." + +.PHONY: changes +changes: + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes + @echo + @echo "The overview file is in $(BUILDDIR)/changes." + +.PHONY: linkcheck +linkcheck: + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in $(BUILDDIR)/linkcheck/output.txt." + +.PHONY: doctest +doctest: + $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest + @echo "Testing of doctests in the sources finished, look at the " \ + "results in $(BUILDDIR)/doctest/output.txt." + +.PHONY: coverage +coverage: + $(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage + @echo "Testing of coverage in the sources finished, look at the " \ + "results in $(BUILDDIR)/coverage/python.txt." + +.PHONY: xml +xml: + $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml + @echo + @echo "Build finished. The XML files are in $(BUILDDIR)/xml." + +.PHONY: pseudoxml +pseudoxml: + $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml + @echo + @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." + +.PHONY: dummy +dummy: + $(SPHINXBUILD) -b dummy $(ALLSPHINXOPTS) $(BUILDDIR)/dummy + @echo + @echo "Build finished. Dummy builder generates no files." diff --git a/docs/Maybe.md b/docs/Maybe.md new file mode 100644 index 000000000..e155d4122 --- /dev/null +++ b/docs/Maybe.md @@ -0,0 +1,38 @@ +Maybe +===== + +```haskell +maybe :: b -> (a -> b) -> Maybe a -> b +``` + +```haskell +isJust :: Maybe a -> Bool +``` + +```haskell +isNothing :: Maybe a -> Bool +``` + +```haskell +fromJust :: Maybe a -> a +``` + +```haskell +fromMaybe :: a -> Maybe a -> a +``` + +```haskell +listToMaybe :: [a] -> Maybe a +``` + +```haskell +maybeToList :: Maybe a -> [a] +``` + +```haskell +catMaybes :: [Maybe a] -> [a] +``` + +```haskell +mapMaybe :: (a -> Maybe b) -> [a] -> [b] +``` diff --git a/docs/Monad.md b/docs/Monad.md index 53452fdc2..78d0ea4fa 100644 --- a/docs/Monad.md +++ b/docs/Monad.md @@ -1,14 +1,14 @@ Monads ====== -#### Monad +Monad +----- ```haskell class Applicative m => Monad (m :: * -> *) where (>>=) :: m a -> (a -> m b) -> m b (>>) :: m a -> m b -> m b return :: a -> m a - GHC.Base.fail :: GHC.Base.String -> m a ``` ```haskell @@ -119,7 +119,24 @@ ap :: Monad m => m (a -> b) -> m a -> m b (<$!>) :: Monad m => (a -> b) -> m a -> m b ``` -#### MonadPlus +```haskell +whenM :: Monad m => m Bool -> m () -> m () +``` + +```haskell +unlessM :: Monad m => m Bool -> m () -> m () +``` + +```haskell +ifM :: Monad m => m Bool -> m a -> m a -> m a +``` + +```haskell +guardM :: MonadPlus m => m Bool -> m () +``` + +MonadPlus +----- ```haskell class (Alternative m, Monad m) => MonadPlus (m :: * -> *) where diff --git a/docs/Monoid.md b/docs/Monoid.md new file mode 100644 index 000000000..55b8a68f2 --- /dev/null +++ b/docs/Monoid.md @@ -0,0 +1,79 @@ +Monoid +====== + +Monoid +------ + +#### mempty + +```haskell +mempty :: Monoid a => a +``` + +#### <> + +```haskell +(<>) :: Monoid m => m -> m -> m +``` + +```haskell +mappend :: Monoid a => a -> a -> a +``` + +#### mconcat + +```haskell +mconcat :: Monoid a => [a] -> a +``` + +Semigroup +--------- + +#### <> + +```haskell +(<>) :: Semigroup a => a -> a -> a +``` + +#### sconcat + +```haskell +sconcat :: Semigroup a => NonEmpty a -> a +``` + +#### stimes + +```haskell +stimes :: (Semigroup a, Integral b) => b -> a -> a +``` + +```haskell +option :: b -> (a -> b) -> Option a -> b +``` + +```haskell +diff :: Semigroup m => m -> Endo m +``` + +```haskell +cycle1 :: Semigroup m => m -> m +``` + +```haskell +stimesMonoid :: (Integral b, Monoid a) => b -> a -> a +``` + +```haskell +stimesIdempotent :: Integral b => b -> a -> a +``` + +```haskell +stimesIdempotentMonoid :: (Integral b, Monoid a) => b -> a -> a +``` + +```haskell +mtimesDefault :: (Integral b, Monoid a) => b -> a -> a +``` + +NonEmpty +--------- diff --git a/docs/Numbers.md b/docs/Numbers.md new file mode 100644 index 000000000..134ae728f --- /dev/null +++ b/docs/Numbers.md @@ -0,0 +1,31 @@ +Numbers +======= + +* Int8 +* Int16 +* Int32 +* Int64 +* Integer +* Word +* Word8 +* Word16 +* Word32 +* Word64 + +Arithemtic +---------- + +Trigonometric +------------- + +Comparisons +----------- + +Ratios +------ + +Complex Numbers +--------------- + +Conversions +----------- diff --git a/docs/Reader.md b/docs/Reader.md new file mode 100644 index 000000000..b8c4c7e81 --- /dev/null +++ b/docs/Reader.md @@ -0,0 +1,2 @@ +Reader +====== diff --git a/docs/ST.md b/docs/ST.md new file mode 100644 index 000000000..2c23fbea4 --- /dev/null +++ b/docs/ST.md @@ -0,0 +1,2 @@ +ST +== diff --git a/docs/State.md b/docs/State.md new file mode 100644 index 000000000..b81674eed --- /dev/null +++ b/docs/State.md @@ -0,0 +1,2 @@ +State +===== diff --git a/docs/Strings.md b/docs/Strings.md new file mode 100644 index 000000000..17f86d104 --- /dev/null +++ b/docs/Strings.md @@ -0,0 +1,95 @@ +Strings +======= + +```haskell +import qualified Data.Text as T +import qualified Data.Text.Lazy as L +``` + +Text +---- + +The Text type represents Unicode character strings, in a time and space-efficient manner. This package provides text processing capabilities that are optimized for performance critical use, both in terms of large data quantities and high speed. + +LText +----- + +Bytestring +---------- + +LBytestring +----------- + +Encoding +---------- + +#### encodeUtf8 + +```haskell +encodeUtf8 :: Text -> ByteString +``` + +```haskell +> encodeUtf8 "ポケット" +"\227\131\157\227\130\177\227\131\131\227\131\136" +``` + +#### decodeUtf8 + +```haskell +decodeUtf8 :: ByteString -> Text +``` + +```haskell +> putStrLn $ decodeUtf8 "\227\131\157\227\130\177\227\131\131\227\131\136" +ポケット +``` + +#### decodeUtf8' + +```haskell +decodeUtf8' :: ByteString -> Either UnicodeException Text +``` + +#### decodeUtf8With + +```haskell +decodeUtf8With :: OnDecodeError -> ByteString -> Text +``` + +Conversion +---------- + +```haskell +class StringConv a b where + strConv :: Leniency -> a -> b + +data Leniency = Lenient | Strict +``` + +```haskell +toS :: StringConv a b => a -> b +``` + +```haskell +toSL :: StringConv a b => a -> b +``` + +*Example*: + +```haskell +a :: LByteString +a = "Einstein" + +b :: Text +b = "Feynmann" + +c :: ByteString +c = "Schrödinger" + +example1 :: ByteString +example1 = toS b + +example2 :: Bool +example2 = (a == toS b) && (toS b == c) +``` diff --git a/docs/Transformers.md b/docs/Transformers.md new file mode 100644 index 000000000..90200db72 --- /dev/null +++ b/docs/Transformers.md @@ -0,0 +1,2 @@ +Transformers +============ diff --git a/docs/Traversals.md b/docs/Traversals.md new file mode 100644 index 000000000..31a1c1607 --- /dev/null +++ b/docs/Traversals.md @@ -0,0 +1,2 @@ +Traversals +========== diff --git a/docs/Tuple.md b/docs/Tuple.md index 3b59ad459..f9cbb5b73 100644 --- a/docs/Tuple.md +++ b/docs/Tuple.md @@ -1,22 +1,76 @@ Tuples ====== +#### fst + ```haskell fst :: (a, b) -> a ``` +Extract the first component of a pair. + +*Example*: + +```haskell +> fst (1,2) +``` + +#### snd + ```haskell snd :: (a, b) -> b ``` +Extract the second component of a pair. + +*Example*: + +```haskell +> snd (1,2) +2 +``` + +#### swap + ```haskell swap :: (a, b) -> (b, a) ``` +Swap the components of a pair. + +*Example*: + +```haskell +> swap (1,2) +(2,1) +``` + +#### curry + ```haskell curry :: ((a, b) -> c) -> a -> b -> c ``` +curry converts an uncurried function to a curried function. + +*Example*: + +```haskell +> curry fst 1 2 +1 +``` + +#### uncurry + ```haskell uncurry :: (a -> b -> c) -> (a, b) -> c ``` + +uncurry converts a curried function to a function on pairs. + +*Example*: + +```haskell +> uncurry (+) (1,2) +3 +``` diff --git a/docs/TypeLevel.md b/docs/TypeLevel.md index 3a0346a3d..2ac046872 100644 --- a/docs/TypeLevel.md +++ b/docs/TypeLevel.md @@ -30,6 +30,44 @@ vacuous :: Functor f => f Void -> f a data Proxy (t :: k) = Proxy ``` +#### Symbol + +```haskell +symbolVal :: KnownSymbol n => proxy n -> String +``` + +*Example*: + +```haskell +b :: String +b = symbolVal (Proxy :: Proxy "foo") +``` + +```haskell +someSymbolVal :: String -> SomeSymbol +``` + +*Example*: + +#### Nat + +```haskell +natVal :: KnownNat n => proxy n -> Integer +``` + +*Example*: + +```haskell +a :: Integer +a = natVal (Proxy :: Proxy 1) +``` + +```haskell +someNatVal :: Integer -> Maybe SomeNat +``` + +*Example*: + #### Type Equality ```haskell diff --git a/docs/Unsafe.md b/docs/Unsafe.md new file mode 100644 index 000000000..24da25e38 --- /dev/null +++ b/docs/Unsafe.md @@ -0,0 +1,2 @@ +Unsafe +====== diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 000000000..afc5b41fc --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,348 @@ +# -*- coding: utf-8 -*- +# +# protolude documentation build configuration file, created by +# sphinx-quickstart on Thu Dec 8 09:08:30 2016. +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# +# import os +# import sys +# sys.path.insert(0, os.path.abspath('.')) + +import sphinx_rtd_theme +from recommonmark.parser import CommonMarkParser + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +# +# needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + 'sphinx.ext.githubpages', +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +# +# source_suffix = ['.rst', '.md'] + +source_parsers = { + '.md': CommonMarkParser, +} +source_suffix = ['.rst', '.md'] + +# The encoding of source files. +# +# source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'protolude' +copyright = u'2016, Stephen Diehl' +author = u'Stephen Diehl' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = u'0.1.11' +# The full version, including alpha/beta/rc tags. +release = u'0.1.11' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +# +# today = '' +# +# Else, today_fmt is used as the format for a strftime call. +# +# today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This patterns also effect to html_static_path and html_extra_path +exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +# +# default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +# +# add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +# +# add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +# +# show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +# modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +# keep_warnings = False + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = False + + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = "sphinx_rtd_theme" + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +# +# html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +# html_theme_path = [] +html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] + +# The name for this set of Sphinx documents. +# " v documentation" by default. +# +# html_title = u'protolude v0.1.11' + +# A shorter title for the navigation bar. Default is the same as html_title. +# +# html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +# +# html_logo = None + +# The name of an image file (relative to this directory) to use as a favicon of +# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +# +# html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +# +# html_extra_path = [] + +# If not None, a 'Last updated on:' timestamp is inserted at every page +# bottom, using the given strftime format. +# The empty string is equivalent to '%b %d, %Y'. +# +# html_last_updated_fmt = None + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +# +# html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +# +# html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +# +# html_additional_pages = {} + +# If false, no module index is generated. +# +# html_domain_indices = True + +# If false, no index is generated. +# +# html_use_index = True + +# If true, the index is split into individual pages for each letter. +# +# html_split_index = False + +# If true, links to the reST sources are added to the pages. +# +# html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +# +# html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +# +# html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +# +# html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +# html_file_suffix = None + +# Language to be used for generating the HTML full-text search index. +# Sphinx supports the following languages: +# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' +# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr', 'zh' +# +# html_search_language = 'en' + +# A dictionary with options for the search language support, empty by default. +# 'ja' uses this config value. +# 'zh' user can custom change `jieba` dictionary path. +# +# html_search_options = {'type': 'default'} + +# The name of a javascript file (relative to the configuration directory) that +# implements a search results scorer. If empty, the default will be used. +# +# html_search_scorer = 'scorer.js' + +# Output file base name for HTML help builder. +htmlhelp_basename = 'protoludedoc' + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + # + # 'papersize': 'letterpaper', + + # The font size ('10pt', '11pt' or '12pt'). + # + # 'pointsize': '10pt', + + # Additional stuff for the LaTeX preamble. + # + # 'preamble': '', + + # Latex figure (float) alignment + # + # 'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + (master_doc, 'protolude.tex', u'protolude Documentation', + u'Stephen Diehl', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +# +# latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +# +# latex_use_parts = False + +# If true, show page references after internal links. +# +# latex_show_pagerefs = False + +# If true, show URL addresses after external links. +# +# latex_show_urls = False + +# Documents to append as an appendix to all manuals. +# +# latex_appendices = [] + +# It false, will not define \strong, \code, itleref, \crossref ... but only +# \sphinxstrong, ..., \sphinxtitleref, ... To help avoid clash with user added +# packages. +# +# latex_keep_old_macro_names = True + +# If false, no module index is generated. +# +# latex_domain_indices = True + + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + (master_doc, 'protolude', u'protolude Documentation', + [author], 1) +] + +# If true, show URL addresses after external links. +# +# man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + (master_doc, 'protolude', u'protolude Documentation', + author, 'protolude', 'One line description of project.', + 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +# +# texinfo_appendices = [] + +# If false, no module index is generated. +# +# texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +# +# texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +# +# texinfo_no_detailmenu = False diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 000000000..b95e877bc --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,47 @@ +Protolude Documentation +======================= + +An alternative Prelude. + +.. toctree:: + :maxdepth: 0 + Function + Strings + Bool + Numbers + Printing + Files + Debug + Bits + Functor + Applicative + Monad + Maybe + Either + Monoid + Semigroup + Bifunctor + List + Folds + Traversals + Transformers + Reader + State + Exceptions + ST + Concurrency + Storable + System + Map + Set + Tuple + Generics + Hashing + TypeLevel + Unsafe + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`search` diff --git a/protolude.cabal b/protolude.cabal index 3f84c0de1..c9cc2836f 100644 --- a/protolude.cabal +++ b/protolude.cabal @@ -1,5 +1,5 @@ name: protolude -version: 0.1.11 +version: 0.2 synopsis: A sensible set of defaults for writing custom Preludes. description: A sensible set of defaults for writing custom Preludes. homepage: https://github.com/sdiehl/protolude diff --git a/src/Functor.hs b/src/Functor.hs index 80683396e..7d0a31d9f 100644 --- a/src/Functor.hs +++ b/src/Functor.hs @@ -6,9 +6,12 @@ module Functor ( Functor(..), ($>), (<$>), + (<<$>>), void, ) where +import Data.Function ((.)) + #if (__GLASGOW_HASKELL__ >= 710) import Data.Functor ( Functor(..) @@ -23,16 +26,17 @@ import Data.Functor ( ) import Data.Function (flip) -import Data.Function ((.)) infixl 4 $> ($>) :: Functor f => f a -> b -> f b ($>) = flip (<$) -(<<$>>) :: (Functor f, Functor g) => (a -> b) -> f (g a) -> f (g b) -(<<$>>) = fmap . fmap - void :: Functor f => f a -> f () void x = () <$ x #endif + +infixl 4 <<$>> + +(<<$>>) :: (Functor f, Functor g) => (a -> b) -> f (g a) -> f (g b) +(<<$>>) = fmap . fmap diff --git a/src/Protolude.hs b/src/Protolude.hs index dc51c42ff..c292626f0 100644 --- a/src/Protolude.hs +++ b/src/Protolude.hs @@ -103,6 +103,10 @@ import Data.Functor.Identity as X #if ( __GLASGOW_HASKELL__ >= 800 ) import Data.Monoid as X +import Data.List.NonEmpty as X ( + NonEmpty(..) + , nonEmpty + ) import Data.Semigroup as X ( Semigroup(sconcat, stimes) , WrappedMonoid @@ -201,6 +205,7 @@ import Data.Typeable as X ( import Data.Type.Coercion as X ( Coercion(..) , coerceWith + , repr ) import Data.Type.Equality as X ( @@ -223,7 +228,7 @@ import Data.Void as X ( import Control.Monad.State as X ( MonadState , State - , StateT + , StateT(StateT) , put , get , gets @@ -243,7 +248,7 @@ import Control.Monad.State as X ( import Control.Monad.Reader as X ( MonadReader , Reader - , ReaderT + , ReaderT(ReaderT) , ask , asks , local @@ -255,7 +260,7 @@ import Control.Monad.Reader as X ( import Control.Monad.Except as X ( MonadError , Except - , ExceptT + , ExceptT(ExceptT) , throwError , catchError , runExcept @@ -274,7 +279,19 @@ import Data.Bits as X hiding ( unsafeShiftL , unsafeShiftR ) -import Data.Word as X +import Data.Word as X ( + Word + , Word16 + , Word32 + , Word64 + , Word8 +#if (__GLASGOW_HASKELL__ >= 710) + , byteSwap16 + , byteSwap32 + , byteSwap64 +#endif + ) + import Data.Either as X import Data.Complex as X import Data.Char as X (chr) @@ -293,6 +310,7 @@ import Data.Function as X ( -- Genericss import GHC.Generics as X ( Generic(..) + , Generic1 , Rep , K1(..) , M1(..) @@ -341,6 +359,16 @@ import Data.Text.Encoding as X ( , decodeUtf8With ) +import Data.Text.Encoding.Error as X ( + OnDecodeError + , OnError + , UnicodeException + , lenientDecode + , strictDecode + , ignore + , replace + ) + -- IO import System.Exit as X import System.Environment as X (getArgs) @@ -403,7 +431,7 @@ map :: Functor f => (a -> b) -> f a -> f b map = fmap uncons :: [a] -> Maybe (a, [a]) -uncons [] = Nothing +uncons [] = Nothing uncons (x:xs) = Just (x, xs) unsnoc :: [x] -> Maybe ([x],x) diff --git a/stack.yaml b/stack.yaml index 38583d04e..bb517b9f0 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,4 +1,4 @@ -resolver: lts-5.10 +resolver: lts-6.2 packages: - '.' extra-deps: