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
8
votes
1 answer

Why `data` cause an infinite loop while `newtype` not

I am learning Arrow following the tutorial programming with arrows. I've typed the following code according to the paper except that the SF is defined by data, not by newtype as in the paper (actually, I made this change by chance, since I typed the…
Z-Y.L
  • 1,740
  • 1
  • 11
  • 15
8
votes
1 answer

fix vs. ArrowLoop

Description of loop from Control.Arrow: The loop operator expresses computations in which an output value is fed back as input, although the computation occurs only once. It underlies the rec value recursion construct in arrow notation. Its source…
Dannyu NDos
  • 2,458
  • 13
  • 32
8
votes
1 answer

Right-tightening ArrowLoop law

According to the Control.Arrow documentation, for many monads (those for which the >>= operation is strict) the instance MonadFix m => ArrowLoop (Kleisli m) does not satisfy the right-tightening law (loop (f >>> first h) = loop f >>> h) required by…
themarketka
  • 672
  • 6
  • 14
8
votes
1 answer

Can you define an operator (***) in F#?

I'm working on Arrows in F# and I wanted to create a *** operator. I note, however, that (***), the necessary way to express an operator in a function definition, overlaps with the F# block comment syntax. So how could you actually express this?…
CodexArcanum
  • 3,944
  • 3
  • 35
  • 40
8
votes
2 answers

Control.Arrow: Why "let (a,b) = (first,second)" fails?

What I want is to write something like this: let (a,b) = if *condition* then (first, second) else (second, first) I found out that I cannot write even this: let (a,b) = (first,second) It fails with an error: :7:5: …
Savenkov Alexey
  • 678
  • 4
  • 11
8
votes
3 answers

How to disable Slick Slider arrows?

I'm using Slick sliders with two different styles, for my web page but I'm having a problem with arrows. Can you please help me? This is my main .slider, I've styled it's prev and next arrows using CSS http://prntscr.com/7kdpgo And here I used…
Erum-n
  • 81
  • 1
  • 1
  • 3
8
votes
1 answer

Product and Sum Type Parallels in Haskell Type Classes

It appears that type classes such as Applicative, Monad and Arrow have some sort of sum type equivalent in type classes such as Alternative, MonadPlus and ArrowPlus respectively. For example, Applicative and Alternative can be used to define the…
8
votes
1 answer

Haskell Arrow delay function

I am reading John Hughes's Programing with Arrows. There is a piece of code that I really cannot understand. The code is following: import Control.Arrow.Operations import Control.Arrow import Control.Category import Prelude hiding ((.),id) newtype…
Song Zhang
  • 315
  • 1
  • 5
8
votes
1 answer

Tools to View Haskell Arrows as Graphs

Haskell Arrows are commonly explained as expressing a directed acyclic graph (DAG) of computations. I'm looking for tools or library code that would use this relationship in aid of programming with Arrows. From Arrow to graph, a tool could help…
pkturner
  • 83
  • 4
8
votes
2 answers

Converting Monad notation to Arrow notation

I'm trying to understand arrow notation, in particularly how it works with Monads. With Monads I can define the following: f = (*2) g = Just 5 >>= (return . f) and g is Just 10 How do I do the above but using arrow notation?
Clinton
  • 22,361
  • 15
  • 67
  • 163
8
votes
2 answers

Why there isn't a Functor instance for Kleisli in Control.Arrow?

While trying to familiarize myself with Control.Arrow, I have noticed that the Kleisli newtype would seem to admit a Functor instance, something like: instance Monad m => Functor (Kleisli m a) where fmap f (Kleisli k) = Kleisli $ liftM f . k Is…
danidiaz
  • 26,936
  • 4
  • 45
  • 95
8
votes
5 answers

Can I map the first element of a pair without arrows?

I'm eyeing functors, applicative functors… I'm not sure how to get where I want, but I have the feeling that following the types should get me closer. Is there a simple way to make a map-alike which only applies to the first element of a 2-tuple?…
Asherah
  • 18,948
  • 5
  • 53
  • 72
7
votes
2 answers

Haskell Arrows inside Tuples

I want to crate a tuple, that holds an arrow and a string that describes the arrow. If i do so with functions (instead of arrows), the following works like expected: funTimes10 = (*10) describe10 = "times 10" tuple10 :: (Num b) => ((b -> b),…
frosch03
  • 719
  • 4
  • 13
7
votes
1 answer

Are there monads that can be used like an automaton?

I'm writing a stream transformer from some Input data type to an Output data type. Input is made by the user, so there is some time between the events. Because each input requires some resource loading, I'd like to "look into the future", i.e. send…
Duschvorhang
  • 361
  • 1
  • 8
7
votes
1 answer

Why does mutual yielding make ArrowApply and Monads equivalent, unlike Arrow and Applicative?

Here's the SO post I'm going to refer to. Also, I'm going to use the same snippets as the OP in that question in order not to separate the materials. It is widely known that an ArrowApply instance yields a Monad and vice versa: newtype ArrowMonad a…
Zhiltsoff Igor
  • 1,812
  • 8
  • 24