Skip to content

Feature: implied parentheses #22

Open
@deepfire

Description

@deepfire

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)}]))

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions