Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data RecordType
- type RecordFields r = HashMap Text (Struct r)
- data Struct (r :: RecordType) where
- type AnalyzeM a = ReaderT Text (State (Map (RecordFields 'Structure) (NESet Text))) a
- analyze :: Value -> Map (RecordFields 'Structure) (NESet Text)
- canonicalizeRecordNames :: Map (RecordFields 'Structure) (NESet Text) -> Bimap Text (RecordFields 'Structure)
- chooseBestName :: NESet Text -> Set Text -> Text
- makeUnique :: Text -> Set Text -> Text
- addReferences :: Bimap Text (RecordFields 'Structure) -> Struct 'Structure -> Struct 'Ref
- toRecordName :: Text -> Text
Documentation
data RecordType Source #
data Struct (r :: RecordType) where Source #
The recursive representation of the "type" of a JSON value
SArray :: Struct r -> Struct r | |
SRecord :: RecordFields 'Structure -> Struct 'Structure | |
SRecordRef :: Text -> Struct 'Ref | |
SMap :: Struct r -> Struct r | |
SBool :: Struct r | |
SNumber :: NumberType -> Struct r | |
SNull :: Struct r | |
SString :: Struct r | |
SValue :: Struct r |
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