Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,384
    • Issues 4,384
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 368
    • Merge Requests 368
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #14446

Closed
Open
Opened Nov 09, 2017 by dredozubov@trac-dredozubov

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
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#14446