Code Monkey home page Code Monkey logo

Comments (3)

fehrenbach avatar fehrenbach commented on June 19, 2024

As small as an example as I can manage:

var db = database "stefan";

var exists = compose(not, empty);

typename Data = (parent : Int, value  : String);

typename CompilationContext = TableHandle(Data,Data,Data);

sig filterConstraint : (CompilationContext) ~> (Data) -> Bool
fun filterConstraint (data) {
  var aa = fun (x) {
             for (text <-- data)
             where ( true )
               [(val = text.value)]
             };
  fun (x) {
    exists(
      for (a <- aa(x))
      where (a.val == "b")
        [()]
    )
  }
}

var data = table ("ciawfb_data") with Data from db;
var filter = filterConstraint(data);
query {
  for (r <-- data)
  where (filter(r))
    [r]
}

Replacing sig filterConstraint : (CompilationContext) ~> (Data) -> Bool by sig filterConstraint : (CompilationContext) ~> (Data) {}-> Bool "fixes" the problem.

from links.

slindley avatar slindley commented on June 19, 2024

Here's a smaller example:

var exists = compose(not, empty);

sig filterConstraint : () -> Bool
fun filterConstraint () {
  exists([()])
}

query {
  [(x=filterConstraint())]
}

There is a bug in Links in the way it is reporting the bug in your program. The bug in your program is that due to the ML value restriction, exists is not polymorphic in its effects, but filterConstraint is declared to have a type that is polymorphic in its effects. The solution is to eta expand exists:

fun exists(xs) {not(empty(xs))}

or:

var exists = fun (xs) {compose(not, empty)(xs)};

In fact, we could, and perhaps should relax the value restriction in the case of pure functions (like compose, pure, and empty), in which case your original program would work.

from links.

fehrenbach avatar fehrenbach commented on June 19, 2024

Thanks, I fixed my code :-)
Now I'll have to do some reading on the value restriction.

from links.

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.