on master help sign in
Make Value an instance of IsString

Requested by Bas van Dijk.

commit2694fcc9df6bccaafaf758897fe43175b0e01b90 authorBryan O'Sullivan <bos@serpentine.com> dateTue 22 Feb 2011, 15:00 (16 years ago) parent6b40e5d
1 file changed+5
Data/Aeson/Types.hs+5
Data/Aeson/Types.hs+5
@@ -45,6 +45,7 @@ import qualified Data.IntSet as IntSet
4545import Data.Map (Map)
4646import Data.Monoid (Dual(..), First(..), Last(..))
4747import Data.Ratio (Ratio)
48+import Data.String (IsString(..))
4849import Data.Text (Text, pack, unpack)
4950import Data.Text.Encoding (decodeUtf8, encodeUtf8)
5051import Data.Time.Clock (UTCTime)
@@ -150,6 +151,10 @@ instance NFData Value where
150151 rnf (Bool b) = rnf b
151152 rnf Null = ()
152153
154+instance IsString Value where
155+ fromString = String . pack
156+ {-# INLINE fromString #-}
157+
153158-- | The empty array.
154159emptyArray :: Value
155160emptyArray = Array V.empty