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
```
```haskell
(<$>) :: Functor f => (a -> b) -> f a -> f b
```
```haskell
orAlt :: (Alternative f, Monoid a) => f a -> f a
```
+58
View File
@@ -1,38 +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*:
+1 -1
View File
@@ -61,7 +61,7 @@ throwSTM :: Exception e => e -> STM a
throwError :: MonadError e m => e -> m a
```
#### Panic
#### Fatal Errors
```haskell
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 -> m b -> m b
return :: a -> m a
GHC.Base.fail :: GHC.Base.String -> m a
```
```haskell
+48 -4
View File
@@ -1,14 +1,58 @@
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
~~~~~~~~~~~
-----------
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
======
.. highlight:: haskell
#### fst
fst
***
::
fst :: (a, b) -> a
```haskell
fst :: (a, b) -> a
```
Extract the first component of a pair.
*Example*:
::
> fst (1,2)
1
```haskell
> fst (1,2)
```
snd
***
#### snd
::
snd :: (a, b) -> b
```haskell
snd :: (a, b) -> b
```
Extract the second component of a pair.
*Example*:
::
> snd (1,2)
2
```haskell
> snd (1,2)
2
```
swap
****
#### swap
::
swap :: (a, b) -> (b, a)
```haskell
swap :: (a, b) -> (b, a)
```
Swap the components of a pair.
*Example*:
::
> swap (1,2)
(2,1)
```haskell
> swap (1,2)
(2,1)
```
curry
*****
#### curry
::
curry :: ((a, b) -> c) -> a -> b -> c
```haskell
curry :: ((a, b) -> c) -> a -> b -> c
```
curry converts an uncurried function to a curried function.
*Example*:
::
```haskell
> curry fst 1 2
1
```
> curry fst 1 2
1
#### uncurry
uncurry
*******
::
uncurry :: (a -> b -> c) -> (a, b) -> c
```haskell
uncurry :: (a -> b -> c) -> (a, b) -> c
```
uncurry converts a curried function to a function on pairs.
*Example*:
::
> uncurry (+) (1,2)
3
```haskell
> uncurry (+) (1,2)
3
```
+4 -4
View File
@@ -5,17 +5,17 @@ An alternative Prelude.
.. toctree::
:maxdepth: 0
Function
Strings
Bool
Numbers
Printing
Debug
Files
Strings
Function
Applicative
Monad
Maybe
Either
Bool
Numbers
Monoid
Semigroup
Bifunctor
+12 -1
View File
@@ -196,6 +196,7 @@ import Data.Typeable as X (
import Data.Type.Coercion as X (
Coercion(..)
, coerceWith
, repr
)
import Data.Type.Equality as X (
@@ -269,7 +270,17 @@ import Data.Bits as X hiding (
unsafeShiftL
, 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.Complex as X
import Data.Char as X (chr)
+1 -1
View File
@@ -1,4 +1,4 @@
resolver: lts-5.10
resolver: lts-6.2
packages:
- '.'
extra-deps: