Re:The advantages of static typing, simply stated
by yamadapc on Friday September 16, 2016 @10:54AM
(#12514388)
In Haskell you can generate a parser to a typed structure using library combinators and code generation:
data DataMessage = DataMessage { company :: Text
}
deriving (Show)
$(deriveJSON defaultOptions ''DataMessage)
data DataList = DataList { _data :: [DataMessage]
}
deriving (Show)
$(deriveJSON defaultOptions { fieldLabelModifier = drop 1 } ''DataList)
Which will fail properly when the data is malformed and in the real-world is even shorter, because you can set your data-type to protocol naming conventions and share them throughout.
Then there isn't much bloat. You wrote your types and generated your way to parse them.
Then there isn't much bloat. You wrote your types and generated your way to parse them.
You could test with:
https://gist.github.com/b30f6f09a737dcc980e052b0f3d2a39e