basic hierarchy in place

This commit is contained in:
Stephen Diehl
2016-12-10 12:46:48 +00:00
parent c28fa6b00c
commit b32c80d0bb
11 changed files with 261 additions and 146 deletions
-4
View File
@@ -29,10 +29,6 @@ class Functor f => Applicative (f :: * -> *) where
(<*) :: f a -> f b -> f a (<*) :: f a -> f b -> f a
``` ```
```haskell
(<$>) :: Functor f => (a -> b) -> f a -> f b
```
```haskell ```haskell
orAlt :: (Alternative f, Monoid a) => f a -> f a orAlt :: (Alternative f, Monoid a) => f a -> f a
``` ```
+58
View File
@@ -1,38 +1,96 @@
Debug Debug
===== =====
Stubbing
--------
#### undefined
```haskell ```haskell
undefined :: a 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 ```haskell
notImplemented :: a notImplemented :: a
``` ```
An undefined expression standing in for a yet to completed program.
*Example*:
```haskell
main :: IO ()
main = notImplemented
```
Tracing
-------
#### trace
```haskell ```haskell
trace :: Print b => b -> a -> a trace :: Print b => b -> a -> a
``` ```
*Example*:
#### traceM
```haskell ```haskell
traceM :: (Monad m) => Text -> m () traceM :: (Monad m) => Text -> m ()
``` ```
*Example*:
#### traceId
```haskell ```haskell
traceId :: Text -> Text traceId :: Text -> Text
``` ```
*Example*:
#### traceShowM
```haskell ```haskell
traceShowM :: (P.Show a, Monad m) => a -> m () traceShowM :: (P.Show a, Monad m) => a -> m ()
``` ```
*Example*:
#### traceShowId
```haskell ```haskell
traceShowId :: P.Show a => a -> a traceShowId :: P.Show a => a -> a
``` ```
*Example*:
#### traceShow
```haskell ```haskell
traceShow :: P.Show a => a -> b -> b traceShow :: P.Show a => a -> b -> b
``` ```
*Example*:
#### traceIO
```haskell ```haskell
traceIO :: Print b => b -> a -> IO a traceIO :: Print b => b -> a -> IO a
``` ```
*Example*:
+1 -1
View File
@@ -61,7 +61,7 @@ throwSTM :: Exception e => e -> STM a
throwError :: MonadError e m => e -> m a throwError :: MonadError e m => e -> m a
``` ```
#### Panic #### Fatal Errors
```haskell ```haskell
data FatalError = FatalError {msg :: Text} data FatalError = FatalError {msg :: Text}
+98
View File
@@ -0,0 +1,98 @@
Functions
=========
Composition
-----------
#### $
```haskell
($) :: (a -> b) -> a -> b
```
*Example*:
#### .
```haskell
(.) :: (b -> c) -> (a -> b) -> a -> c
```
*Example*:
#### &
```haskell
(&) :: a -> (a -> b) -> b
```
*Example*:
#### flip
```haskell
flip :: (a -> b -> c) -> b -> a -> c
```
*Example*:
#### on
```haskell
on :: (b -> b -> c) -> (a -> b) -> a -> a -> c
```
*Example*:
#### const
```haskell
const :: a -> b -> a
```
*Example*:
#### fix
```haskell
fix :: (a -> a) -> a
```
*Example*:
#### identity
```haskell
identity :: a -> a
```
The identity function maps any value to itself.
*Example*:
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*:
-83
View File
@@ -1,83 +0,0 @@
Functions
=========
.. highlight:: haskell
$
***
::
($) :: (a -> b) -> a -> b
&
***
::
(&) :: a -> (a -> b) -> b
.
***
::
(.) :: (b -> c) -> (a -> b) -> a -> c
flip
****
::
flip :: (a -> b -> c) -> b -> a -> c
on
***
::
on :: (b -> b -> c) -> (a -> b) -> a -> a -> c
const
*****
::
const :: a -> b -> a
fix
***
::
fix :: (a -> a) -> a
identity
********
::
identity :: a -> a
$!
***
::
($!) :: NFData a => (a -> b) -> a -> b
$!!
***
::
($!!) :: NFData a => (a -> b) -> a -> b
force
*****
::
force :: NFData a => a -> a
-1
View File
@@ -9,7 +9,6 @@ class Applicative m => Monad (m :: * -> *) where
(>>=) :: m a -> (a -> m b) -> m b (>>=) :: m a -> (a -> m b) -> m b
(>>) :: m a -> m b -> m b (>>) :: m a -> m b -> m b
return :: a -> m a return :: a -> m a
GHC.Base.fail :: GHC.Base.String -> m a
``` ```
```haskell ```haskell
+48 -4
View File
@@ -1,14 +1,58 @@
Strings Strings
======= =======
```haskell
import qualified Data.Text as T
import qualified Data.Text.Lazy as L
```
Text 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 LText
~~~~ -----
Bytestring Bytestring
~~~~~~~~~~ ----------
LBytestring LBytestring
~~~~~~~~~~~ -----------
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)
```
+39 -47
View File
@@ -1,84 +1,76 @@
Tuples Tuples
====== ======
.. highlight:: haskell #### fst
fst ```haskell
*** fst :: (a, b) -> a
```
::
fst :: (a, b) -> a
Extract the first component of a pair. Extract the first component of a pair.
*Example*: *Example*:
:: ```haskell
> fst (1,2)
```
> fst (1,2) #### snd
1
snd ```haskell
*** snd :: (a, b) -> b
```
::
snd :: (a, b) -> b
Extract the second component of a pair. Extract the second component of a pair.
*Example*: *Example*:
:: ```haskell
> snd (1,2)
2
```
> snd (1,2) #### swap
2
swap ```haskell
**** swap :: (a, b) -> (b, a)
```
::
swap :: (a, b) -> (b, a)
Swap the components of a pair. Swap the components of a pair.
*Example*: *Example*:
:: ```haskell
> swap (1,2)
(2,1)
```
> swap (1,2) #### curry
(2,1)
curry ```haskell
***** curry :: ((a, b) -> c) -> a -> b -> c
```
::
curry :: ((a, b) -> c) -> a -> b -> c
curry converts an uncurried function to a curried function. curry converts an uncurried function to a curried function.
*Example*: *Example*:
:: ```haskell
> curry fst 1 2
1
```
> curry fst 1 2 #### uncurry
1
uncurry ```haskell
******* uncurry :: (a -> b -> c) -> (a, b) -> c
```
::
uncurry :: (a -> b -> c) -> (a, b) -> c
uncurry converts a curried function to a function on pairs. uncurry converts a curried function to a function on pairs.
*Example*: *Example*:
:: ```haskell
> uncurry (+) (1,2)
> uncurry (+) (1,2) 3
3 ```
+4 -4
View File
@@ -5,17 +5,17 @@ An alternative Prelude.
.. toctree:: .. toctree::
:maxdepth: 0 :maxdepth: 0
Function
Strings
Bool
Numbers
Printing Printing
Debug Debug
Files Files
Strings
Function
Applicative Applicative
Monad Monad
Maybe Maybe
Either Either
Bool
Numbers
Monoid Monoid
Semigroup Semigroup
Bifunctor Bifunctor
+12 -1
View File
@@ -196,6 +196,7 @@ import Data.Typeable as X (
import Data.Type.Coercion as X ( import Data.Type.Coercion as X (
Coercion(..) Coercion(..)
, coerceWith , coerceWith
, repr
) )
import Data.Type.Equality as X ( import Data.Type.Equality as X (
@@ -269,7 +270,17 @@ import Data.Bits as X hiding (
unsafeShiftL unsafeShiftL
, unsafeShiftR , unsafeShiftR
) )
import Data.Word as X import Data.Word as X (
byteSwap16
, byteSwap32
, byteSwap64
, Word
, Word16
, Word32
, Word64
, Word8
)
import Data.Either as X import Data.Either as X
import Data.Complex as X import Data.Complex as X
import Data.Char as X (chr) import Data.Char as X (chr)
+1 -1
View File
@@ -1,4 +1,4 @@
resolver: lts-5.10 resolver: lts-6.2
packages: packages:
- '.' - '.'
extra-deps: extra-deps: