Comments (1)
This is indeed a complex next step! I'm excited for it, and it's worth carefully considering how to design the semantics. Here are just a few notes to get us started.
At an extremely high level, I suggest we divide the effort (both design and implementation) into two phases:
- Polymorphism without inference.
- Defining a polymorphic function type would require explicit type parameters. For example, the syntax might look something like
def foo[M: nat, N: nat](a: int[M bank N])
. The parameters in square brackets are type-level parameters; the parameters in parentheses remain type-level, and their types can refer to type parameters. - Invoking a polymorphic function would require explicitly specifying its type parameters. The syntax might look like
foo[10, 2](m)
. - In this phase, we'd need to define the abstract syntax for polymorphic types. I'd recommend taking inspiration from the appropriate formalism (i.e., System F): there would be explicit type-level abstractions. A type variable occurrence would refer to a specific type abstraction. These type abstractions could be either their own type AST node kind, or they could be folded in with function types (i.e., function types have both a list of type-level parameters and a list of value-level parameters).
- Defining a polymorphic function type would require explicit type parameters. For example, the syntax might look something like
- Add inference.
- Once we're happy with the correctness of the polymorphic language, but exhausted from typing all the parameters every time, now we add inference—and therefore the constraint generation.
- In version 1.0, we should just ask the SMT solver to give us back a concrete assignment for the whole program. Rather than getting back a new set of constraints ourselves, the solver can just pick an arbitrary valuation that makes the program type-check.
- Then, it would be a good subsequent challenge to get this to work in a compositional, intraprocedural way. That would probably involve enriching the language itself to include constraints along the lines of
M % 4 == 0
, which could be written explicitly in addition to being inferred.
from dahlia.
Related Issues (20)
- Add memory to Function Definitions for Futil backend. HOT 3
- `--lower` flag handling memory parameters incorrectly.
- Double imports for FuTIL backend HOT 5
- Using fixed point in futil imports or function definitions doesn't work. HOT 3
- Fixed point division not using correct primitive. HOT 1
- Support reverse range iteration HOT 1
- Remove fixed point constants from Dahlia.
- Hoist slow binops incorrectly hoists
- Current Fixed Point Constant Implementation parses numbers incorrectly.
- Multi-cycle binary operations emit incorrect `write_en` guard.
- UnrollBank doesn't re-write same local variable names in different definitions.
- Add `@bound` attribute for loops with statically known bounds. HOT 1
- [Calyx] Don't generate conflicting assignments when lowering unrolled loops
- `split` views not lowered correctly
- [Calyx] Generate non-combinational reads for memories HOT 2
- Support for Constants and Dynamic Loops HOT 4
- Typechecker isSubtype does not handle alias type
- Typechecker Issue HOT 3
- Split views bypass typechecker and allow incorrect loop unrolling
- Parse error in let expression for bitwidth 32 and above
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dahlia.