applicative Questions

2

What's the simplest yet most elegant way to NOT short-circuit and instead collect errors until their values are used? What's so hard in accumulating errors? Short circuit only if a function call re...
Polytrophic asked 11/3, 2024 at 11:55

3

Solved

Control.Lens.Tutorial says: type Traversal' a b = forall f . Applicative f => (b -> f b) -> (a -> f a) type Lens' a b = forall f . Functor f => (b -> f b) -> (a -> f a) ...
Avulsion asked 21/2, 2024 at 14:5

6

I am getting into Haskell and found the book "learn you a Haskell" most helpful. I am up to the section on applicative functors. I am puzzled by the following as it appears in the book: (\x y z ...
Separator asked 27/1, 2014 at 8:31

1

Recall the Applicative class: class Functor f => Applicative f where pure :: a -> f a liftA2 :: (a -> b -> c) -> f a -> f b -> f c (<*>) :: f (a -> b) -> f a -&g...
Rybinsk asked 26/8, 2023 at 6:28

1

Solved

I'm looking at the These datatype from the these package, in particular at its Applicative instance: instance (Semigroup a) => Applicative (These a) where pure = That This a <*> _ = This...
Crying asked 24/6, 2023 at 10:32

2

I've been experimenting with monoids and Distributives lately, and I think I've found something of interest (described in my answer) - are these already known structures? (I've been unable to find ...

3

Solved

I'm playing around with formulating Applicative in terms of pure and liftA2 (so that (<*>) = liftA2 id becomes a derived combinator). I can think of a bunch of candidate laws, but I'm not su...
Hodges asked 12/3, 2015 at 18:32

2

Solved

I was kinda surprised when I read the source code of instances of Applicative Complex and Monad Complex from GHC Data.Complex module: -- | @since 4.9.0.0 instance Applicative Complex where pure a...
Stclair asked 8/11, 2017 at 13:32

7

Solved

I have 2 Optionals (or Maybe objects) that I would like to combine so that I get the following results: || first operand second ++-------------+------------- operand || empty | optional(x) ===...
Morpheme asked 17/6, 2022 at 20:38

4

Solved

I'm reading Graham Hutton book on Haskell, and don't no how to proceed in one part of an excercise. The excercise says as follows: Given the following type expressions data Expr a = Var a | Val I...
Jiggle asked 15/10, 2019 at 16:57

5

Time and again I read the term effectful, but I am still unable to give a clear definition of what it means. I assume the correct context is effectful computations, but I've also seen the term effe...
Uncinate asked 28/10, 2015 at 8:55

1

Solved

Java's CompletableFuture is a Monad given its methods thenCompose and thenApply, which correspond to >>= (bind) and fmap in Haskell. It is a well known fact that any Monad gives rise to an Ap...
Oshiro asked 15/1, 2022 at 18:58

2

Solved

What is the point of making Functor a super class of Applicative and Monad. Both Applicative and Monad immediately imply the only implementation of Functor that abides by the laws as far as I...
Hipster asked 2/1, 2022 at 7:7

1

Solved

I recently saw a simple example that brought <* and *> to light. validate :: String -> Maybe String validate s = if s=="" then Nothing else Just s >validate "a" *&g...
Jannery asked 10/12, 2021 at 13:20

1

Solved

Consider this type: data Vec3 = Vec3 {_x, _y, _z :: Int} I have some functions that all take the same input, and may fail to compute a field: data Input getX, getY, getZ :: Input -> Maybe Int ...
Maggot asked 7/12, 2021 at 11:28

7

Solved

I just read the following from typeclassopedia about the difference between Monad and Applicative. I can understand that there is no join in Applicative. But the following description looks vague t...
Alecalecia asked 28/4, 2014 at 13:17

2

I declared a group on applicative functors. Judging by what we usually call "actions", it seems that such group would enable the action to be undone: import Control.Applicative class Alt...
Frodeen asked 8/10, 2021 at 2:47

4

Solved

I am trying to implement Applicative instance for such a type: newtype State s a = State {runState :: s -> (a, s)} I have some different ideas for (<*>) function. One way to implement it ...
Brinkley asked 17/7, 2017 at 21:46

2

For the function monad I find that (<*>) and (>>=)/(=<<) have two strikingly similar types. In particular, (=<<) makes the similarity more apparent: (<*>) :: (r -> ...

7

Solved

Applicatives compose, monads don't. What does the above statement mean? And when is one preferable to other?

1

Solved

From the docs: (>>) : Sequentially compose two actions, discarding any value produced by the first (*>) : Sequence actions, discarding the value of the first argument. Both seem to me doin...
Adorno asked 31/3, 2021 at 9:14

2

Solved

For any Applicative instance, once <*> is written, pure is uniquely determined. Suppose you have pure1 and pure2, both of which obey the laws. Then pure2 f <*> pure1 y = pure1 ($ y) &lt...
Selfpity asked 9/3, 2021 at 22:9

1

The Monad typeclass can be defined in terms of return and (>>=). However, if we already have a Functor instance for some type constructor f, then this definition is sort of 'more than we need...

2

Solved

Spin off of this question. Intuitively I have understood what sequenceA does in that usecase, but not how/why it works like that. So it all boils down to this question: how does sequenceA work in t...
Ninurta asked 2/10, 2020 at 19:10

2

Solved

The language suggestion states that the advantages are detailed in the linked paper. I had a quick skim through and I can't see it spelled out explicitly. Is the advantage just that each statement ...
Luke asked 3/9, 2020 at 8:52

© 2022 - 2025 — McMap. All rights reserved.