on 13664a2 help sign in
25 lines 465 B history raw
1{-# LANGUAGE OverloadedStrings #-}
2module Servant.Text where
4import Data.Text
6class FromText a where
7 fromText :: Text -> Maybe a
9class ToText a where
10 toText :: a -> Text
12instance FromText Text where
13 fromText = Just
15instance ToText Text where
16 toText = id
18instance FromText Bool where
19 fromText "true" = Just True
20 fromText "false" = Just False
21 fromText _ = Nothing
23instance ToText Bool where
24 toText True = "true"
25 toText False = "false"