Questions tagged [arrows]

Arrows are a means of modeling computational effects that are more general and less powerful than Monads.

Arrows can express relationships between nodes in a graph (a tree is a type of graph).

Arrows can be primitives in computer graphics.

In some programming languages, arrow symbols like -> and => are syntax with specific meaning.

335 questions
19
votes
1 answer

What are hyperfunctions in the context of computer science?

In Arrows: A General Interface to Computation I found this brief remark on hyperfunctions: The weird datatype newtype Hyper b c = H (Hyper c b -> c) can be shown to be an arrow [KLP01]. but the link to the paper is broken. There is also…
Petr
  • 62,528
  • 13
  • 153
  • 317
17
votes
3 answers

Computation Constructs (Monads, Arrows, etc.)

I have become rather interested in how computation is modeled in Haskell. Several resources have described monads as "composable computation" and arrows as "abstract views of computation". I've never seen monoids, functors or applicative functors…
Doug Moore
  • 1,028
  • 2
  • 10
  • 20
17
votes
1 answer

Arrow and Monad, two independent viewpoints to compose computations?

I've reading the "The Typeclassopedia" by Brent Yorgey in Monad.Reader#13 ,and found that "the Functor hierachy" is interdependent of "the Category hierachy" as the Figure.1 shown. And according to the author, ArrowApply == Monad, especially that…
snowmantw
  • 1,611
  • 1
  • 13
  • 25
17
votes
2 answers

Would a type class "between" Category and Arrow make sense?

Often you have something like an Applicative without pure, or something like a Monad, but without return. The semigroupoid package covers these cases with Apply and Bind. Now I'm in a similar situation concerning Arrow, where I can't define a…
Landei
  • 54,104
  • 13
  • 100
  • 195
17
votes
1 answer

Haskell: Am I misunderstanding how Arrows may be used?

I wrote some toy code to play with the concept of Arrows. I wanted to see if I could write an Arrow which encoded the concept of a stateful function - giving a different value after different calls. {-# LANGUAGE Arrows#-} module StatefulFunc…
rampion
  • 87,131
  • 49
  • 199
  • 315
16
votes
4 answers

How to make custom arrow mark in agm-map?

I am building a vehicle tracking application and i am using agm-map-marker to display the vehicles that were located like this in the image, And Livetracking.component.html code is,
16
votes
1 answer

Control.Category, what does >>> and <<< mean?

I am following this blog, to write a simple http server in haskell, Usage of >>> is not clear to me. What does this code snippet do? handleHttpConnection r c = runKleisli (receiveRequest >>> handleRequest r >>> handleResponse) c >> close…
15
votes
2 answers

Proc syntax in Haskell Arrows leads to severe performance penalty

Using proc notation for Arrow seems to kill performance in my project. Here is a toy example of the problem: We define Coroutine newtype (mostly copying from Generalizing Streams into Coroutines) to represent Mealy machines (i.e. functions that…
Artem Solod
  • 417
  • 2
  • 9
15
votes
2 answers

Is there something like `map2 :: (i -> a) -> (i -> b) -> [i] -> [(a,b)]`?

I just wrote functions like this up to map4 just because they seem useful: map2 :: Functor f => (i -> a) -> (i -> b) -> f i -> f (a,b) map2 f1 f2 = fmap $ \i -> (f1 i, f2 i) Before I continue to map8 i thought I'd ask if there is something similar…
fho
  • 6,787
  • 26
  • 71
15
votes
1 answer

Employing arrows to fold a list of tuples

Sometimes you want to fold a list of tuples into one tuple using different folding functions. For instance, in order to glue together a list of runState results, getting an (in some sense) combined state and a combined result. Consider the following…
Francis Drake
  • 315
  • 2
  • 11
14
votes
1 answer

Arrow equivalent of mapM?

I'm trying to grok & work with Arrows, and am having some difficulty. I have a context where I need an Arrow [a] [b], and I want to write an Arrow a b and map/sequence it inside the arrow, a la mapM. Specifically, the arrow is a Hakyll Compiler, but…
Michael Ekstrand
  • 28,379
  • 9
  • 61
  • 93
13
votes
1 answer

JavaFX line/curve with arrow head

I'm creating a graph in JavaFX which is supposed to be connected by directed edges. Best would be a bicubic curve. Does anyone know how to do add the arrow heads? The arrow heads should of course be rotated depending on the end of the curve. Here's…
Roland
  • 18,114
  • 12
  • 62
  • 93
13
votes
2 answers

Haskell's Arrow-Class in Agda and -> in Agda

I have two closely related questions: First, how can the Haskell's Arrow class be modeled / represented in Agda? class Arrow a where arr :: (b -> c) -> a b c (>>>) :: a b c -> a c d -> a b d first :: a b c -> a (b,d)…
phynfo
  • 4,830
  • 1
  • 25
  • 38
12
votes
2 answers

Creative uses of arrows

I just read the post Creative uses of monads, that is crowded of very interesting ideas and references, so I got curious: what about arrows? I'm not looking for personal opinions or references on the basics or "standard" uses (as in monads vs arrows…
Riccardo T.
  • 8,907
  • 5
  • 38
  • 78
12
votes
2 answers

What do the special brackets (| ... |) desugar into?

I've read the arrow notation documentation page, but it's not entirely clear to me what the "pipe brackets" used under "7.10.3. Defining your own control structures" desugar into. Given the example in the above document proc x -> do y <- f -<…
shang
  • 24,642
  • 3
  • 58
  • 86
1
2
3
22 23