google / codeworld

Educational computer programming environment using Haskell
http://code.world
Apache License 2.0
1.24k stars 196 forks source link

Way too much indentation for nested functions #1282

Closed cdsmith closed 4 years ago

cdsmith commented 4 years ago

Shared Program: https://code.world/#P7_OjaRA2_IOx04FvxPQ3og

Description

I'm not sure what to do about this, but something should be done. The problem is that the indenter is trying to set things up to align the elements of these parentheses (See #1280). But that means it commits to ridiculous amounts of indenting, cramming code against the right margin, and making line breaks completely ineffective to fix anything.

The right "fix" for a student here is to add a newline after the open parentheses if I'm going to wrap inside the functions. Unfortunately, that doesn't make things great either. https://code.world/#Pahd9lkfkp5gCVhcveSAU_Q Better than the original, for sure, but those eight-character indents are killing me! (8 characters because there's one indent for wrapping the outer expression, and another for the indent between parentheses and their contents).

I'm seriously considering setting indents to 2 spaces, given how they tend to double up anyway.

cdsmith commented 4 years ago

I am now persuaded that this is actually what we want. This is just a bad way to write code. I've tried this on a bunch of saved code and student code now, and in all cases the indentation makes it clearer what's going on. Even when it does things that look bad, it's actually clarifying surprising structure in the student's code.