Extending TypeApplications to support infix functions
For a motivational example I propose a piece of code using a library https://github.com/typeable/schematic, which defines a fancy record-like object and requires some type annotations:
jsonExample = withRepr @SchemaExample
$ field @"foo" [12]
:& field @"bar" (Just "bar")
:& RNil
By using the same function as an infix operator, it may be possible to rewrite it to something along the lines of
(.=) = field
jsonExample = withRepr @SchemaExample
$ @"foo" .= [12]
:& @"bar" .= (Just "bar")
:& RNil
To do that, we'll need to associate a type application with the function to the right of it. I imagine it'll introduce ambiguity to the parser, but it can be dealt with by allowing a different syntactical construct for a right type application. Haven't checked with a grammar, but it can be something like this:
jsonExample = withRepr @SchemaExample
$ "foo"@ .= [12]
:& "bar"@ .= (Just "bar")
:& RNil
Trac metadata
Trac field | Value |
---|---|
Version | 8.2.1 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |