diff options
Diffstat (limited to 'src/Data')
-rw-r--r-- | src/Data/List/Extra.hs | 8 | ||||
-rw-r--r-- | src/Data/Monoid/Extra.hs | 6 | ||||
-rw-r--r-- | src/Data/Text/Encoding/Extra.hs | 11 | ||||
-rw-r--r-- | src/Data/Text/Extra.hs | 8 |
4 files changed, 33 insertions, 0 deletions
diff --git a/src/Data/List/Extra.hs b/src/Data/List/Extra.hs new file mode 100644 index 0000000..d18bc76 --- /dev/null +++ b/src/Data/List/Extra.hs @@ -0,0 +1,8 @@ +module Data.List.Extra where + +import Data.Maybe (listToMaybe) + + +(!!?) :: [a] -> Int -> Maybe a +x !!? i | i >= 0 = listToMaybe (drop i x) +_ !!? _ = Nothing diff --git a/src/Data/Monoid/Extra.hs b/src/Data/Monoid/Extra.hs new file mode 100644 index 0000000..e484cf0 --- /dev/null +++ b/src/Data/Monoid/Extra.hs @@ -0,0 +1,6 @@ +module Data.Monoid.Extra where + + +mintercalate :: Monoid b => b -> [b] -> b +mintercalate c (h:t) = foldl (\acc x -> acc <> c <> x) h t +mintercalate _ [] = mempty diff --git a/src/Data/Text/Encoding/Extra.hs b/src/Data/Text/Encoding/Extra.hs new file mode 100644 index 0000000..a8e6234 --- /dev/null +++ b/src/Data/Text/Encoding/Extra.hs @@ -0,0 +1,11 @@ +module Data.Text.Encoding.Extra where + +import Data.ByteString (ByteString) +import Data.Text (Text) +import qualified Data.Text.Encoding as Text +import qualified Data.Text.Encoding.Error as Text + + +decodeUtf8Lenient :: ByteString -> Text +decodeUtf8Lenient = + Text.decodeUtf8With Text.lenientDecode diff --git a/src/Data/Text/Extra.hs b/src/Data/Text/Extra.hs new file mode 100644 index 0000000..07dd45c --- /dev/null +++ b/src/Data/Text/Extra.hs @@ -0,0 +1,8 @@ +module Data.Text.Extra where + +import Data.Text (Text) +import qualified Data.Text as Text + + +show :: Show a => a -> Text +show = Text.pack . Prelude.show |