-
In our last meeting, @JacquesCarette mentioned that we should give priority to cleaning up things related to the type checker. So, let's discuss and confirm the nature of our work and what kind of changes we can/should make needed to “clean up” the type checker. In other words, let's figure out what “clean up” means 😉 . Where it's atQuick recap:
Design choicesRecalling a few of our design choices:
Unfortunately, we only got to typing Expr, but now we want to extend it to type checking the others, whilst minimizing code duplication, amongst other things. How the current type-checker worksThe current type-checker is built around the below code: Drasil/code/drasil-lang/lib/Language/Drasil/WellTyped.hs Lines 10 to 38 in 85cf74d In the above code, we see:
Recalling the code related to Expr, we have a type-checker that relies purely on simple inference: Drasil/code/drasil-lang/lib/Language/Drasil/Expr/Lang.hs Lines 232 to 428 in 85cf74d Issues with the current workWe see:
Ultimately, there's a lot of room for improvement. What we wantFirst, we want the inverse of the 3 issues:
Afterwards, we want to extend the type-checker to ModelExpr and CodeExpr, while being mindful of code duplication. ModelExpr will be a bit more complicated than extension to CodeExpr because of a non-trivial interest: type variables. Where should we go?For now, we will focus on the earlier 3 issues. To address the first issue and the parts of the third, I think we can switch over to a monadic type inference system. Right now, monads are severely underused. We can review how much code duplication is left over after switching to a monadic style. Now, for improved type error messages, I'm not completely sure. One thing is for sure: we need to be able to track where we are in the expression as we go along. Do we do that from “source”? I don't see any easy way to do that without writing a GHC plugin, but I'm not sure if that's the route we want to go down. So, should we track just the AST and print out a horizontal tree that prints the AST with the root in the right-most position? Should we just try to print out Haskell-like code? I'm not quite sure. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Nice summary @balacij. I don't know the answers to your questions, but @JacquesCarette very likely will have some thoughts. Maybe we should discuss this during our morning meeting on Monday? |
Beta Was this translation helpful? Give feedback.
-
As discussed today, we also want the code to "look like" the typing rules as much as possible. One of the things to do to clean up the code a lot is to move the error-generating code "elsewhere". And error happens when a conflict arises between reality (the Then the remaining work becomes one of 'classifying' the different kinds of conflicts that can arise from the rules. I wonder if there's something we can learn from Andrej Bauer's PL zoo regarding this. |
Beta Was this translation helpful? Give feedback.
Thank you! Hmm, I don't think it would hurt, but I think this one can be done over GitHub, so perhaps as a lower priority item?