witchcrafters / witchcraft

Monads and other dark magic for Elixir
https://witchcrafters.github.io
MIT License
1.2k stars 58 forks source link

Applicative do notation #30

Open expede opened 7 years ago

expede commented 7 years ago

What it says in the title

expede commented 7 years ago

This requires significantly more AST magic than monadic do (#19). Will return to this after completing v1 #29

OvermindDL1 commented 7 years ago

Remember, if necessary you can add a post-compilation pass like Protocols uses (where it scans all beam files for things that implement protocols, reads some meta-data out of them, then builds a singular Protocol.* module that inlines everything for speed).

expede commented 7 years ago

@OvermindDL1 ah, cool, I haven't dug into how Protocol does that yet. Will check it out for sure 😃

For Applicative Do (as opposed to Monadic Do, which is in the code already), the magic is more around desugaring in a way that lets you do computation in parallel when there are no data dependancies between lines. Here's a detailed explanation from the GHC docs.

This is totally doable (ha! pun), but probably doesn't need to be in there for v1.0.0 launch, especially due to the higher complexity and that fact that it's so new even in Haskell.

OvermindDL1 commented 7 years ago

For Applicative Do (as opposed to Monadic Do, which is in the code already), the magic is more around desugaring in a way that lets you do computation in parallel when there are no data dependancies between lines. Here's a detailed explanation from the GHC docs.

Heh, I know, I just noticed some work in type_class and there was not really a good place to mention how Protocols work there, and this issue seemed 5% related, so I dropped it here instead of creating a new issue just to mention how Protocols work. I figure you might find a post-compile hook useful in a variety of work. ^.^