From 257a38f68fbba6a6b16d357a61aeb4ff5fa1b0ca Mon Sep 17 00:00:00 2001 From: Stephen Diehl Date: Mon, 12 Dec 2016 13:09:18 +0000 Subject: [PATCH] functor module --- docs/Functor.md | 26 ++++++++++++++++++++++++++ docs/List.md | 4 ---- docs/Strings.md | 14 ++++++++++++-- docs/index.rst | 1 + src/Protolude.hs | 1 + 5 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 docs/Functor.md diff --git a/docs/Functor.md b/docs/Functor.md new file mode 100644 index 000000000..a557294b1 --- /dev/null +++ b/docs/Functor.md @@ -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 () +``` diff --git a/docs/List.md b/docs/List.md index 7c3b64ba6..fdc7b6442 100644 --- a/docs/List.md +++ b/docs/List.md @@ -109,7 +109,3 @@ filter :: (a -> Bool) -> [a] -> [a] ```haskell replicate :: Int -> a -> [a] ``` - -```haskell -map :: Functor f => (a -> b) -> f a -> f b -``` diff --git a/docs/Strings.md b/docs/Strings.md index 2f77d78b1..17f86d104 100644 --- a/docs/Strings.md +++ b/docs/Strings.md @@ -29,22 +29,32 @@ Encoding 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 -> Text +decodeUtf8' :: ByteString -> Either UnicodeException Text ``` #### decodeUtf8With ```haskell -decodeUtf8With :: Data.Text.Encoding.Error.OnDecodeError -> ByteString -> Text +decodeUtf8With :: OnDecodeError -> ByteString -> Text ``` Conversion diff --git a/docs/index.rst b/docs/index.rst index 98aedfc9d..b195c6775 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -13,6 +13,7 @@ An alternative Prelude. Files Debug Bits + Functor Applicative Monad Maybe diff --git a/src/Protolude.hs b/src/Protolude.hs index c9d020d5c..8f2805523 100644 --- a/src/Protolude.hs +++ b/src/Protolude.hs @@ -352,6 +352,7 @@ import Data.Text.Encoding as X ( import Data.Text.Encoding.Error as X ( OnDecodeError , OnError + , UnicodeException , lenientDecode , strictDecode , ignore