<     May 2017     >
Su Mo Tu We Th Fr Sa  
    1  2  3  4  5  6  
 7  8  9 10 11 12 13  
14 15 16 17 18 19 20  
21 22 23 24 25 26 27  
28 29 30 31
00:03 takle joined
00:03 dobson joined
00:08 malaclyps joined
00:11 takle joined
00:19 takle joined
00:26 takle joined
00:28 kadoban_ joined
00:29 Deide joined
00:30 uglyfigurine joined
00:31 juanpaucar joined
00:38 bumpkin joined
00:40 uglyfigurine joined
00:43 Rodya_ joined
00:47 takle joined
00:48 vaibhavsagar joined
00:49 uglyfigurine joined
01:02 uglyfigurine joined
01:08 conal joined
01:13 bumpkin joined
01:20 takle joined
01:35 juanpaucar joined
01:37 takle joined
01:44 takle joined
01:45 Rodya_ joined
01:48 uglyfigurine joined
01:52 Youmu joined
01:54 louispan joined
01:54 takle joined
01:57 louispan joined
01:57 uglyfigurine joined
01:59 saussure joined
01:59 saussure joined
02:02 cschneid_ joined
02:03 cschneid_ joined
02:10 takle joined
02:10 erisco joined
02:16 saussure joined
02:21 ljc joined
02:23 argent0 joined
02:23 exferenceBot joined
02:26 takle joined
02:28 hexagoxel joined
02:29 uglyfigurine joined
02:38 takle joined
02:39 juanpaucar joined
02:43 uglyfigurine joined
02:46 Rodya_ joined
02:47 kritzcreek joined
02:52 takle joined
03:03 louispan joined
03:04 saussure joined
03:13 saussure joined
03:20 takle joined
03:27 condy joined
03:31 malaclyps joined
03:43 juanpaucar joined
03:46 Rodya_ joined
03:50 prophile joined
03:54 malaclyps joined
04:04 saussure joined
04:13 takle joined
04:27 condy joined
04:30 louispan joined
04:32 takle joined
04:39 takle joined
04:39 mtg joined
04:44 nullcone joined
04:46 systemfault joined
04:47 takle joined
04:47 Rodya_ joined
04:47 juanpaucar joined
04:58 takle joined
05:01 blissdev joined
05:20 Kuros` joined
05:23 mstruebing joined
05:24 meandi_2 joined
05:24 takle joined
05:39 takle joined
05:41 nickager joined
05:48 Rodya_ joined
05:52 juanpaucar joined
05:55 takle joined
06:03 takle joined
06:11 nomotif joined
06:25 takle joined
06:40 mattyw joined
06:40 takle joined
06:49 Rodya_ joined
06:52 juanpaucar joined
06:53 takle joined
06:55 haskelleksah joined
07:08 bvad joined
07:10 Gloomy joined
07:10 takle joined
07:14 Gurkenglas joined
07:16 ali_bush joined
07:16 ali_bush joined
07:17 Pupnik joined
07:18 merijn joined
07:19 juanpaucar joined
07:28 takle joined
07:28 nickager joined
07:28 malaclyps joined
07:35 not_on_fp joined
07:35 takle joined
07:36 Levex joined
07:42 takle joined
07:45 grayjoc joined
07:49 takle joined
07:49 Rodya_ joined
07:51 zero_byte joined
07:53 zacts joined
08:04 nickolay_ joined
08:06 Orion3k joined
08:08 thc202 joined
08:14 alqatari joined
08:16 Iceland_jack joined
08:21 grdryn joined
08:23 juanpaucar joined
08:33 nacon joined
08:33 nacon joined
08:51 shayan_ joined
08:51 Rodya_ joined
08:59 takle joined
09:00 yellowj joined
09:03 Levex joined
09:06 pie_ joined
09:06 takle joined
09:10 takle_ joined
09:11 prophile joined
09:12 takle joined
09:12 grizwako joined
09:13 takle joined
09:14 louispan joined
09:25 qu1j0t3 joined
09:25 louispan joined
09:26 juanpaucar joined
09:39 kritzcreek joined
09:40 netheranthem joined
09:45 qu1j0t3 joined
09:53 Rodya_ joined
09:57 Orion3k joined
09:57 fotonzade joined
09:59 harfangk joined
10:04 romank joined
10:05 yellowj joined
10:06 takle joined
10:08 louispan joined
10:13 pie_ joined
10:17 Tene joined
10:17 Tene joined
10:28 takle joined
10:30 juanpaucar joined
10:36 Levex joined
10:40 louispan joined
10:50 madjestic joined
10:53 dni-_ joined
11:00 <romank> Hi guys, I'm trying to understand applicative functors, probably someone knows good exercises with growing complexity from beginner lever to higher one to try them in practice? Typeclassopedia have good description of that concepts but lacks practical excercises
11:01 <Iceland_jack> do you know Functors?
11:01 <tuturto> romank: I had good luck with: http://www.seas.upenn.edu/~cis194/spring13/lectures.html
11:01 <tuturto> week 9 and forward
11:02 <romank> yep, i feel pretty comfortable with functors at that point, but applicatives are still vague for me
11:03 mattyw joined
11:04 <Iceland_jack> It may be good to think of it like this
11:04 <Iceland_jack> Functor lets you lift (a -> b) to (F a -> F b)
11:04 <Iceland_jack> Applicative lets you lift a single (a) to (F a)
11:04 <Iceland_jack> and a binary function (a -> b -> c) to (F a -> F b -> F c) and more
11:05 mattyw__ joined
11:05 <Iceland_jack> :t pure :: a -> IO a
11:05 <lambdabot> a -> IO a
11:05 <Iceland_jack> :t fmap :: (a -> b) -> (IO a -> IO b)
11:05 <lambdabot> (a -> b) -> IO a -> IO b
11:05 <Iceland_jack> :t liftA2 :: (a -> b -> c) -> (IO a -> IO b -> IO c)
11:05 <lambdabot> (a -> b -> c) -> IO a -> IO b -> IO c
11:05 <Iceland_jack> :t liftA3 :: (a -> b -> c -> d) -> (IO a -> IO b -> IO c -> IO d)
11:05 <lambdabot> (a -> b -> c -> d) -> IO a -> IO b -> IO c -> IO d
11:12 fotonzade joined
11:17 mattyw joined
11:18 Levex joined
11:20 <romank> Thank you guys, now i have to reados about all of the above
11:21 <romank> *reason
11:22 takle joined
11:33 yellowj joined
11:34 juanpaucar joined
11:36 Levex joined
11:37 takle joined
11:37 pbrant joined
11:43 mattyw joined
11:49 chlong joined
11:59 Levex joined
12:07 TCZ joined
12:10 Gloomy joined
12:12 Gurkenglas joined
12:12 takle joined
12:26 fotonzade joined
12:35 carlomagno1 joined
12:38 juanpaucar joined
12:39 fotonzade joined
12:42 eacameron joined
12:43 takle joined
12:43 takle_ joined
12:44 saussure joined
12:48 Gloomy joined
12:55 jathan joined
13:01 juanpaucar joined
13:02 mtg joined
13:06 exferenceBot joined
13:08 mengu joined
13:11 Dance joined
13:17 iAmerikan joined
13:28 takle joined
13:37 saussure joined
13:38 saussure joined
13:42 kritzcreek joined
13:44 harfangk joined
13:46 bumpkin joined
13:56 Rodya_ joined
14:00 erisco joined
14:04 takle joined
14:05 juanpaucar joined
14:22 fotonzade joined
14:23 juanpaucar joined
14:31 Gloomy joined
14:45 Levex joined
14:45 takle joined
14:50 saussure joined
14:51 mengu joined
14:51 aarvar joined
14:53 saussure joined
14:54 uglyfigurine joined
14:56 saussure joined
14:56 Rodya_ joined
14:57 davenpcm joined
14:58 Levex joined
15:03 takle joined
15:04 Computist joined
15:04 argent0 joined
15:05 juanpaucar joined
15:06 takle joined
15:07 juanpaucar joined
15:09 Rodya_ joined
15:12 juanpaucar joined
15:24 tusj joined
15:24 conal joined
15:25 cschneid_ joined
15:25 <WarmCookie> (a -> b) -> (f a -> f b)
15:25 <WarmCookie> f (a -> b) -> (f a -> f b)
15:27 mtg joined
15:28 <Iceland_jack> If F is an Applicative functor, you can get from (a -> b) to (F a -> F b) in two ways
15:29 <Iceland_jack> Using (<*>): (a -> b) becomes (F a -> F b)
15:29 <Iceland_jack> sorry
15:29 <Iceland_jack> using fmap
15:29 <Iceland_jack> or using pure and then (<*>): (a -> b) becomes F (a -> b) becomes (F a -> F b)
15:29 <Iceland_jack> fmap f xs = pure f <*> xs
15:31 <WarmCookie> fmap (+1) -- Here you're lifting this increment transformation to work on functors.
15:32 <WarmCookie> ap (Just (+1)) -- Here you'll be applying this increment transformation that's already in some functor, to other functors (of the same type).
15:32 <WarmCookie> > fmap (+1) (Just 42)
15:32 <lambdabot> Just 43
15:32 <WarmCookie> > Just (+1) <*> Just 42
15:32 <lambdabot> Just 43
15:33 <WarmCookie> romank: You goal is to reach the Eureka moment when you realise that Applicative stands for Applicative Functors, functors whose values can be applied to other functors.
15:36 <Iceland_jack> Also look at equivalent formulations, like the ((lax) monoidal) formulation blog.ezyang.com/2012/08/applicative-functors/
15:36 <WarmCookie> Here are examples with the [] functor:
15:36 <WarmCookie> > (+1) <$> [1,2,3]
15:36 <lambdabot> [2,3,4]
15:37 <WarmCookie> > [(+1),(*10)] <*> [1,2,3]
15:37 <lambdabot> [2,3,4,10,20,30]
15:37 <Iceland_jack> instead of the (closed) formulation, preserving function types — F (a -> b) -> (F a -> F b)
15:38 <WarmCookie> This one is usually easier to work with; people are used to lists more than `Maybe a` :P
15:38 simendsjo joined
15:42 <WarmCookie> romank: You could probably invent Applicatives yourself if asked the right question. (Actually, maybe even stumble to something close to monoids and monads indirectly).
15:43 chlong joined
15:48 <WarmCookie> romank: The question being: Given that Functors let you lift a regular function (a -> b) to work with such functor (f a -> f b), how would you work with a regular function that's inside some functor? We cannot remove the functor, so we invent two operations:
15:48 <WarmCookie> (1) Lifting other things inside the functor.
15:48 <WarmCookie> (2) Function application _within_ such functor.
15:50 <WarmCookie> pure :: a -> f a
15:50 <WarmCookie> pure ~ (a -> b) -> f (a -> b)
15:51 <WarmCookie> <*> :: f (a -> b) -> (f a -> f b)
15:51 <WarmCookie> romank: Let me know if you want to brainstorm with examples, I think it'd become more clear (:
16:00 alibabzo joined
16:03 <romank> what i've come to is trying to implement sequenceAL :: Applicative f => [f a] -> f [a]
16:03 <romank> and calling sequenceAL with [(+3),(+2),(+1)] results is a function expecting a context
16:03 <romank> this is where i'm stuch
16:03 <romank> stuck*
16:03 conal joined
16:04 <romank> as far as I understand pure [] in this case is wrapped with ((->) r) context
16:04 <romank> but i'm a bit confused of how haskell knows in which context to use when calling pure
16:05 <romank> sequenceAL :: Applicative f => [f a] -> f [a]
16:05 <romank> sequenceAL [] = pure []
16:05 <romank> sequenceAL (x:xs) = ((fmap (:) x) <*>) (sequenceAL xs)
16:05 <romank> this is an implementation i'm working on right now
16:08 <romank> still can't fully understand it
16:09 <WarmCookie> Mhh, this seems a little beyond <*>.
16:09 <romank> seems like calling sequence with a list of partially applied functions results in something like sequenceAL [(+3),(+2),(+1)] == \a -> [(a + 3), (a + 2), (a + 1)]
16:09 <WarmCookie> Just to be sure we're on the same page:
16:09 <WarmCookie> :: Applicative f => [f a] -> f [a]
16:10 <WarmCookie> That's a list of applicatives received as inputs and an applicative as output.
16:10 <WarmCookie> So there's a sequence or some flattening going on.
16:10 <WarmCookie> Let's see what you have so far c:
16:11 malaclyps joined
16:11 uglyfigurine joined
16:11 <WarmCookie> An empty list as input should probably produce an empty list as output, and we must list that with `pure` to keep it in the applicative `f`, that looks fine.
16:12 <WarmCookie> We can clarify pure after :P
16:12 <WarmCookie> *lift that
16:12 Levex joined
16:12 <WarmCookie> The second one... mhhh...
16:14 <WarmCookie> It takes an element `x`, which is going to be an applicative of type `f a`, then we lift concatenation with `fmap (:)` so now you have the function (x:) inside an applicative `f`.
16:16 <WarmCookie> So our left side is an applicative of the function (x:) and our right side is going to be more applicatives from a recursive usage, of type `f [a]`.
16:16 <WarmCookie> Looks good to me.
16:16 uglyfigurine joined
16:16 <WarmCookie> This defers the implementation of the functor to fmap, which is totally fine.
16:16 <WarmCookie> class Functor f => Applicative f
16:17 <WarmCookie> You can remove a little bit of redundant syntax though.
16:17 <romank> sequenceAL (x:xs) = (:) <$> x <*> sequenceAL xs
16:18 <romank> still have one thing unclear
16:18 <romank> given a signature sequenceAL :: Applicative f => [f a] -> f [a]
16:18 <WarmCookie> sequenceAL (x:xs) = fmap (:) x <*> sequenceAL xs
16:18 peterbecich joined
16:18 <Iceland_jack> romank: I would urge implementing 'liftA2' in terms of Applicative, before attempting sequenceA
16:18 <WarmCookie> sequenceAL (x:xs) = (:) <$> x <*> sequenceAL xs
16:19 <WarmCookie> :t liftA2 (:)
16:19 <lambdabot> Applicative f => f a -> f [a] -> f [a]
16:19 <romank> if we consider the following code: sequenceAL [(+3),(+2),(+1)]
16:19 <romank> sequenceAL [(+3),(+2),(+1)] 3
16:20 <romank> it results in [6,5,4]
16:20 <Iceland_jack> romank: You're attempting difficult problems :)
16:20 Gloomy joined
16:20 <romank> the first argument to a function is ok since it fits the declaration, [f a] which is [(->) r]
16:21 <Iceland_jack> This should be simpler than using the ((->) _) Applicative
16:21 <Iceland_jack> > sequenceA [Just 1, Just 2, Just 3]
16:21 <lambdabot> Just [1,2,3]
16:21 <romank> but the signature says the function returns a f [a]
16:21 <romank> this blows my mind
16:21 <Iceland_jack> ((->) _) is a common hurdle
16:21 <Iceland_jack> :t sequence
16:21 <romank> since [6,5,4] is already an applicative itself
16:21 <lambdabot> (Monad m, Traversable t) => t (m a) -> m (t a)
16:21 peterbecich joined
16:21 <ski> sequenceAL :: [rho -> a] -> (rho -> [a]) -- in your case
16:21 uglyfigurine joined
16:22 <Iceland_jack> Prelude> :t sequenceA @[]
16:22 <Iceland_jack> sequenceA @[] :: Applicative f => [f a] -> f [a]
16:22 <Iceland_jack> Prelude> :t sequenceA @[] @((->) _)
16:22 <Iceland_jack> sequenceA @[] @((->) _) :: [t -> a] -> t -> [a]
16:22 <ski> `(rho ->)' here is your `f'
16:22 <WarmCookie> Oh I'm a little off here, this shouldn't type check.
16:23 <* WarmCookie> burns
16:23 <ski> @src liftA2
16:23 <lambdabot> liftA2 f a b = f <$> a <*> b
16:28 <romank> hm...
16:28 erisco joined
16:29 <Iceland_jack> romank: it follows a very nice pattern
16:30 <Iceland_jack> fmap f a = pure f <*> a
16:30 <Iceland_jack> liftA2 f a b = pure f <*> a <*> b
16:30 <Iceland_jack> liftA3 f a b c = pure f <*> a <*> b <*> c
16:31 <Iceland_jack> romank: You can think of "pure" as liftA0
16:31 <ski> `pure' could be called `liftA0' and `fmap' `liftA1'
16:31 <Iceland_jack> and fmap as liftA1, liftA
16:31 <* ski> grins
16:32 <romank> :t liftA2
16:32 <lambdabot> Applicative f => (a -> b -> c) -> f a -> f b -> f c
16:32 <ski> @type fmap
16:32 <lambdabot> Functor f => (a -> b) -> f a -> f b
16:32 <ski> @type pure
16:32 <lambdabot> Applicative f => a -> f a
16:33 <Iceland_jack> romank: You should think of it as transforming functions, I usually write it with redundant parens: liftA2 :: ... => (a -> b -> c) -> (f a -> f b -> f c) because it is transforming/lifting the binary function (a -> b -> c) to the binary function (f a -> f b -> f c)
16:33 <Iceland_jack> same with fmap/liftA3/..
16:36 <romank> ohhh, i'm starting to get it
16:41 merijn joined
16:43 permegreen joined
16:43 <WarmCookie> (+1) <$> [42]
16:43 <WarmCookie> pure (+1) <*> [42]
16:44 saussure joined
16:45 <WarmCookie> (+) <$> [1] <*> [42]
16:45 <WarmCookie> liftA2 (+) [1] [42]
16:46 <WarmCookie> All these things work c:
16:46 MarcelineVQ joined
16:46 <romank> :t liftA2 (+)
16:46 <lambdabot> (Num c, Applicative f) => f c -> f c -> f c
16:46 <WarmCookie> :t (+)
16:46 <lambdabot> Num a => a -> a -> a
16:48 <WarmCookie> romank: Have you see Maybe ?
16:48 <WarmCookie> *seen
16:48 <romank> i have
16:48 <romank> :t liftA2 (liftA2)
16:48 <lambdabot> (Applicative f, Applicative f1) => f1 (a -> b -> c) -> f1 (f a) -> f1 (f b -> f c)
16:48 <WarmCookie> romank: What do I get if I do (+) <$> Just 42 ?
16:48 <romank> a function expecting another Maybe
16:48 uglyfigurine joined
16:48 <WarmCookie> Slightly more than that.
16:49 <romank> :t (+) <$> Just 42
16:49 <lambdabot> Num a => Maybe (a -> a)
16:50 <WarmCookie> You were presented so far with the view of functors and applicatives as lifting functions; I have more or less an alternative approach if you're willing to give that a try.
16:50 <WarmCookie> romank: Yeah it's not a function expecting a Maybe, but instead, Maybe a function.
16:51 juanpaucar joined
16:52 monkeysee joined
16:53 <WarmCookie> I'm only suggesting it because the `lifting` idea was really abstract to me when I started. I had no idea functors were morphisms.
16:53 <monkeysee> Hi, just started with Haskell - quick question about Stack
16:53 juanpaucar joined
16:53 <monkeysee> are local GHC installations made for each new project?
16:53 uglyfigu_ joined
16:53 <monkeysee> if so, aren't there space concerns? How does Stack handle using one such installation for multiple projects?
16:53 <WarmCookie> romank: fmap :: (a -> b) -> f a -> f b -- A different take, would you agree this is applying a transformation function of type `(a -> b)` on a functor value of type `f a` resulting in something of type `f b` ?
16:54 <WarmCookie> romank: Thus, preserving the functor `f` but transforming `a` to `b` with the help of that transformation function?
16:55 <romank> yes, that's what is does
16:55 <WarmCookie> If I specialize it for the Maybe functor: fmap :: (a -> b) -> Maybe a -> Maybe b
16:55 <WarmCookie> If I specialize it for the [] functor: fmap :: (a -> b) -> [a] -> [b]
16:55 <WarmCookie> Cool, let's build up :)
16:56 <WarmCookie> romank: This implies that once information is placed within a functor, one cannot extract that information from it.
16:56 <WarmCookie> romank: You may transform what's inside of the functor, but the structure of the structure itself cannot change.
16:56 pilne joined
16:57 <WarmCookie> For example, you can transform all the elements of a list by increment them by 1, but you'll still have the same amount of elements in the end.
16:57 <WarmCookie> *structure of the functor
16:58 <romank> > (+) <$> Just 42 <*> pure 42
16:58 <lambdabot> Just 84
16:59 <romank> that is exactly what an fmap does over a functor
16:59 <WarmCookie> romank: Where I'm headed next is that, `(+) <$> Just 42`, leads to applying (+) on 42, which gives you (42+), but you cannot discard the `Maybe` functor that is `Just` here.
17:00 <romank> so the 42+ is wrapped inside a Maybe
17:00 <WarmCookie> You end up with `Just (42+)`. Correct.
17:00 <WarmCookie> Which leads to my next question, how do you apply `Just (42+)` on `0` ?
17:00 <WarmCookie> If it was merely a function, applying on 0 would be trivial.
17:01 <WarmCookie> But we do not have a function, we have Maybe a function, and we have a 0 for sure.
17:01 <WarmCookie> As you know now, that's applicative.
17:01 <WarmCookie> Just (42+) <*> pure 0
17:01 haskelleksah joined
17:01 <WarmCookie> Just (42+) <*> Just 0
17:02 <WarmCookie> romank: Do you see how it's just function application within a functor? The Maybe functor?
17:04 <WarmCookie> romank: Me using `Just 0` or `pure 0` is identical, all it bring that `0` value inside the functor and `pure` provides a very general way of doing this for every functors (because every functors implement what it means for them).
17:05 <WarmCookie> pure x = [x] -- For lists
17:05 <WarmCookie> pure x = Just x -- For maybe
17:05 <WarmCookie> etc..
17:05 juanpaucar joined
17:05 <romank> now it's clear for simple types
17:06 <romank> and what about (-> r)
17:06 <romank> as far as i can see it's also an applicative hence a functor
17:06 saussure joined
17:06 <WarmCookie> romank: I'm assuming you mean ((->) r) ?
17:06 <romank> yes
17:08 <WarmCookie> Does it helps if I say this is a partially applied function?
17:08 <Iceland_jack> "romank: This implies that once information is placed within a functor, one cannot extract that information from it." you should be clear, "using the Functor methods"
17:08 <WarmCookie> Right.
17:09 <Iceland_jack> romank: Before I leave work :) writing ((->) r) as a section would be (r ->)
17:09 <WarmCookie> Unfortunately, the instance declaration syntax doesn't let us do sections like that :(
17:10 <WarmCookie> type PartApplFunc r = ((->) r)
17:10 <Iceland_jack> WarmCookie: implement it ;) https://ghc.haskell.org/trac/ghc/ticket/12477
17:10 <WarmCookie> fmap :: (a -> b) -> f a -> f b
17:11 <WarmCookie> fmap :: (a -> b) -> ((->) r) a -> ((->) r) b
17:11 <WarmCookie> fmap :: (a -> b) -> (r -> a) -> (r -> b)
17:11 <WarmCookie> romank: Still with me ?
17:11 <romank> yes
17:11 <romank> looks like composition
17:11 <WarmCookie> That's because it is.
17:11 <WarmCookie> :)
17:11 <Iceland_jack> great observation romank
17:12 <WarmCookie> instance Functor ((->) r) where fmap = (.)
17:12 <WarmCookie> > fmap (+1) (*2) 5
17:12 <lambdabot> 11
17:12 <Iceland_jack> Viewing composition through the lens of 'fmap', it changes the 'output' of a function just like map changes the 'output values' of a list
17:12 <Iceland_jack> afk
17:13 <romank> now it's much more clear
17:13 <WarmCookie> romank: If we keep our analogy, we have have some functor (which is a partially apply function), we transform our partially applied function by adding a transformation to it, resulting in a new partially applied function.
17:14 <WarmCookie> The context is preserved (still a partial function), but the guts (the function implementation) is doing more things now.
17:14 <romank> so since the functions are curried the initial context stays preserved during that transformation
17:15 <WarmCookie> Well, let's continue with applicatives if you're curious.
17:16 <WarmCookie> <*> :: f (a -> b) -> f a -> f b
17:16 <romank> sure :)
17:16 <WarmCookie> <*> :: ((->) r) (a -> b) -> ((->) r) a -> ((->) r) b
17:16 <WarmCookie> <*> :: (r -> a -> b) -> (r -> a) -> (r -> b)
17:19 <romank> how this can be put into an example of code?
17:21 <WarmCookie> Given a transformation function `a -> b` that also happens to take an extra argument `r` and a partial function that has yet to know its partial value `r`, we obtain a partial function that has yet to know it's `r` value but can produce `b`.
17:21 <WarmCookie> Mhh, let me try. Honestly I don't use that one very often, but the monad one is really awesome.
17:22 uam joined
17:22 takle joined
17:23 <WarmCookie> Essentially you're working with (\r -> (+r)), a partial function whose's partiality is still unknown.
17:23 <WarmCookie> Assuming we're using (+) for our example but yeah.
17:24 <WarmCookie> :t (\r a b -> a + b * c) <*> (\r -> (+r))
17:24 <lambdabot> error:
17:24 <lambdabot> • Couldn't match type ‘t -> t’ with ‘Expr’
17:24 <lambdabot> Expected type: t -> Expr
17:24 <WarmCookie> Whoops
17:25 <romank> I can see how (r ->) can be replaced with other instances of Applicative
17:25 <romank> > (Just (*2)) <*> (Just 7)
17:25 <lambdabot> Just 14
17:26 juanpaucar joined
17:27 <WarmCookie> > do { x <- (+2); y <- (+1); return (x * y) } 42
17:27 <lambdabot> <hint>:1:45: error: parse error on input ‘42’
17:28 <WarmCookie> > (do { x <- (+2); y <- (+1); return (x * y) }) 42
17:28 <lambdabot> 1892
17:28 <WarmCookie> That's the monad one, it's easier to visualize for me. It will help me backtrack :P
17:29 <WarmCookie> So here, 42 is given to fullfill the first partial function, then it's given again to fullfill the other partial function.
17:29 <romank> :t ((\r a -> a * r) <*> (\r -> r ^ r))
17:29 <lambdabot> Integral a => a -> a
17:29 <WarmCookie> So we get x is 44 and y is 42.
17:29 <romank> > ((\r a -> a * r) <*> (\r -> r ^ r)) 5
17:29 <lambdabot> 15625
17:29 <WarmCookie> There you go.
17:30 <WarmCookie> So you obtain a function whose result is the composition of two partial function that'll receive this `5`.
17:30 <MarcelineVQ> WarmCookie: what do you mean by partial function and partiality?
17:30 <WarmCookie> Which is why ((->) r) is often called Reader.
17:30 <WarmCookie> MarcelineVQ: ((->) r) is a partially applied function.
17:30 <WarmCookie> You're working with partial functions all along.
17:31 <romank> i assume partially applied function is expecting missing arguments to be computable
17:31 <srhb> It's partially a function, but it's neither a partial function or a partially applied function.
17:31 <MarcelineVQ> ah okay, I ask because typically a partial function is a function that is not a total function, partially applied is something a little different
17:31 <geekosaur> where total function means always produces a non-bottom result for non-bottom parameters
17:31 <WarmCookie> MarcelineVQ: Oh yeah, sorry, haven't been watching my words really.
17:32 <srhb> (To be more clear, a -> b is a function, but (->) a is not by a normal definition, it has the wrong kind)
17:32 <WarmCookie> Just trying to untangle his confusion and not paying much attention to being pedantic.
17:32 <WarmCookie> My mistake.
17:32 <geekosaur> also, I'd argue that is partial application at type level
17:32 <MarcelineVQ> it's not something egregious but I wanted to check :>
17:32 <WarmCookie> geekosaur: Yes.
17:33 <MarcelineVQ> romank: you have the right idea about what WarmCookie was conveying by partial
17:33 <WarmCookie> I guess what I meant is that it has the type of a partially applied function, but in practice, this function has yet to receive the `r` that will make it partially applied.
17:34 <WarmCookie> It's not even applied yet.
17:35 <WarmCookie> Which is probably the whole strength of it. Once you get to see the monad, you end up with an implicit parameter applied to all the partial functions you'll be working with, it's neat.
17:35 <WarmCookie> romank: Such as a Config or similar :P
17:35 <romank> hope i will get to monads soon
17:35 <romank> there are not enough words in any language to describe by gratitude
17:35 <WarmCookie> Instead of passing it around to every function explicitely and risking that one function mutates it or whatever.
17:36 <WarmCookie> romank: ((->) r) takes a while to get used to :P
17:36 <WarmCookie> You're doing fine <3
17:36 <romank> sometimes i think one need a degree in calculus to understand that concepts
17:37 <romank> thank you very much guys, not i'm much more clear
17:37 <WarmCookie> romank: I'm not surprised you think that, but it's because we're not used to be presented with powerful abstractions. Also, the more powerful, the less it makes sense to you initially.
17:37 <WarmCookie> romank: Eventually, you start replacing everything you know by this abstract concept because it's more simpler and covers all the bases at once.
17:38 takle joined
17:38 <WarmCookie> romank: Literally all data structures in Haskell are functors (or at least could be). You can all apply a transformation to their elements easily.
17:39 <WarmCookie> > fmap (+1) [1..5]
17:39 <lambdabot> [2,3,4,5,6]
17:39 <WarmCookie> > fmap (+1) (Just 42)
17:39 <lambdabot> Just 43
17:39 <WarmCookie> > fmap (+1) (Right 42)
17:39 <lambdabot> Right 43
17:40 <WarmCookie> > fmap (+1) (M.fromList [("hello", 42")])
17:40 <lambdabot> <hint>:1:40: error:
17:40 <lambdabot> lexical error in string/character literal at end of input
17:40 <romank> :)
17:40 <romank> > fmap (+1) (M.fromList [("hello", "42")])
17:40 <lambdabot> error:
17:40 <lambdabot> • No instance for (Num [Char]) arising from an operator section
17:40 <lambdabot> • In the first argument of ‘fmap’, namely ‘(+ 1)’
17:40 <WarmCookie> > fmap (+1) (M.fromList [("hello", 42)])
17:40 <lambdabot> fromList [("hello",43)]
17:41 <WarmCookie> That's Map (a key value store)
17:41 <romank> > fmap (++"00") (M.fromList [("hello", "42")])
17:41 <lambdabot> fromList [("hello","4200")]
17:41 <WarmCookie> romank: In other languages, this would result in iterators, or templates or things that are specific to each type. Here we're able to implement functions that works for any functors!
17:41 <WarmCookie> Then it gets better, things like Traversable.
17:41 <WarmCookie> > length [1..5]
17:41 <lambdabot> 5
17:42 <WarmCookie> > length (Just 32)
17:42 <lambdabot> 1
17:42 <WarmCookie> etc.
17:42 <WarmCookie> It avoids a ridiculously amount of concepts and bundles them into re-usable general ideas (the promised land o: !)
17:43 <WarmCookie> romank: The biggest advantage is, when stumbling up on a new type from a library you haven't seen before, you can just look at the instances it has and you immediatly know what it does or how to use it).
17:44 <romank> yeah, thats the benefit of high level abstraction
17:44 nacon joined
17:44 nacon joined
17:45 <WarmCookie> romank: Functor I can transform it. Applicative I can apply it on other things like itself, Monoid I can merge it with other things like itself, Monad can sequence it, Ord it's orderable, Eq it's comparable, so on so forth.
17:46 <WarmCookie> romank: The cost of learning some of these abstractions pays back like 10 folds, and they generally aren't complicated, they just are, well, very general. Sometimes too general.
17:46 <WarmCookie> The most powerful one to my knowledge is Category.
17:47 <WarmCookie> Yet, you're using `(.)` and `id` all the time unknowingly :P
17:48 <WarmCookie> romank: Because yes, there's more general than identity functions and composition of functions. There's the identity of everything and the composition of everything.
17:48 <WarmCookie> Not just values, not just types, not just programs, not just entire fields of mathematics, not just entire ideas, it's goes really far.
17:49 <WarmCookie> https://hackage.haskell.org/package/base-4.9.1.0/docs/Control-Category.html
17:49 <WarmCookie> romank: And yet there it is x
17:49 <WarmCookie> few lines.
17:50 <romank> still a long way to get to it :)
17:50 <romank> i'm going to leave now
17:50 <WarmCookie> Granted Haskell's Category is quite limited, we have only a handful of instances. (->) and Kleisli mainly.
17:50 <WarmCookie> romank: bai bai!
17:50 <romank> WarmCookie thank you
17:50 Rodya_ joined
17:50 <WarmCookie> You're welcome. Please come see us again o:
17:51 <romank> btw, is there a place where chat log get persisted?
17:51 <WarmCookie> http://www.irclogger.com/.haskell-beginnerS/2017-05-18
17:52 <romank> thanks!
17:52 <romank> see you later
18:02 pranitbauva1997 joined
18:03 patbecich joined
18:03 taksuyu joined
18:06 iAmerikan joined
18:07 pie_ joined
18:12 haskelleksah joined
18:15 mac10688 joined
18:18 takle joined
18:23 uglyfigurine joined
18:28 grayjoc joined
18:29 grayjoc joined
18:30 grayjoc joined
18:30 malaclyps joined
18:31 grayjoc joined
18:35 mstruebing joined
18:41 yellowj joined
18:57 juanpauc_ joined
19:00 uglyfigurine joined
19:08 ralu joined
19:08 aporia joined
19:11 MotherFlojo joined
19:15 Iceland_jack joined
19:27 Iceland_jack joined
19:29 Iceland_jack joined
19:34 uglyfigurine joined
19:35 zacts joined
19:41 mstruebing joined
19:49 peterbecich joined
19:53 peterbecich joined
19:55 yellowj joined
19:58 MotherFlojo joined
19:58 juanpaucar joined
19:59 merijn joined
20:01 malaclyps joined
20:02 uglyfigurine joined
20:07 iAmerikan joined
20:08 madjestic joined
20:10 juanpaucar joined
20:13 uglyfigurine joined
20:14 juanpauc_ joined
20:20 kareeeeem joined
20:25 prophile joined
20:26 conal joined
20:26 argent0 joined
20:36 pranitbauva1997 joined
20:39 fotonzade joined
20:45 peterbecich joined
20:54 uglyfigurine joined
20:54 emmanuel_erc joined
20:56 zero_byte joined
20:58 conal joined
21:00 blissdev joined
21:08 iAmerikan joined
21:26 juanpaucar joined
21:31 albertus1 joined
21:31 nickolay_ joined
21:34 juanpaucar joined
21:36 Levex joined
21:42 trolling joined
21:46 erisco joined
21:47 saussure joined
21:47 MotherFlojo joined
21:54 hiratara joined
21:54 juanpaucar joined
22:07 juanpaucar joined
22:12 kadoban joined
22:13 malaclyps joined
22:15 mengu joined
22:20 crave joined
22:21 juanpaucar joined
22:23 malaclyps joined
22:26 juanpaucar joined
22:27 fotonzade joined
22:27 albertus1 joined
22:31 hiratara joined
22:40 takle_ joined
22:41 crave joined
22:41 prophile joined
22:51 matt__ joined
22:58 <_cyril_> What's the recommended library to deal with protobuf encoding/decoding in Haskell?
23:10 saussure joined
23:12 louispan joined
23:19 louispan joined
23:22 takle joined
23:29 takle joined
23:30 fotonzade joined
23:33 cschneid_ joined
23:34 Bhootrk_ joined
23:35 louispan joined
23:36 Gloomy joined
23:38 takle joined
23:39 Levex joined
23:42 Bhootrk_ joined
23:43 snowcrshd joined
23:46 takle joined
23:52 fotonzade joined
23:53 Bhootrk_ joined
23:54 peterbecich joined