Comments (4)
I wonder if we could get rid of the current data declarations and just have polymorphic variants. It would definitely be nice to have symmetry in the type system.
data Foo a = Foo | Bar a
would become something like
type Foo a = < Foo , Bar a >
with maybe better syntax
from purescript.
Initial attempt is in the variants
branch. Code review would be appreciated.
This change removes data
declarations, and now every constructor must take exactly one argument. This means that there is no exact equivalent for data Maybe a = Nothing | Just a
. The nearest thing is type Maybe a = <Nothing {} | Just a>
, but note that the Nothing
constructor now requires an argument. This is because I can't infer the number of arguments when using the Nothing
constructor on its own.
from purescript.
Moving this out of the current milestone until I can figure out what to do with nullary constructors.
One option might be to allow quantification over vectors of types, giving them their own kind V
, say, so that e.g. Nothing
would have type
Nothing :: forall v. v -> <Nothing :: v>
where v
denotes an unknown vector of types, i.e. Nothing
is a function which takes an unknown number of arguments.
Constructors would have sets of values with kind V
, brought into scope in a case statement.
The case statement
case x of
Nothing() -> ...
Just(y) -> ...
would give the following types:
Nothing :: () -> <Nothing :: ()>
Just :: forall y. (y) -> <Just :: (y)>
This approach would probably require that unknowns cannot appear deep inside a vector. That is, a vector can either be unknown or fully known.
from purescript.
I think this has proved to be too difficult to integrate with the current sum types.
from purescript.
Related Issues (20)
- Name collision with `top` HOT 8
- Improve error message for generic method implementation in point-free style for recursive type HOT 1
- Extend CoreFn's Int literal encoding with a stringified value HOT 8
- LTS 21.7 for ghc-9.4.5
- Bad rejection of some instances of classes with fundeps. (Or misleading error message) HOT 1
- CI's Ubuntu build doesn't hit the cache
- Core dump for Linux Arm64 release with ArchlinuxARM HOT 5
- Improve accessibility for the generated docs HOT 7
- Parser accepts @ binders in class heads
- Have more information in DuplicateSelectiveImport
- Support `--source-globs FILE` argument due to Windows' `cmd.exe` character limitation
- Problem typing a let expression HOT 1
- Replace `npm-installer` usage with `purs-installer` HOT 1
- Pattern matching between identical let-bindings produce no shadowing errors HOT 4
- Type synonym impossible to fully apply in type application HOT 2
- Missing all metadata for custom error
- Using an infix type alias in a type application crashes the compiler.
- Document syntax for qualified operators HOT 1
- Record field access using raw strings breaks parser HOT 1
- Code doesn't typecheck when moving a type alias between modules
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 purescript.