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,382
    • Issues 4,382
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 369
    • Merge Requests 369
  • 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
  • Wiki
  • lambdas vs pattern matching

lambdas vs pattern matching · Changes

Page history
added notes regarding arrow notation (proc expressions) authored Jul 05, 2012 by Wolfgang Jeltsch's avatar Wolfgang Jeltsch
Hide whitespace changes
Inline Side-by-side
Showing with 16 additions and 0 deletions
+16 -0
  • lambdas-vs-pattern-matching.md lambdas-vs-pattern-matching.md +16 -0
  • No files found.
lambdas-vs-pattern-matching.md
View page @ 419864c4
......@@ -24,6 +24,18 @@ or even
However, when this situation nests (e.g. monadic bind) and variables have the same type, naming becomes painful and often degrades to not-so-meaningful ```meaningfulName1```, ```meaningfulName2```, ...
A similar problem exists with `proc` expressions from arrow notation, which can be regarded as generalized lambda expressions. We sometimes have expressions of the following structure:
```wiki
proc meaningfulName -> case meaningfulName of
Pat1 -> ...
Pat2 -> ...
```
Here, the dots stand for arrow expressions, not ordinary expressions.
## The proposals
### LambdaCase: ```case of```
......@@ -53,6 +65,7 @@ desugars to
- Looks weird (no hint of being a lambda abstraction)
- Single-argument solution (see the note)
- Cannot be generalized to cover also `proc` expressions
### LambdaCase: ```\case```
......@@ -80,6 +93,7 @@ desugars to
- Pros
- No conflicts with the current syntax (the sequence ```\ case``` is illegal)
- An analog syntax for `proc` expressions can be gained by replacing `\` with `proc`
- Cons
- Single-argument solution (see the note). One way to extend it to support multiple arguments is
......@@ -109,6 +123,7 @@ Extend the current syntax with alternative clauses:
- Pros
- Multi-argument solution (see the note)
- An analog syntax for `proc` expressions can be gained by replacing `\` with `proc`
- Cons
- Breaks current idioms. For example,
......@@ -144,6 +159,7 @@ Addresses the layout problem of MultiClauseLambdas. Requires multi-clause abstra
- No conflicts with the current syntax
- Multi-argument solution (see the note)
- An analog syntax for `proc` expressions can be gained by replacing `\` with `proc`
- Cons
- Deciding on the keyword may take years
......
Clone repository Edit sidebar
  • All things layout
  • AndreasK
  • AndreasPK
  • Building GHC on Windows with Stack protector support (SSP) (using Make)
  • CAFs
  • CafInfo rework
  • Compiling Data.Aeson Error
  • Contributing a Patch
  • Core interface section
  • Dead Code
  • Developing Hadrian
  • Documentation Style Guide
  • Doubleton Arrays
  • Errors as (structured) values
  • Extensible Interface Files
View All Pages