@@ -1,7 +1,10 @@
11{-# LANGUAGE FlexibleInstances #-}
22{-# LANGUAGE OverloadedStrings #-}
33{-# LANGUAGE TypeSynonymInstances #-}
4−module Servant.Common.Text where
4+module Servant.Common.Text
5+ ( FromText(..)
6+ , ToText(..)
7+ ) where
58
69import Data.String.Conversions
710import Data.Int
@@ -9,11 +12,11 @@ import Data.Text
912import Data.Text.Read
1013import Data.Word
1114
12−-- | For getting values from url captures, get parameters
15+-- | For getting values from url captures and query string parameters
1316class FromText a where
1417 fromText :: Text -> Maybe a
1518
16−-- | For putting values in paths, get parameters
19+-- | For putting values in paths and query string parameters
1720class ToText a where
1821 toText :: a -> Text
1922
@@ -29,11 +32,18 @@ instance FromText String where
2932instance ToText String where
3033 toText = cs
3134
35+-- |
36+-- > fromText "true" = Just True
37+-- > fromText "false" = Just False
38+-- > fromText _ = Nothing
3239instance FromText Bool where
3340 fromText "true" = Just True
3441 fromText "false" = Just False
3542 fromText _ = Nothing
3643
44+-- |
45+-- > toText True = "true"
46+-- > toText False = "false"
3747instance ToText Bool where
3848 toText True = "true"
3949 toText False = "false"