This may be a strange question. I have the following DSL whose sole purpose is to construct a list, and as such as it provides one method that will append to a being-constructed list:
I'm working on the notion of (for lack of better term) "typed forests" - which is a forest type (a tree with several roots) in which each node "determines" its children types (so, dependent types?). I use GADTs to represent the node types. Each GADT constructor represents the possible choice for a n
That's very similar to that html-do problem - you could use RebindableSyntax and overload >>, but I guess in this case, you could just as well ditch do for (/-) :: Member (XListLang f) r => X f -> Sem r a -> Sem r ()
This may be a strange question. I have the following DSL whose sole purpose is to construct a list, and as such as it provides one method that will append to a being-constructed list:
I use it like this:
Question: can that
addX
be obviated entirely? So that I can define foo as:Real-world example:
(For a larger context, I actually have a "XMapLang" as well - which is all part of of the typed-forest thing described here: https://funprog.srid.ca/haskell/typed-forest.html )
For XMapLang this is not a problem, as its methods take two arguments - so I created nice operators:
As you can see,
XListLang
's method takes one parameter only; so defining operator won't work.Currently trying to write a Monad instance myself:
Uhh, no. What I need is a monad instance for
X f
itself.But the confusion is: what should be the semantics of
stuff <- cheese
be? That makes no sense.Using
PostfixOperators
Don't really like those parenthesis though
Alternatively using list constructor:
But don't like the
: []
at the end.But I don't like non-do based solutions, because you can't nest the structure without tripping precedences or using paranthesis
So back to monads, but because Haskell does not allow user-defined unary operators, we use
o :: ()
to:That's very similar to that
html-do
problem - you could useRebindableSyntax
and overload>>
, but I guess in this case, you could just as well ditchdo
for(/-) :: Member (XListLang f) r => X f -> Sem r a -> Sem r ()
Where
infixr 0 /-