Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List notation #45

Closed
2 tasks done
rolyp opened this issue Jan 22, 2019 · 3 comments
Closed
2 tasks done

List notation #45

rolyp opened this issue Jan 22, 2019 · 3 comments

Comments

@rolyp
Copy link
Collaborator

rolyp commented Jan 22, 2019

  • do Broken syntax for nullary constructors #49 first?
  • infix cons (::)
  • Haskell-style list notation [a, b, c], with [x, ...xs] as notation for cons
  • revisit continuation-passing idiom for trie-parsing? (requires trie zipper)
  • extend notation to pattern-matching
@rolyp rolyp added the language label Jan 22, 2019
@rolyp
Copy link
Collaborator Author

rolyp commented Apr 9, 2019

Most brain-dead list notation that doesn't require two distinct notations (e.g. :: and [x, y, ...] in Haskell).

@rolyp rolyp closed this as completed Apr 9, 2019
@jamescheney
Copy link
Collaborator

In Prolog (and I think Erlang also) "cons" can be written [x|xs] and you can write [x,y,z|xs] for cons(x,cons(y,cons(z,xs))).

@rolyp
Copy link
Collaborator Author

rolyp commented Apr 9, 2019

Ok, that's useful to know - thanks! That's what I've just implemented, but with "..." instead of "|" (reminiscent of ES6 spread notation).

   fun mergesort xs →
      match xs as {
         [] → xs;
         [x] → xs;
         [x, y, ...xs'] →
            match split xs as 
               (ys, zs) → merge (mergesort ys) (mergesort zs)
      }

Implementing that for list patterns turned out to be quite tricky because the syntax of tries requires the pattern parser to be written in a continuation-passing style..gah.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

2 participants