Repository navigation
Rename Type to Decoder, InputType to Encoder - #1485
Conversation
| , UnionEncoder(..) | ||
| , encodeConstructorWith | ||
| , encodeConstructor | ||
| , encodeUnion |
There was a problem hiding this comment.
I think it was good to get rid of the "input*" names here, but I'm not convinced about these "encode*" names.
| , recordEncoder | ||
| , UnionEncoder(..) | ||
| , encodeConstructorWith | ||
| , encodeConstructor |
There was a problem hiding this comment.
I'm still not sure about the encode{Field,Constructor}With names. It's really a bit unfair that the FromDhall side got to use field and constructor!
There was a problem hiding this comment.
Would constructorEncoder[With] and fieldEncoder[With] be any better? At least it would keep the encode name free for better uses…
There was a problem hiding this comment.
We could also consider creating separate modules for encoding and decoding. Then we could have field[With] and constructor[With], and union and record in both modules.
There was a problem hiding this comment.
To decrease the unfairness, how about names like to{Record, Field, Singleton}With for the ToDhall side and from{Record, Field, Singleton}With for FromDhall?
About module for encoding and decoding, it's an out-there suggestion but, the way tomland encodes and decodes toml is with a bi-directional codec, something like
data Codec a =
Codec { fromDhall :: Expr Src Void -> Extractor Src Void a
toDhall :: a -> Expr Src Void
dhallType :: Expr Src Void
}It's pretty nice to keep the symmetry, and this way you always have to implement both encoders and decoders at the same time.
There was a problem hiding this comment.
{to,from}Record don't seem too helpful to me since we have records on both sides. Similarly for {to,from}Field.
The Codec idea is intriguing, but this PR is not the right place for discussing it IMHO!
There was a problem hiding this comment.
Let's maybe leave the lack of symmetry between record and union decoders and encoders for future work.
… as a part of #1393.