Skip to content

Pythonic syntax #1139

@rolyp

Description

@rolyp

Finalisation tasks for merge:

See also:

Done/dropped:

  • Finalisation tasks for RSECon presentation:
    • Comments
    • Doc comments
    • Paragraph
  • Migrate article website to new syntax
  • Integrate new specific syntax tests with main test suite dropped after discussion with @jacobpake
  • article/non-renewables broken: only one point in scatterplot, dependencies borked
  • Improvements to error reporting ✅ enough on this for now
  • Highlightable instances in new prettyprinter
  • Migrate remaining websites
    • Merge misc examples into article
  • Migrate all test cases to new syntax
    • incomplete patterns error in dtw cases
  • Restore comments in prelude.fld
  • Restore indentation strictness? see Remaining indentation fixes #1440
  • Remove migration tests and infrastructure
    • Delete spurious files in fluid (e.g. test.fld, pi.fld)
  • Incorporate parenthesis improvements from old prettyprinter
  • @rolyp to review and finalise
    • Restore comments to graphics.fld
    • Parse/Constants
      • Where are these used?
      • Some redundancy with Parse/Parser.purs/keywords
    • Pretty.Constants -- thought we decided not to use the constand definitions after all?
    • Pretty.Helpers -> Util
    • prettyParseError probably doesn't need its own module
    • Pretty.Config may not need its own module?
    • Bump patch version again
    • Delete our version of Array.transpose

One idea to make Fluid an easier target for generative AI would be to make the syntax resemble a pure dialect of Python.

I think there is only so far you could push this, partly because of the purity, and also because the Python version of pattern matching is pretty clunky:

def describe_shape(shape):
    match shape:
        case Circle(radius):
            return f"A circle with radius {radius}"
        case Rectangle(width, height):
            return f"A rectangle with width {width} and height {height}"
        case _:
            return "Unknown shape"

But one could imagine allowing something like the following:

def describe_shape(Circle(radius)):
    return f"A circle with radius {radius}"

def describe_shape(Rectangle(width, height)):
    return f"A rectangle with width {width} and height {height}"

def describe_shape(_):
    return "Unknown shape"

A secondary (and potentially significant) advantage would be that Python folk would find Fluid an easy language to switch to. I would be tempted to do this sooner rather than later, but unfortunately this would be a non-trivial amount of work, not least because Python is indentation-sensitive.

Sub-issues

Metadata

Metadata

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions