mirage / mirage-lambda

An eDSL for MirageOS apps
19 stars 5 forks source link

Sending `return` value to Mirage server causes a type-error #28

Closed aherrmann closed 6 years ago

aherrmann commented 6 years ago

Sending a return value to the Mirage server causes a type-error.

E.g. sending the following (protobufs encoded) Mirage-Lambda program

lam {
  typ { list { value { abstract { witness: "Cstruct.t" } } } }
  var: "inps"
  expr {
    lam {
      typ { list { value { abstract { witness: "Cstruct.t" } } } }
      var: "outs"
      expr {
        val {
          value { return { typ { int { } } value { int { value: 42 } } } }
        }
      }
    }
  }
}

with the following (protobufs encoded) type

arrow {
  a { list { value { abstract { witness: "Cstruct.t" } } } }
  b {
    arrow {
      a { list { value { abstract { witness: "Cstruct.t" } } } }
      b { apply { a { int { } } b { lwt { } } } }
    }
  }
}

(Note, how the expression has type Apply Int Lwt, because the Int value is wrapped in the return value constructor.)

Causes an error with the following log output

Error
  error while evaluating:
  (fun (inps: Cstruct.t list) -> (fun (outs: Cstruct.t list) -> 42)) []
  [(Cstruct.t list -> (Cstruct.t list -> int)) is not compatible with (Cstruct.t list
                                                                      ->
                                                                      (Cstruct.t list
                                                                      ->
                                                                      int Lwt.t))].
dinosaure commented 6 years ago

Close by #31