dimitriv / Ziria

A domain-specific-language and compiler for low-level bitstream processing.
92 stars 18 forks source link

Support length polymorphism in computation functions #75

Open edsko opened 9 years ago

edsko commented 9 years ago

Currently the code for checking ECall looks like

      fTy    <- instantiateCall =<< zonk (nameTyp f)
      actual <- mapM lintExp args
      res    <- freshTy "b"
      unify loc fTy $ TArrow actual res
      return res

but the code for checking Call looks like

      fTy    <- zonk (nameTyp f)
      actual <- forM args $ \arg -> case arg of
                  CAExp  e -> CAExp  <$> lintExp e
                  CAComp c -> CAComp <$> lintComp c
      res    <- freshCTy "b"
      unify loc fTy $ CTArrow actual res
      return res

with no call to instantiate(C)Call. This means that we do not support polymorphism in computation functions, which is a bit surprising. I haven't changed this right now because if we do change this we should also add some tests for it (and anyway it's an orthogonal concern involving a single changed line).

Note that ctComp already supports polymorphic computation functions.