Add showConstructor to convert union value constructor to Text#1257
Add showConstructor to convert union value constructor to Text#1257Gabriella439 merged 8 commits intodhall-lang:masterfrom
showConstructor to convert union value constructor to Text#1257Conversation
Gabriella439
left a comment
There was a problem hiding this comment.
Looks great! I think all this needs is tests
MonoidMusician
left a comment
There was a problem hiding this comment.
Looks good to me, just this one detail.
* Fix grammar spacing * Make typing rule less strict to work with abstract arguments Co-authored-by: Gabriella Gonzalez <Gabriel439@gmail.com> Co-authored-by: Verity Scheel <monoidmusician@gmail.com>
sjakobi
left a comment
There was a problem hiding this comment.
Looks like a great feature! :)
I've been trying to think of some "interesting" type-inference failure tests. So far I've only come up with:
showConstructor < A : Bool >.AshowConstructor None
Please also add type-inference and normalization success tests for something like showConstructor (< A : Bool>.A False).
I also wonder whether showConstructor ought to work for Bools. I don't see why not. Our main reason for not allowing merge for Bools doesn't seem to apply in this case.
|
Thanks for the test suggestions! I've added those.
|
sjakobi
left a comment
There was a problem hiding this comment.
showConstructor for Bools sounds reasonable, though I wonder what the use case would be where you wouldn't just use Bool/show.
It might be just slightly more convenient than importing Bool/show from the Prelude. Not a very important addition though.
tests/type-inference/success/unit/ShowConstructorNonEmptyB.dhall
Outdated
Show resolved
Hide resolved
tests/normalization/success/unit/ShowConstructorNonEmptyB.dhall
Outdated
Show resolved
Hide resolved
Co-authored-by: Simon Jakobi <simon.jakobi@gmail.com>
… as standardized in dhall-lang/dhall-lang#1257 Co-authored-by: David Richey <darichey1@gmail.com>
Fixes #1204
Adds a
showConstructorkeyword that can be used to convert a union value toTextby its constructor name. For example:It also works on
Optionalvalues:I have a draft implementation for dhall-haskell: darichey/dhall-haskell@64ef9df