4 ms·
The trick you describe is possible in Haskell also. https://hackage.haskell.org/package/simple-reflect https://hackage.haskell.org/package/simple-reflect does i
by _jackdk_ 2y ago
The trick you describe is possible in Haskell also. https://hackage.haskell.org/package/simple-reflect https://hackage.haskell.org/package/simple-reflect does it by providing a `Num` instance for a particular type.
I'm surprised that you say an imperative language would give you an _easier_ embedding than using Haskell. I would have said the reverse: Haskell makes it impossible to confuse an imperative command used during AST assembly with a representation of an imperative command. That's one of the payoffs of using monads.
- JadeNB 2y ago> I'm surprised that you say an imperative language would give you an _easier_ embedding than using Haskell. I don't think your parent says this. The three comparisons I found were: > The fun thing is that this sounds like "just" a more type-safe version of the way DSLs are usually implemented in imperative languages, particularly scripting languages. This sounds like saying that this trick is already common in imperative languages, not necessarily easier. > The DSL in question tries to block that by preventing AST nodes from being converted to boolean, but it's not perfect. Haskell has an advantage there. This explicitly gives the win to Haskell. > So there's no trouble distinguishing between, e.g., calling some function bar() and then using the return value twice, versus calling bar() twice. No need to use a separate <- operator for assignments. This one seems to give the win to imperative languages, but, as far as I can tell, just on the basis of syntax.