Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

2D arrays #276

Closed
24 tasks done
rolyp opened this issue Feb 26, 2020 · 4 comments
Closed
24 tasks done

2D arrays #276

rolyp opened this issue Feb 26, 2020 · 4 comments
Assignees

Comments

@rolyp
Copy link
Collaborator

rolyp commented Feb 26, 2020

A proposed syntax for arrays in Fluid, as a precursor to defining a formal syntax. Let’s start by rewriting the convolution example in “Fluid extended with array notation.” You can create a new file fluid/example/convolution.fld for this experiment. It won’t parse with our existing parser, but it will allow us to prototype how we want things to look before making changes to the grammar.

Take a look at the code examples in the fluid folder to see what you can currently do in the language (unfortunately there isn’t any documentation yet, and there are some oddities like Unicode arrows). We can probably assume our arrays have a fixed lower bound (0 or 1). My guess is that this will take multiple iterations before we settle on a design, especially we’re not clear yet on the relationship to lists.

If we’re going to end up needing comprehensions, you might like to take a look at https://www.haskell.org/onlinereport/exps.html#list-comprehensions for how Haskell translates list comprehensions into the core language.

  • add names to primitives – defer to later task
  • fix problem revealed by dependsNeither (output dependencies only relevant to constructed values)
  • standardise on eval_fwd vs. desugarFwd

Done/dropped:

  • prototype Fluid array syntax using convolution example
  • list comprehensions (List comprehensions #277)
  • formalise grammar, typing rules and evaluation rules for arrays
  • factor branch and branches parsers into separate curried and uncurried versions
  • rename range to enumFromTo, a la Haskell
  • array construction
    • AST, eval rule
    • desugaring rules
    • parser
    • fwd slicing
    • bwd slicing
    • test case
  • array dims, lookup
    • generalise primitives to deal with array arguments
    • switch to storing indices as the pair value used to compute them
    • forward slicing
      • rehash primitives design to allow for custom dependencies
    • backward slicing
      • rehash primitives design again to flatten representation of partially applied primitives
        • store list of operands along with primitives
        • associate arity with each primitive
  • eliminate setα, getα
  • desugar BinaryApp s1 op s2 into App (App (Op op) (desugar s1)) (desugar s2)
@rolyp
Copy link
Collaborator Author

rolyp commented Feb 26, 2020

@min-nguyen Realised that keeping lengthy discussions against commits isn’t very helpful, so created this task instead.

@min-nguyen
Copy link
Collaborator

Thanks! Also out of interest, is the need to introduce arrays due to wanting to implement matrix convolution? i.e. were there a way of performing convolution using only lists, would we not be interested in this?

@rolyp
Copy link
Collaborator Author

rolyp commented Feb 27, 2020

Yes, the main reason for arrays is simply that it’s a nicer fit for convolution and other similar applications. List^2 would be an alternative, although somewhat less type-constrained because there would be no requirement that the inner lists all be of the same size.

I guess one thing we can do before we add arrays to the language is add list comprehensions - it sounds like we will need these for arrays, and it would be a nice feature to have anyway. So I suggest starting with fluid/example/list-comprehension.fld instead - just a simple example we can use to settle on a syntax for comprehensions. Probably we want the simplest version of comprehensions we can get away with (Haskell no doubt has more features than we need). We can then turn that file into a failing test case for the parser, which will induce the task of modifying the parser to make the test pass.

We can then think about the evaluation semantics and slicing rules for list comprehensions, which would be a nice thing to have. (We’ll have to give a direct semantics for list comprehensions, rather than an indirect one expressed in terms of a translation to a core language. We can discuss why and what this would involve nearer the time.)

@rolyp rolyp mentioned this issue Feb 27, 2020
11 tasks
@rolyp
Copy link
Collaborator Author

rolyp commented Feb 27, 2020

Extracted a new task (#277) for list comprehensions, since they can be done first and will be an independently useful feature.

@rolyp rolyp changed the title Prototype Fluid array syntax using convolution example 2D arrays Mar 2, 2020
@rolyp rolyp mentioned this issue Mar 3, 2020
@rolyp rolyp closed this as completed Mar 19, 2021
@rolyp rolyp added this to the v0.4: POPL 2022 milestone Nov 3, 2021
@rolyp rolyp added this to Fluid Jun 30, 2022
@rolyp rolyp moved this to Done in Fluid Jun 30, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

2 participants