Deep embeddings and Arrows Re: Uniquable RdrName instance

to clarify: having bind would be equivalent to having arr for the purposes
of my question (assuming its the standard monadic bind).
having arr :: (b -> c) -> a b c
is tantamount to assuming that any haskell function can be embedded in an
arrow instance
which prevents a lot of interesting deep embedding uses of the Arrow
abstraction/ or at least makes it a bit tricker. (eg things like writing
circuits or certain types of compiled FRP models).
On Tue, Jun 17, 2014 at 4:06 AM, Jan Stolarek
FYI it's #7828, not #7282. Of course, yes.
would making arrow remindable involve dropping the arr == haksell functions assumption or doing something that would allow generalized arrows? Not sure if I fully understand what you mean. There's an idea to give up on current desugaring that heavily uses arr, >>> etc. in favor of desugaring based on bind equivalents for arrows. Is this what you wanted to know? There's some discussion on the Trac you might want to follow.
Janek _______________________________________________ ghc-devs mailing list ghc-devs@haskell.org http://www.haskell.org/mailman/listinfo/ghc-devs

assuming that any haskell function can be embedded in an arrow instance (...) prevents a lot of interesting deep embedding uses of the Arrow abstraction Could you point me to some specific examples? I'm new to arrows and definitely far from groking all the arcana of their usage.
Janek

ok, so one example of this design, albeit implemented in a funky way
(compiler passes written in coq), was
Adam Megacz's Garrows project http://www.megacz.com/berkeley/garrows/
a more concrete example of a haskell lib that enjoys a deep embedding and
doesn't let you inject arbitrary (f:: a-> b )
would be Accelerate hackage.haskell.org/package/accelerate (the expression
language there could be made into an "*arr* free Arrow" but not an Arrow
that has *arr*)
basically not having *arr* or the monadic equiv *bind*, gives you a way to
write libs where you can get a program as a first order AST when you "run
it" and be able to analyze/compile it in user land at runtime
On Tue, Jun 17, 2014 at 4:37 PM, Jan Stolarek
assuming that any haskell function can be embedded in an arrow instance (...) prevents a lot of interesting deep embedding uses of the Arrow abstraction Could you point me to some specific examples? I'm new to arrows and definitely far from groking all the arcana of their usage.
Janek

Conal (cc'd) also has an ongoing blog series about this http://conal.net/blog/ On Tue, Jun 17, 2014 at 4:45 PM, Carter Schonwald < carter.schonwald@gmail.com> wrote:
ok, so one example of this design, albeit implemented in a funky way (compiler passes written in coq), was Adam Megacz's Garrows project http://www.megacz.com/berkeley/garrows/
a more concrete example of a haskell lib that enjoys a deep embedding and doesn't let you inject arbitrary (f:: a-> b ) would be Accelerate hackage.haskell.org/package/accelerate (the expression language there could be made into an "*arr* free Arrow" but not an Arrow that has *arr*)
basically not having *arr* or the monadic equiv *bind*, gives you a way to write libs where you can get a program as a first order AST when you "run it" and be able to analyze/compile it in user land at runtime
On Tue, Jun 17, 2014 at 4:37 PM, Jan Stolarek
wrote: assuming that any haskell function can be embedded in an arrow instance (...) prevents a lot of interesting deep embedding uses of the Arrow abstraction Could you point me to some specific examples? I'm new to arrows and definitely far from groking all the arcana of their usage.
Janek

Did you mean pure/return as the monadic equivalent? I've frequently
encountered embeddings where it's possible to have a valid <*> and >>= but
not pure (or fmap).
On Jun 17, 2014 1:46 PM, "Carter Schonwald"
ok, so one example of this design, albeit implemented in a funky way
(compiler passes written in coq), was
Adam Megacz's Garrows project http://www.megacz.com/berkeley/garrows/
a more concrete example of a haskell lib that enjoys a deep embedding and doesn't let you inject arbitrary (f:: a-> b ) would be Accelerate hackage.haskell.org/package/accelerate (the expression language there could be made into an "arr free Arrow" but not an Arrow that has arr)
basically not having arr or the monadic equiv bind, gives you a way to write libs where you can get a program as a first order AST when you "run it" and be able to analyze/compile it in user land at runtime
On Tue, Jun 17, 2014 at 4:37 PM, Jan Stolarek
wrote: assuming that any haskell function can be embedded in an arrow instance (...) prevents a lot of interesting deep embedding uses
of the Arrow
abstraction Could you point me to some specific examples? I'm new to arrows and definitely far from groking all the arcana of their usage.
Janek
_______________________________________________ ghc-devs mailing list ghc-devs@haskell.org http://www.haskell.org/mailman/listinfo/ghc-devs

yes, that what I meant, though the standard >>= does need to be used
carefully on a restricted universe of types to ensure you can get a deep
embedding
On Tue, Jun 17, 2014 at 5:33 PM, John Lato
Did you mean pure/return as the monadic equivalent? I've frequently encountered embeddings where it's possible to have a valid <*> and >>= but not pure (or fmap).
On Jun 17, 2014 1:46 PM, "Carter Schonwald"
wrote: ok, so one example of this design, albeit implemented in a funky way
(compiler passes written in coq), was
Adam Megacz's Garrows project http://www.megacz.com/berkeley/garrows/
a more concrete example of a haskell lib that enjoys a deep embedding and doesn't let you inject arbitrary (f:: a-> b ) would be Accelerate hackage.haskell.org/package/accelerate (the expression language there could be made into an "arr free Arrow" but not an Arrow that has arr)
basically not having arr or the monadic equiv bind, gives you a way to write libs where you can get a program as a first order AST when you "run it" and be able to analyze/compile it in user land at runtime
On Tue, Jun 17, 2014 at 4:37 PM, Jan Stolarek
wrote: assuming that any haskell function can be embedded in an arrow instance (...) prevents a lot of interesting deep embedding
uses of the Arrow
abstraction Could you point me to some specific examples? I'm new to arrows and definitely far from groking all the arcana of their usage.
Janek
_______________________________________________ ghc-devs mailing list ghc-devs@haskell.org http://www.haskell.org/mailman/listinfo/ghc-devs

On Tue, Jun 17, 2014 at 03:10:14PM -0400, Carter Schonwald wrote:
to clarify: having bind would be equivalent to having arr for the purposes of my question (assuming its the standard monadic bind).
having arr :: (b -> c) -> a b c
is tantamount to assuming that any haskell function can be embedded in an arrow instance which prevents a lot of interesting deep embedding uses of the Arrow abstraction/ or at least makes it a bit tricker. (eg things like writing circuits or certain types of compiled FRP models).
I have two answers: First, it's not that difficult using the Arrow class. For example, see the netlist example at the end of my "Fun of Programming" slides (http://www.soi.city.ac.uk/~ross/papers/fop.html). The idea is that arr can take any function, but if you require the circuit to be parametric in the value types, you can limit the types of function the programmer can pass to arr to simple plumbing. Second, suppose we split arr :: forall b c. (b -> c) -> a b c into two primitives (^>>) :: forall b c d. (b -> c) -> a c d -> a b d id :: forall b. a b b Arrow notation relies on (^>>) being a contravariant functor -- that's what allows the translation to manipulate environments, and it gives you a substitution property for commands. On the other hand it doesn't need id (or equivalently returnA). Perhaps the problem is the universally quantified b in the type of id. One might instead use a variant of id constrained to an ADT with just the operations you want.
participants (4)
-
Carter Schonwald
-
Jan Stolarek
-
John Lato
-
Ross Paterson