Suggestion: can we use PureScript's whitespace sensitivity to reduce verbosity?

Continuation of this comment.

@Adrielus you make a good point.

@ajnsit you also make a good point. I know that PureScript’s syntax is almost the same as Haskell’s, but is having a similar syntax a goal of PureScript?


In my personal opinion - I am not too bothered by the extra commas. Particularly when formatted like this -

foo =
  [ someValue
  , anotherValue
  , finalValue

It’s a very minor inconvenience to prefix the first value with a [ and subsequent values with , but it’s not enough to change syntax.

Haskell libraries often abuse the monadic do-notation to append values together.

FWIW I hacked together an example in Purescript - Open the browser console to see the output.

It allows code like this -

foo = unwrap do
  e someValue
  e anotherValue
  e finalValue

It’s still terrible (because >> is not a part of the Monad class, and ado has a different syntax), but atleast it gets rid of the commas!

EDIT: To clarify my stance, this is a bad idea, please don’t use this in production.

1 Like

I’m going to pretend I didn’t see that.


Jokes aside, I agree with you.

To be clear, in F#, when elements are on separate lines, seperators are optional, so the following would all be valid

let bs = [
let cs = [ 1; 2; 3 ]
let ds = 
  [ 1
  ; 2
  ; 3
let es = 
  [ 1; 2
    3; 4 ]

So I don’t think it pulls away from Haskell syntax much to use the same strategy, since the Haskell syntax is still valid, it just adds more options. However, IMO I agree it’s not worth the effort of the core maintainers to implement something like that.

As an amusing anecdote, my team uses F# on the backend and PureScript on the frontend, and several of my fellow developers have started defining records & lists using the syntax like

let ds = 
  [ 1
  ; 2
  ; 3

for multiline definitions, just because they picked it up from PureScript and liked it so much :stuck_out_tongue_winking_eye:


Ah, you can do optional separators with this as well, just use *> as the separator :slight_smile: For example the following would be an array [2,3,4,5,6] -

 unwrap do
  e 2 *> e 3
  e 4 *> e 5
  e 6