4 ms·
The control flow section perplexed me a bit, just because you can embed a DSL in Haskell with monads doesn’t mean that “control flow isn’t embedded in the langu
by mlazos 7y ago
The control flow section perplexed me a bit, just because you can embed a DSL in Haskell with monads doesn’t mean that “control flow isn’t embedded in the language”. You still have a main entry point and all functions are executed top to bottom albeit with lazy semantics. You could write a DSL and interpret it with C# with all of the properties they want. Haskell is better for this sort of task but their reasons seemed off. Am I misunderstanding that section?
- willtim 7y agoUsing C# as an example, foreach and IEnumerable are baked into the language as is try/catch and more recently Async/Await. These are all just library functions in Haskell and often more general (e.g. forM in Haskell works for any Monad not just IO). Because they are library functions they can be changed/customized very easily. In C#, how could foreach be made to support a different stream type, exceptions be made checked or Async/Await be made to suspend across stack frames? For this reason, Haskell is probably closer to a general purpose language than many of the imperative systems programming languages (especially Go).
- bakhy 7y agoC# has LINQ. Implement Select and SelectMany extension methods for whatever you like, and you can use the LINQ syntax with your type just as easily as with IEnumerable. Foreach and async/await are baked in, that's true, but the LINQ syntax is easily extendable to new use cases.
- ddellacosta 7y agoI wonder why this is? https://www.infoq.com/interviews/erik-meijer-linq/ https://www.infoq.com/interviews/erik-meijer-linq/ (from "3. How does LINQ work?") What we have done, and what the mathematicians call Monads, we have identified these sets of operations, we call them standard query operators; we have a list of about 25 standard operators that you can apply to any data model.
- lmm 7y ago> all functions are executed top to bottom albeit with lazy semantics. No? There is no "top to bottom" execution, that's the whole point of the lazy semantics.
- mlazos 7y agoMy point was that you still call functions and return from them, you have conditionals, and you still have a call stack with lexical scoping (and Main). You have a very similar control flow model compared to any other language. The other comment explained pretty well what they meant by having the control flow not being dictated by the language - with the expressiveness of haskell’s core language you can dictate your control flow for your embedded dsl.