[GHC] #14446: Extending TypeApplications to support infix functions

GHC ghc-devs at haskell.org
Thu Nov 9 22:36:04 UTC 2017


#14446: Extending TypeApplications to support infix functions
-------------------------------------+-------------------------------------
           Reporter:  dredozubov     |             Owner:  (none)
               Type:  feature        |            Status:  new
  request                            |
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  8.2.1
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 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
 }}}

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14446>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list