Giter Club home page Giter Club logo

Comments (4)

paf31 avatar paf31 commented on May 18, 2024

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.

paf31 avatar paf31 commented on May 18, 2024

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.

paf31 avatar paf31 commented on May 18, 2024

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.

paf31 avatar paf31 commented on May 18, 2024

I think this has proved to be too difficult to integrate with the current sum types.

from purescript.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.