functor module

This commit is contained in:
Stephen Diehl
2016-12-12 13:09:18 +00:00
parent 66958def93
commit 257a38f68f
5 changed files with 40 additions and 6 deletions
+26
View File
@@ -0,0 +1,26 @@
Functor
=======
```haskell
foreach :: Functor f => f a -> (a -> b) -> f b
```
```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)
```
```haskell
void :: Functor f => f a -> f ()
```
-4
View File
@@ -109,7 +109,3 @@ filter :: (a -> Bool) -> [a] -> [a]
```haskell ```haskell
replicate :: Int -> a -> [a] replicate :: Int -> a -> [a]
``` ```
```haskell
map :: Functor f => (a -> b) -> f a -> f b
```
+12 -2
View File
@@ -29,22 +29,32 @@ Encoding
encodeUtf8 :: Text -> ByteString encodeUtf8 :: Text -> ByteString
``` ```
```haskell
> encodeUtf8 "ポケット"
"\227\131\157\227\130\177\227\131\131\227\131\136"
```
#### decodeUtf8 #### decodeUtf8
```haskell ```haskell
decodeUtf8 :: ByteString -> Text decodeUtf8 :: ByteString -> Text
``` ```
```haskell
> putStrLn $ decodeUtf8 "\227\131\157\227\130\177\227\131\131\227\131\136"
```
#### decodeUtf8' #### decodeUtf8'
```haskell ```haskell
decodeUtf8' :: ByteString -> Text decodeUtf8' :: ByteString -> Either UnicodeException Text
``` ```
#### decodeUtf8With #### decodeUtf8With
```haskell ```haskell
decodeUtf8With :: Data.Text.Encoding.Error.OnDecodeError -> ByteString -> Text decodeUtf8With :: OnDecodeError -> ByteString -> Text
``` ```
Conversion Conversion
+1
View File
@@ -13,6 +13,7 @@ An alternative Prelude.
Files Files
Debug Debug
Bits Bits
Functor
Applicative Applicative
Monad Monad
Maybe Maybe
+1
View File
@@ -352,6 +352,7 @@ import Data.Text.Encoding as X (
import Data.Text.Encoding.Error as X ( import Data.Text.Encoding.Error as X (
OnDecodeError OnDecodeError
, OnError , OnError
, UnicodeException
, lenientDecode , lenientDecode
, strictDecode , strictDecode
, ignore , ignore