Comments (5)
We don't have to teach everything about case expressions (and indeed, we probably shouldn't).
It might surprise you how easy it is to explain (essentially) everything about case
expressions in Haskell. They're quite simple.
For reference, this is the most recent concensus on Slack (original):
Alright, so pattern matching is to be split up into two concepts, with
- Pattern Matching 1 introducing matching on integer literals and (hereby proposed by me) guards, and
- Pattern Matching 2 introducing matching on ADTs (including reminder on guards)
(Names temporary: I failed to come up with good name pairs.)
Does this sound right?
If we do this we should consider introducing custom data types/algebraic data types between the two, and
Maybe
in particular as it is not an enum-like type but has an optional field.Also
Either
, in parallel with or directly followingMaybe
. Having them both as prerequisites for PM2 is not necessary but would be nice.
@pwadsworth has already worked on this PM1: the corresponding exercise is Guessing Game.
I'd like to call dibs on the explainers of PM2, as I have already been composing in my head for days. These explainers should make it obvious even to the non-Haskellers what appropriate exercises look like.
from haskell.
For names, how about:
- Pattern Matching: Literals and Variables.
- Pattern Matching: Types.
The Type part would benefit of a qualifier. Simple? Basic? So is not confusing if we later want to go into PM: Lists, PM: Tuples, etc.
Although after these two concepts it would make sense to include the specifics of pattern matching with each new type introduced.
I'd like to call dibs on the explainers of PM2
What do you mean by 'explainers'? The concept? instructions? both? Do you want me to tackle the exercise? If so, Valentine's Day?
from haskell.
I'm not entirely sure I follow the discussion.
Alright, so pattern matching is to be split up into two concepts, with
- Pattern Matching 1 introducing matching on integer literals and (hereby proposed by me) guards, and
- Pattern Matching 2 introducing matching on ADTs (including reminder on guards)
The guessing-game
exercise has been built and covers part 1, and the valentines-day
exercise that is still to be built will cover part 2. That said, this issue is about case-expressions
, for which I thought we intended to create another, third exercise just for case-expressions
. Did I miss anything?
from haskell.
Way I understand it, the concept graph will look something like this.
|
Simple Pattern Matching
/ | \
Maybe Either ... (tuples, lists?)
\ | /
Algebraic Data Types
("custom types")
|
Pattern Matching Proper
|
with
-
Simple Pattern Matching introducing matching on literals and guards. Personally I prefer introducing
case
expressions here as well, and explicitly presenting thename pattern = ...
as syntactic sugar forcase
. -
Maybe, Either, …, introducing the following aspects of these types:
- Acting on them – see utilities in
Data.Maybe
,Data.Either
,Data.Tuple
- Constructing them using their constructors
But not pattern matching on them.
- Acting on them – see utilities in
-
Algebraic Data Types introducing
data
declarations, maybetype
declarations, and probably notnewtype
declarations. But still not pattern matching on them. -
Pattern Matching Proper introducing pattern matching on algebraic data types. Exhaustivity, recursive ('deep') matching, pattern variables, …, all the usual stuff.
What do you mean by 'explainers'? The concept? instructions? both? Do you want me to tackle the exercise? If so, Valentine's Day?
@pwadsworth The explainers are the about.md
and the introduction.md
. I have no wish one way or the other as to who does the exercise.
Did I miss anything?
@ErikSchierboom in the above-laid-out design, case
expressions are tackled at the same time as pattern matching. I feel they should: 'all' pattern matching occurs in case
expressions or syntactic sugar for the latter. Valentine's Day is fine.
from haskell.
@MatthijsBlom I really like that concept graph, and I'd like to open a new issue with the graph as a starting point.
We have a solid exercise for the first node in the graph with the Guessing Game PR that @pwadsworth has opened (#1094), and I'd like to get that merged. We can always come back and tweak it once we have more exercises and start seeing how the bigger picture is shaping up.
I'll leave this issue on hold until we've figured out the exercises for the nodes in the graph. As you say, case
expressions will likely be covered as part of that, and if so we can just close this issue at that point.
from haskell.
Related Issues (20)
- Add a disclaimer about version constraints and Stackage
- [Learning Mode] Discussion: building up to Pattern Matching HOT 26
- Which memoization library to use? HOT 3
- [Learning Mode] make learning track visible HOT 1
- Build error (connection failure, `Cabal file info not found...`) HOT 2
- Continuation of development of Learning Mode? HOT 3
- Intention behind not updating a Queen Attack test HOT 2
- docs: contributing instructions regarding versioning are out of date HOT 2
- Binary Search Tree: add test cases for `bstRight`, `bstLeft` HOT 5
- README: Replace outdated information about hints.md with correct information
- Are hints.md files rendering properly? HOT 1
- Add test to check for eligible boards where queen is on rightmost column in queen attack HOT 3
- Exercise Zipper: instruction is out of date HOT 1
- Building a training set of tags for haskell HOT 21
- exercism cli not installing most recent version of project template HOT 2
- Roman numerals doesn't test for Nothing HOT 1
- Phone Number exercise tests are out of sync with problem-specifications HOT 1
- CI is broken
- Satellite requires unnatural edge case checking HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from haskell.