json-to-haskell-0.1.1.2
Safe HaskellNone
LanguageHaskell2010

JsonToHaskell.Internal.Parser

Synopsis

Documentation

data RecordType Source #

Constructors

Ref 
Structure 

type RecordFields r = HashMap Text (Struct r) Source #

The representation of a record's field types

data Struct (r :: RecordType) where Source #

The recursive representation of the "type" of a JSON value

Instances

Instances details
Eq (Struct r) Source # 
Instance details

Defined in JsonToHaskell.Internal.Parser

Methods

(==) :: Struct r -> Struct r -> Bool #

(/=) :: Struct r -> Struct r -> Bool #

Ord (Struct r) Source # 
Instance details

Defined in JsonToHaskell.Internal.Parser

Methods

compare :: Struct r -> Struct r -> Ordering #

(<) :: Struct r -> Struct r -> Bool #

(<=) :: Struct r -> Struct r -> Bool #

(>) :: Struct r -> Struct r -> Bool #

(>=) :: Struct r -> Struct r -> Bool #

max :: Struct r -> Struct r -> Struct r #

min :: Struct r -> Struct r -> Struct r #

Show (Struct r) Source # 
Instance details

Defined in JsonToHaskell.Internal.Parser

Methods

showsPrec :: Int -> Struct r -> ShowS #

show :: Struct r -> String #

showList :: [Struct r] -> ShowS #

analyze :: Value -> Map (RecordFields 'Structure) (NESet Text) Source #

Convert a Value into a Typed representation of its structure, tracking reasonable names for each subrecord along the way

canonicalizeRecordNames :: Map (RecordFields 'Structure) (NESet Text) -> Bimap Text (RecordFields 'Structure) Source #

Given a mapping of structures to name candidates, pick names for each record, avoiding duplicates

chooseBestName :: NESet Text -> Set Text -> Text Source #

Choose a "fresh" name given a list of candidates and a map of names which have already been chosen.

makeUnique :: Text -> Set Text -> Text Source #

Given a name candidate, make it unique amongs the set of taken names by appending the lowest number which isn't yet taken. E.g. if "name" is taken, try "name2", "name3" ad infinitum

addReferences :: Bimap Text (RecordFields 'Structure) -> Struct 'Structure -> Struct 'Ref Source #

Switch literal struct definitions with their "names"

toRecordName :: Text -> Text Source #

Clean a name into a valid Haskell record name