Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,944
    • Issues 4,944
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 453
    • Merge requests 453
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Wiki
  • pattern synonyms

pattern synonyms · Changes

Page history
Edit PatternSynonyms authored Oct 02, 2015 by Matthew Pickering's avatar Matthew Pickering
Hide whitespace changes
Inline Side-by-side
pattern-synonyms.md
View page @ e1ed7a40
......@@ -467,6 +467,26 @@ Normal pattern synonyms provide a convenient way to abstract away from ADTs by e
Currently there is no way to similar way to project an existing datatype to a record.
Adding this feature provides completeness as pattern synonyms would become equally expressive as ordinary data type declarations.
### Specification
The syntax for defining pattern synonyms is extened as follows
```wiki
patsyndecl_w_records ::= patsyndecl
| 'pattern' con '{' var1 ',' ... ',' varn '}' <- pat
```
A bidirectional record pattern synonym `P` with type `T` and arguments `f1, f2, ..., fn` which have types `t1, t2, ...., tn` should behave just as if `P` had been defined as a record constructor for `T` with the corresponding fields.
For example,
```wiki
data T ... = ... | P { f1 :: t1, f2 :: t2, ..., fn :: tn }
```
### Design
......
Clone repository Edit sidebar
  • 9.6
  • Adventures in GHC compile times
  • All things layout
  • AndreasK
  • AndreasPK
  • Back End and Run Time System
  • Backpack refactoring
  • Backpack units
  • Brief Guide for Compiling GHC to iOS
  • Building GHC on Windows with Stack protector support (SSP) (using Make)
  • CAFs
  • CafInfo rework
  • Compiling Case Expressions in ghc
  • Compiling Data.Aeson Error
  • Contributing a Patch
View All Pages