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

Feature: implied parentheses #22

Open
deepfire opened this issue May 15, 2017 · 3 comments
Open

Feature: implied parentheses #22

deepfire opened this issue May 15, 2017 · 3 comments
Labels

Comments

@deepfire
Copy link

deepfire commented May 15, 2017

Since this is 21'th century, we probably can have many (most?) parentheses implied, in a way that is not dissimilar to how Haskell does implicit { ... } blocks (which people mostly don't use for a couple of reasons that are not directly relevant here, since the tradeoffs are different, because no macros).

To be precise: the idea is to allow BOTH options (as in Haskell), since:

  1. We still need to allow the fully-parenthesised form to be emitted in macros, where you really really want to be specific about the parentheses.
  2. The long, multi-line expression cases still stand

To consider the difference of presentation -- using the example from the README:

#lang hackett

data Maybe a
  nothing
  just a

def x : Int
  let y 3
      z 7
    y + z

class Show a
  show : Int -> a -> String

instance forall [a] (Show a) => Show (Maybe a)
  def+ show
    nothing -> "nothing"
    just x  -> "just " <> show x

..versus:

#lang hackett

(data (Maybe a)
  nothing
  (just a))

(def x : Int
  (let ([y 3]
        [z 7])
    {y + z}))

(class (Show a)
  [show : {Int -> a -> String}])

(instance (forall [a] (Show a) => (Show (Maybe a)))
  (def+ show
    [nothing  -> "nothing"]
    [(just x) -> {"just " <> (show x)}]))
@deepfire
Copy link
Author

deepfire commented May 15, 2017

As a personal perspective -- after a long time of doing Lisp, and then coming to Haskell, I have come to value its visual terseness.

It seems to increase the raw perception bandwidth.

@lexi-lambda
Copy link
Owner

I agree that this would be nice if it could be done perfectly, but it’s trickier in practice than it might seem. I do think it would be cool to have an opt-in ML-like reader that you could get with #lang hackett/ml or something like that. For prior art, check out the following SRFIs:

The fact that there are three different standards for this hints that this is a harder problem than it might seem. I would encourage you to study the different tradeoffs each of them makes to better understand what the challenges are.

@johanatan
Copy link

johanatan commented Nov 28, 2017

While I agree that Haskell-like syntax may be easier on the eyes for some, I doubt that the individual perception bandwidth is increased all that much. And the parentheses are not only useful for macros but for editors' structural editing capabilities (which can be thought of as development-time [i.e., pre-compile time] key-bound macros).

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

No branches or pull requests

3 participants