Coder Social home page Coder Social logo

Comments (5)

MatthijsBlom avatar MatthijsBlom commented on July 20, 2024

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 following Maybe. 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.

pwadsworth avatar pwadsworth commented on July 20, 2024

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.

@MatthijsBlom

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.

ErikSchierboom avatar ErikSchierboom commented on July 20, 2024

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.

MatthijsBlom avatar MatthijsBlom commented on July 20, 2024

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 the name pattern = ... as syntactic sugar for case.

  • Maybe, Either, …, introducing the following aspects of these types:

    But not pattern matching on them.

  • Algebraic Data Types introducing data declarations, maybe type declarations, and probably not newtype 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.

kytrinyx avatar kytrinyx commented on July 20, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.