Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fromRise fails when a type variable should be a basic type (or other constraint) #32

Closed
Bastacyclop opened this issue Jan 27, 2020 · 3 comments
Labels
bug Something isn't working

Comments

@Bastacyclop
Copy link
Member

Example:

  // average two positive values rounding up
  val avg: Expr = dtFun(dt => dtFun(compute_dt => fun(
    dt ->: dt ->: dt
  )((a, b) => {
    val cast_ = fun(a => cast(a) :: compute_dt)
    cast((cast_(a) + cast_(b) + cast_(l(1))) / cast_(l(2))) :: dt
  })))

  test("failure") {
    shine.DPIA.fromRise(infer(avg(i16)(i32)))
  }

More precisely, the pattern match in fromRise cannot not pass since TypeVariable is not a BasicType:

      case (core.Cast(), lt.FunType(la: lt.BasicType, lb: lt.BasicType))
      =>
        val a = basicType(la)
        val b = basicType(lb)
        fun[ExpType](ExpType(a, read), x =>
          Cast(a, b, x))

This is closely related to rise-lang/rise#11.

@Bastacyclop Bastacyclop added the bug Something isn't working label Jan 27, 2020
@Bastacyclop
Copy link
Member Author

Currently this is issue is fixed by beta-reducing nat dependent lambdas in fromRise. The idea is that we should always have concrete data types when going to code generation and thus we can eliminate all data type variables.

@bastian-koepcke
Copy link
Member

Does this mean the issue has been resolved?

@Bastacyclop
Copy link
Member Author

@bastian-koepcke Well, I am happy with this solution. We can close the issue if there is no objection.
@rise-lang/core

bastian-koepcke pushed a commit that referenced this issue Sep 17, 2020
Add toMem Primitive to Typed DSL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants