5 ms·
I have not looked further but this looks like Haskell. I see haskell, I upvote.
by toomanydoubts 4y ago
I have not looked further but this looks like Haskell. I see haskell, I upvote.
- keybored 4y agoAny tool that is PL-related has a good chance of being implemented by functional programmers who then inject their syntactic preferences into the tool itself.
- WJW 4y agoThere are a lot of type-level checks you can do in Haskell that are simply not feasible in most other languages and that helps with the realtime guarantees of the generated code. Syntactic preferences may also be there of course (Haskell is certainly not underrepresented in compiler dev circles), but there are definitely technical reasons as well.
- heavyset_go 4y agoCan you expound on how Haskell's type-level checks can help with realtime guarantees of generated code?
- WJW 4y agoIn a nutshell, most languages allow their functions/methods to do almost everything by default. My Ruby methods can log to stdout, mutate global state, create files on disk, truncate database tables, throw exceptions, fire the missiles and generally do whatever it wants. The default is very permissive. The most basic Haskell function on the other hand can do almost nothing. It can access nothing except it's (immutable) arguments and do nothing except returning a result. If you want to add more 'functionality' to it, you have to explicitly mention that in its type. The typical way to do that in Haskell is to add one or more monadic contexts to it. Writing to a file would typically require access to the the `IO` context for example, and if a function does not have that then file I/O would be a compiler error. To bring it back to CoPilot, it is a heavily restricted DSL where all variables are streams of values, each of which gets updated in every iteration of the main loop. The types of the functions and datatypes that you can manipulate these streams with don't contain any "interesting" monadic contexts, so you definitely can't access the outside world other than through the provided interfaces. You are also mostly restricted to mathematical operations on these streams, like summing or multiplying two other streams to produce a third stream. This already restricts a lot of the variability you could introduce in a "normal" program. The CoPilot project then contains a dedicated Haskell-to-C compiler that will try its best to generate constant-time and constant-memory code. If that is not possible, it will generate a compiler error indicating which part was not possible to compile in such a way. For example, for most recursive functions it would not be possible to prove it terminates in a predictable amount of time so that would be right out. Of course, even if it does compile then there are no guarantees that the code will fit inside your time or memory budget. It is still possible to write code that is inefficient or contains bugs. It will just always take the same amount of memory and same amount of cycles per iteration.
- heavyset_go 4y agoThanks a lot, I really appreciate your explanation.
- keybored 4y agoOkay, so this is a DSL embedded in Haskell. I thought Copilot was a standalone language with a Haskell-like syntax.
- deleted 4y ago[deleted]
- _rend 4y agoFrom the Download page[1]: > Copilot is implemented as a Embedded Domain Specific Language in Haskell. Currently Copilot 3.1 requires a version of the Glasgow Haskell Compiler (GHC) of at least 8.0 to be installed. So yeah, looks like Haskell because it is Haskell! :) [1]: https://copilot-language.github.io/download.html https://copilot-language.github.io/download.html
- deleted 4y ago[deleted]