File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -96,5 +96,6 @@ library
96
96
HaskellWorks.IO.Network.Socket
97
97
HaskellWorks.IO.Process
98
98
HaskellWorks.Prelude
99
+ HaskellWorks.ToText
99
100
HaskellWorks.Unsafe
100
101
hs-source-dirs : src
Original file line number Diff line number Diff line change
1
+ module HaskellWorks.ToText
2
+ ( ToText (.. )
3
+ ) where
4
+
5
+ import Data.Function
6
+ import Data.String (String )
7
+ import Data.Text (Text )
8
+ import qualified Data.Text as T
9
+ import qualified Data.Text.Lazy as LT
10
+ import qualified Data.Text.Lazy.Builder as TB
11
+
12
+ class ToText a where
13
+ toText :: a -> Text
14
+
15
+ instance ToText String where
16
+ toText = T. pack
17
+
18
+ instance ToText Text where
19
+ toText = id
20
+
21
+ instance ToText LT. Text where
22
+ toText = LT. toStrict
23
+
24
+ instance ToText TB. Builder where
25
+ toText = LT. toStrict . TB. toLazyText
You can’t perform that action at this time.
0 commit comments