File: Options.hs

package info (click to toggle)
haskell-aeson 2.1.2.1-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,988 kB
  • sloc: haskell: 11,933; ansic: 123; makefile: 11
file content (68 lines) | stat: -rw-r--r-- 2,052 bytes parent folder | download | duplicates (3)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{-# LANGUAGE NoImplicitPrelude #-}

module Options (module Options) where

import Prelude.Compat

import Data.Aeson.Types
import Data.Char

optsDefault :: Options
optsDefault = defaultOptions
              { fieldLabelModifier     = map toLower
              , constructorTagModifier = map toLower
              }

opts2ElemArray :: Options
opts2ElemArray = optsDefault
                 { allNullaryToStringTag = False
                 , sumEncoding     = TwoElemArray
                 }

optsUnwrapUnaryRecords :: Options
optsUnwrapUnaryRecords = optsDefault
                         { unwrapUnaryRecords = True
                         }

optsTaggedObject :: Options
optsTaggedObject = optsDefault
                   { allNullaryToStringTag = False }

optsObjectWithSingleField :: Options
optsObjectWithSingleField = optsDefault
                            { allNullaryToStringTag = False
                            , sumEncoding           = ObjectWithSingleField
                            }

optsOmitNothingFields :: Options
optsOmitNothingFields = optsDefault
                        { omitNothingFields = True
                        }

optsUntaggedValue :: Options
optsUntaggedValue = optsDefault
    { sumEncoding = UntaggedValue
    }

optsTagSingleConstructors :: Options
optsTagSingleConstructors = optsDefault
                            { tagSingleConstructors = True
                            , allNullaryToStringTag = False
                            }

optsOptionField :: Options
optsOptionField = optsDefault
                  { fieldLabelModifier = const "field"
                  , omitNothingFields = True
                  }

optsRejectUnknownFields :: Options
optsRejectUnknownFields = optsDefault
                          { rejectUnknownFields = True
                          }

optsRejectUnknownFieldsTagged :: Options
optsRejectUnknownFieldsTagged = optsDefault
                                { rejectUnknownFields = True
                                , tagSingleConstructors = True
                                }