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
79
votes
5 answers

What are arrows, and how can I use them?

I tried to learn the meaning of arrows, but I didn't understand them. I used the Wikibooks tutorial. I think Wikibook's problem is mainly that it seems to be written for somebody who already understands the topic. Can somebody explain what arrows…
fuz
  • 88,405
  • 25
  • 200
  • 352
73
votes
2 answers

Monads vs. Arrows

I'm broadly familiar with the concepts of monads and arrows as used in functional programming. I also understand that they can be used to solve similar kinds of problems. However, I'm still a bit confused about how to select which one to use in any…
mikera
  • 105,238
  • 25
  • 256
  • 415
67
votes
4 answers

How to draw a nice arrow in ggplot2

I am creating a ggplot chart where I want to have some arrows between two points. The main task is easily done with geom_line(arrow = arrow()). However, I want to have some "beautiful" thick arrows. Resizing the arrow via size= doesn't help since it…
Sebastian Kuhn
  • 671
  • 1
  • 5
  • 7
59
votes
1 answer

Understanding Arrows in Haskell

I've been trying to get a grip on arrows since they're the basis of most FRP implementations. I think I understand the basic idea - they're related to monads but store static information at each bind operator so you can walk through a chain of…
Bill
  • 44,502
  • 24
  • 122
  • 213
38
votes
3 answers

Arrows are exactly equivalent to applicative functors?

According to the famous paper Idioms are oblivious, arrows are meticulous, monads are promiscuous, the expressive power of arrows (without any additional typeclasses) should be somewhere strictly between applicative functors and monads: monads are…
Cactus
  • 27,075
  • 9
  • 69
  • 149
35
votes
1 answer

Useful operations on free arrows

We know free monads are useful, and packages like Operational make it easy to define new monads by only caring about the application-specific effects, not the monadic structure itself. We can easily define "free arrows" analogous to how free monads…
Cactus
  • 27,075
  • 9
  • 69
  • 149
32
votes
1 answer

How does ArrowLoop work? Also, mfix?

I'm fairly comfortable now with the rest of the arrow machinery, but I don't get how loop works. It seems magical to me, and that's bad for my understanding. I also have trouble understanding mfix. When I look at a piece of code that uses rec in a…
danharaj
  • 1,613
  • 14
  • 19
30
votes
2 answers

What's the relationship between profunctors and arrows?

Apparently, every Arrow is a Strong profunctor. Indeed ^>> and >>^ correspond to lmap and rmap. And first' and second' are just the same as first and second. Similarly every ArrowChoice is also Choice. What profunctors lack compared to arrows is the…
Petr
  • 62,528
  • 13
  • 153
  • 317
29
votes
4 answers

How to add arrows with -webkit-scrollbar-button

I have a custom scrollbar. Since I did that, the arrows of the scrollbar are not shown anymore. .scrollbar::-webkit-scrollbar-thumb { background-color: ##00a7e0; } .scrollbar::-webkit-scrollbar-track { background-color: #F5F5F5; } …
BlueCat
  • 673
  • 4
  • 16
  • 27
26
votes
2 answers

How does the Haskell rec keyword work?

In arrow do notation, you can use the rec keyword to write recursive definitions. So for example: rec name <- function -< input input <- otherFunction -< name How can this ever evaluate? It seems like it would just go into an infinite loop…
Jeff Burka
  • 2,571
  • 1
  • 17
  • 30
26
votes
3 answers

Can someone explain to me why the app function of ArrowApply makes them as powerful as monads?

So I'll break my question into 4 parts, but first some background: I feel relatively comfortable with Monads, but not very comfortable with Arrows. I suppose the main problem I have with them is, I don't see what they are useful for. Whether…
25
votes
1 answer

Arrow without arr

If we restrict our understanding of a category to be the usual Category class in Haskell: class Category c where id :: c x x (>>>) :: c x y -> c y z -> c x z Then let's say that an Arrow is a Category which can additionally: class Category c =>…
Dan Burton
  • 53,238
  • 27
  • 117
  • 198
22
votes
2 answers

How does this definition of ArrowLoop.loop work?

The function instance for ArrowLoop contains loop :: ((b,d) -> (c,d)) -> (b -> c) loop f b = let (c,d) = f (b,d) in c First I have a problem with the signature: How can we possibly get b -> c from (b,d) -> (c,d)? I mean, the c in the resulting…
Landei
  • 54,104
  • 13
  • 100
  • 195
21
votes
1 answer

Odd ghc error message, "My brain just exploded"?

When I try to pattern-match a GADT in an proc syntax (with Netwire and Vinyl): sceneRoot = proc inputs -> do let (Identity camera :& Identity children) = inputs returnA -< (<*>) (map (rGet draw) children) . pure I get the…
Dan
  • 12,409
  • 3
  • 50
  • 87
21
votes
5 answers

What can Arrows do that Monads can't?

Arrows seem to be gaining popularity in the Haskell community, but it seems to me like Monads are more powerful. What is gained by using Arrows? Why can't Monads be used instead?
Vlad the Impala
  • 15,572
  • 16
  • 81
  • 124
1
2 3
22 23