File: Aeson.hs

package info (click to toggle)
haskell-wreq 0.5.4.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 380 kB
  • sloc: haskell: 2,992; makefile: 25
file content (42 lines) | stat: -rw-r--r-- 884 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
{-# LANGUAGE FlexibleInstances, TypeFamilies, TypeSynonymInstances #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}

module AWS.Aeson
    (
      object
    , string
    , true
    , (.=)
    ) where

import Data.Aeson hiding ((.=))
import Data.Text (Text, pack)
import GHC.Exts
import qualified Data.Vector as Vector

instance Num Value where
    fromInteger = Number . fromInteger

instance Fractional Value where
    fromRational = Number . fromRational

instance IsList Value where
    type Item Value  = Value
    fromList         = Array . Vector.fromList
    toList (Array a) = Vector.toList a
    toList _         = error "AWS.Aeson.toList"

class Stringy a where
    string :: a -> Value

instance Stringy Text where
    string = String

instance Stringy String where
    string = String . pack

true :: Value
true = Bool True

(.=) :: Text -> Value -> (Text, Value)
a .= b = (a,b)