« first day (174 days earlier)      last day (287 days later) » 

10:19 AM
Prelude> let b = fmap (\f -> f 9)
Prelude> :t b
b :: (Num a, Functor f) => f (a -> b) -> f b
 
@zinking hi :)
 
Prelude Control.Applicative> :t b id
b id :: Num a => (a -> b) -> b
Hi Bartek
I can't understand why apply id changed the signature into this
id is neither applied as the first argument nor the second one
 
@zinking hm, interesting
function instance of Applicative might be the answer here
Consider it written as such:
f (a -> b) -> f b
f (a -> b) -> ((a -> b) -> b)
and substituting first f
hmm
might be clearer if written in prefix form
@zinking I'd ask that on SO :)
Okey, I think I got it.
(a -> b) -> b is an instance of Functor b, as ((->) (a->b) b)
so, taking b away, we get that ((->) (a->b)) is instance of Functor in general
thus, ((a->b) -> (a->b)) -> ((a->b) -> b)
reduces to ((a->b) -> b) when applied with first argument
I hope I made that clearer @zinking :S
And obviously id fits ((a->b) -> (a->b)), because if you substitute u for (a->b), you get u -> u
 
 
2 hours later…
12:43 PM
@BartekBanachewicz , sounds pretty tough to understand.
cannot grasp this immediately.
 
@zinking well, where did this come from?
the short answer to your question is that f b is the same as (a -> b) -> b
 
I was reading the chapter 'aplicative functor???' and I came up with this example
generally I had problem understanding the fmap arg type substitutions
 
functions as functors are a bit weird admittedly
 
(a -> b) -> b is an instance of Functor b, as ((->) (a->b) b) // so how is this related with the function? I defined let b = fmap (\f -> f 9)
b :: (Num a, Functor f) => f (a -> b) -> f b // my function is really about mapping 1 functor to another.
and regarding ask this question on SO, I don't even know how to name this scenario properly
 
@zinking functions are Functors
@zinking yes, but since you used id, you narrowed it to function functors.
 
12:50 PM
functions are functors ??? so no difference between f a -> f b and a->b ?
 
@zinking there is a difference. All functions are functors, but not all functors are functions.
you keep thinking this f magically disappeared; it didn't. It's a coincidence the signatures look as if it did
2 hours ago, by Bartek Banachewicz
f (a -> b) -> f b
f (a -> b) -> ((a -> b) -> b)
 
I some what catch your point now.
seems the most difficult part for me is why you can substitute f with ( a->b ) ->
 
@zinking because function a -> b is a shorthand for ((->) a b)
it's an infix type constructor
 
1:05 PM
so where is the functor f, you didn't even mention f
f ( a-> b ) -> f b // let me try to interpret: a function takes a functor ( which is a function a -> b ) and returns a functor b
 
@zinking no.
this function
    takes a functor returning
        a function taking "a" and returning "b"
    and returns
        a functor returning "b"
IOW takes Functor (a->b) and returns Functor b
 
then I still don't understand how the substitution works. like why not ( b->(a->b) )-> f b
is that because fmap is left associative ?
 
1:22 PM
@zinking what substitution?
 ((a->b) -> (a->b)) -> ((a->b) -> b)
 f (a->b)           -> f b
this is how f is narrowed ^
 
:19928016
f (a -> b) -> f b
f (a -> b) -> ((a -> b) -> b)
and substituting first f
you are substituting the second functor
 
@zinking Yeah sorry I meant "second" there
anyway the message above substitutes both
f = ((a->b) ->)
 
so if it is in the case of : f (a->b) -> f( c->d ), apply the substitute you mentioned
we get 2 scenarios ?
like ( a->b )->(a->b) -> ( (a->b) -> (c->d) )
and probably start from right ?
 
well you could do that
but as you can see it's not very intuitive
if you just want to learn about Functors, look at more reasonable instances, like Maybe or []
 
I see , probably missing some basics here.
 

« first day (174 days earlier)      last day (287 days later) »