summaryrefslogtreecommitdiffstats
path: root/src/Blessings
diff options
context:
space:
mode:
Diffstat (limited to 'src/Blessings')
-rw-r--r--src/Blessings/Internal.hs11
-rw-r--r--src/Blessings/String.hs18
-rw-r--r--src/Blessings/Text.hs18
3 files changed, 47 insertions, 0 deletions
diff --git a/src/Blessings/Internal.hs b/src/Blessings/Internal.hs
new file mode 100644
index 0000000..c96a587
--- /dev/null
+++ b/src/Blessings/Internal.hs
@@ -0,0 +1,11 @@
+module Blessings.Internal where
+
+import Data.String (IsString)
+
+
+class (IsString a, Monoid a) => Blessable a where
+ length :: a -> Int
+ drop :: Int -> a -> a
+ take :: Int -> a -> a
+ intercalate :: a -> [a] -> a
+ fromInt :: Int -> a
diff --git a/src/Blessings/String.hs b/src/Blessings/String.hs
new file mode 100644
index 0000000..c2c7273
--- /dev/null
+++ b/src/Blessings/String.hs
@@ -0,0 +1,18 @@
+{-# LANGUAGE FlexibleInstances #-}
+{-# OPTIONS_GHC -fno-warn-orphans #-}
+
+module Blessings.String
+ ( module Blessings
+ ) where
+
+import Blessings
+import Blessings.Internal
+import qualified Data.List as L
+
+
+instance Blessable String where
+ length = L.length
+ drop = L.drop
+ take = L.take
+ intercalate = L.intercalate
+ fromInt = show
diff --git a/src/Blessings/Text.hs b/src/Blessings/Text.hs
new file mode 100644
index 0000000..64d261b
--- /dev/null
+++ b/src/Blessings/Text.hs
@@ -0,0 +1,18 @@
+{-# OPTIONS_GHC -fno-warn-orphans #-}
+
+module Blessings.Text
+ ( module Blessings
+ ) where
+
+import Blessings
+import Blessings.Internal
+import Data.Text (Text)
+import qualified Data.Text as T
+
+
+instance Blessable Text where
+ length = T.length
+ drop = T.drop
+ take = T.take
+ intercalate = T.intercalate
+ fromInt = T.pack . show