![]() ![]() If it's a "couldn't match expected type a against inferred a -> b" then you know it's probably too few arguments to a function. If you want to provide more friendly compile errors, just parse the code, filter it, send it to the compiler, and parse the compiler output. You can use the SrcLoc value attached to every node in the AST: data SrcLoc = SrcLoc Then you have an AST for a module: Module SrcLoc ModuleName (Maybe WarningText) (Maybe ) Īll you need to do is define a white-list - of what declarations, imports, symbols, syntax is available, then walk the AST and throw a "parse error" on anything you don't want them to be aware of yet. Just parse the module: parseModule :: String -> ParseResult Module I did this for to disallow import statements, to support top-level definitions, etc. Once you've parsed it, stripping out or disallowing certain things is easy. By limiting what they can do, you can prevent them from shooting themselves in the foot while they are still mastering the syntax and concepts you are trying to teach. Pedagogical "language levels" have been used successfully to teach Java and Scheme. As the students progress, I can selectively "turn on" various features once they've mastered the basics. So my idea is to create a language that has exactly the features of Haskell that I'd like and disallows everything else. Miranda does about 90% of what I'd like it to do, but Haskell does about 2000%. ![]() For this semester I have settled on Miranda, a smaller language that inspired Haskell. I am exploring the idea of using Haskell as a language to explore some of the concepts in a Discrete Structures course I am teaching. Of course it can be done, but are there any online resources available to look at? Is there a similar exercise for Haskell? I'd like to implement a subset of Haskell using Haskell as the engine. The power of the full language can be leveraged to produce an interpreter for a subset of the language. A classic programming exercise is to write a Lisp/Scheme interpreter in Lisp/Scheme.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |