Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I understand applicative vs monad style of programming, but most articles discuss this distinction with "simple" monads like Maybe.
But what about monads like Reader, Writer and State. Are there pracrical examples of using them in applicative way?
Every time you use the foo <$> bar <*> baz idom with monadic functions bar and baz, you are using a Monad in an applicative way. This is not a very deep use of Applicative, but rather a convenient way of writing a bit of code, and independent of the Monad – and hence you will find this style also for Reader, Writer and State.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
In Type Synonyms we read
Just like we can partially apply functions to get new functions, we can partially apply type parameters and get new type constructors from them.
How can a parameter be applied to something else? I think it should actually be
Just like we can partially apply functions to get new functions, we can partially apply type constructor (giving them less type parameters then they expect) and get new type constructors from them.
Do you agree?
The author seems to use apply to mean both "the function to the parameters" as well as "the parameters to the function".
Further down we read
we'll partially apply Either by feeding it only one parameter
Where the meaning is the former,
as well as
Let's apply the type parameter to Maybe and see what the kind of that type is.
ghci> :k Maybe Int
where the meaning is the latter.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 2 years ago.
Improve this question
I'm a math PhD student minoring in CS and currently taking a class in Haskell. We just learned about liftM.
The concepts seem similar but I haven't been able to figure out exactly how liftM can be thought of as a lift in the category-theoretical sense (I know very little category theory and was introduced to lifts in a Topology class).
Given the lack of activity -- and the lack of an obvious connection -- I think it's safe to say that liftM was not named because of its connection to topological and category-theoretic lifts.
Instead, I think the term "lift" has come to generically mean any transformation from one domain of reasoning to another, and it is this sense of "lift" that was the historical reason for the name liftM. Specifically: liftM transforms a pure function, "lift"ing it into the domain of a specific monad.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
The intuition of an optional type like Maybe Int is that either there is no Int (thus, there's Nothing there) or that there is some Int; there is something there.
It makes sense to me that we call the type constructor for the "negative" case Nothing, since it means exactly that -- that there's no Int there. But why use the word Just in the case where the emphasis is on something actually being there?
To me, the word "Just" carries the connotation that the thing it's describing is less than the alternative; the opposite of something actually being there; for example,
A: Are you doing anything tonight?
B: No; I'm just gonna stay in and watch TV.
A: Did you investigate the creepy ghost sounds around your house?
B: yeah, turns out it was actually just an owl.
Clearly I'm lacking whatever intuition this naming choice was based on. What is it? Because to me, the word Just means the opposite of how it's used in the Maybe type.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
Many techniques are used for this means, from as simple as Short Cut Fusion to elaborate Stream Fusion. I'm aware compilers such as GHC and MLTon rely considerably on this technique. Are there other compilers in existence that do so?
I think Clojure does fusion (on functions of sequences, not streams, because Rich Hickey cares more about optimizing and parallelizing strict computations on definite data, not stream processing indefinite/lazy data)
https://groups.google.com/forum/m/#!topic/clojure/EJ9hOZ8yaos
http://clojure.org/reducers
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 7 years ago.
Improve this question
Why is the function for lifting a value into a functor named pure in Control.Applicative?
Think of pure as an adjective.
foo <*> pure 4 = foo applied on a pure value 4.
(As for the exact reason why it's called pure, probably only McBride and Paterson will know.)
It's a little like fromInteger. Its argument is always a pure value or function that will be lifted into the functor. Perhaps it should have been fromPure but you know how Haskell people love to shorten names (e.g. fst and snd instead of first and second...).