<     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 _2_5 26 27  
28 29 30 31
00:09 ysgard joined
00:19 <Xion_> thang1: What if most of Haskell code looks to me this way? :)
00:23 mac10688 joined
00:24 dni- joined
00:43 ysgard joined
00:46 acarrico joined
00:49 louispan joined
00:51 Gurkenglas_ joined
00:53 <kadoban> Xion_: Hah, it will at first, but you learn the common ones you have to know and then it calms down.
00:54 cschneid_ joined
01:04 systemhalted joined
01:10 louispan joined
01:11 rstefanic joined
01:17 ridho joined
01:19 eacamero_ joined
01:21 Tene joined
01:26 malaclyps joined
01:33 <rstefanic> So I'm doing the chapter 10 exercises. One of the final ones is to write "maximumBy" using a fold. So this is what I got
01:33 <rstefanic> myMaximumBy = (\f -> (\(x:xs) -> foldl (\a b -> if f a b == GT then a else b) x xs))
01:33 <thang1> oh hey, that one
01:33 <rstefanic> But it wouldn't work if I used "foldr" instead of "foldl"
01:33 <rstefanic> why does it only properly evaluate with foldl and not foldr
01:33 <thang1> brb I'll pull my chapter 10 exercise file up
01:33 <rstefanic> awesome. I appreciate it
01:34 <rstefanic> I mean, I "got it" in the sense that when I ran the my version of it, I got the same answers as the Book's
01:34 <rstefanic> but I don't see how the foldr version of it wouldn't work.
01:35 <benzrf> rstefanic: does it typecheck with foldr?
01:35 <thang1> So are you trying to use foldr instead of foldl?
01:36 <thang1> myMaxBy f (x:xs) = foldl (\a as -> bool a as (f a as == LT)) x xs
01:36 <MarcelineVQ> hmm, both foldl and foldr can be dropped into that without a difference where f = compare
01:36 <thang1> That's what I wrote for mine.
01:37 <monochrom> @type foldl
01:37 <lambdabot> Foldable t => (b -> a -> b) -> b -> t a -> b
01:37 <monochrom> @type foldr
01:37 <lambdabot> Foldable t => (a -> b -> b) -> b -> t a -> b
01:37 <monochrom> pretty sure not a drop-in replacement.
01:37 <rstefanic> yes it does typecheck with foldr
01:38 <thang1> oooh, it'll typecheck with foldr because the signature of the myMaximumBy function is :: (Ord a) => (a -> a -> Ordering) -> [a] -> a
01:38 systemhalted joined
01:38 <thang1> so b -> a -> b and a -> b -> b should be the same in that case, right?
01:39 <rstefanic> That's what I thought
01:39 <rstefanic> But it doesn't :(
01:39 <monochrom> > \f -> (\(x:xs) -> foldl (\a b -> if f a b == GT then a else b) x xs)) compare [3,1,4,1,5]
01:39 <lambdabot> <hint>:1:69: error: parse error on input ‘)’
01:39 <benzrf> did you try swapping the arguments to the folding function
01:39 <monochrom> > (\f -> (\(x:xs) -> foldl (\a b -> if f a b == GT then a else b) x xs)) compare [3,1,4,1,5]
01:39 <lambdabot> 5
01:39 <monochrom> worksforme
01:40 <rstefanic> Since I'm using a function that does comparisons, it shouldn't matter if it's (a -> b -> b) or (b -> a -> b), right?
01:40 <rstefanic> I could try it with foldr and flip
01:40 <monochrom> Wrong reason.
01:40 <rstefanic> wrong reason?
01:40 <monochrom> Wrong reason.
01:40 <thang1> lol with my definition if I just straight replace foldl with foldr, the first testcase gives 2 not 1, the second testcase gives 1 not 10 and the third testcase works
01:41 <thang1> I believe the argument order should matter in this case because if you're testing, say, a < b, it'll behave differntly if you swap the order of the arguments
01:41 <monochrom> > (\f -> (\(x:xs) -> foldl (\a b -> if f a b == GT then a else b) x xs)) compare [3,1,4,1,5, 0]
01:42 <lambdabot> 5
01:42 systemhalted joined
01:42 <monochrom> Is there any counterexample?
01:43 <monochrom> thang1, for other functions, yes you may need to flip; but this one, it returns the greater of the two, so it doesn't matter who's from the left of the list and who's from the right.
01:44 <rstefanic> So I just tried writing it with foldr + flip
01:44 <thang1> > (\f -> (\(x:xs) -> foldl (\a b -> if f a b == GT then a else b) x xs)) compare [15,3,1,4,1,5,5] -- I think this'll break it...
01:44 <lambdabot> 15
01:44 <monochrom> worksforyoutoo
01:44 <rstefanic> myMaximumBy = (\f -> (\(x:xs) -> foldr (flip (\a b -> if f a b == GT then a else b)) x xs))
01:44 louispan joined
01:44 <thang1> monochrom: ah, okay
01:44 <rstefanic> But I get weird output like, with myMaximumBy (\_ _ -> LT) [1..10]
01:44 <rstefanic> I get 2
01:45 acarrico joined
01:45 <monochrom> (\_ _ -> LT) is a counterproductive thing to test with.
01:46 <thang1> monochrom: the book has 3 testcases. (\_ _ -> GT), (\_ _ -> LT), and compare
01:46 <MarcelineVQ> I beleive that's given as one of the testing functions, not sure without checking
01:46 <MarcelineVQ> in which case foldl fits the bill by the looks of it
01:47 <thang1> "myMaximumBy takes a comparison function and a list and returns the greatest element of the list based on the last value that the comparison returned GT for"
01:48 malaclyps joined
01:49 <monochrom> @src foldl1
01:49 <lambdabot> foldl1 f (x:xs) = foldl f x xs
01:49 <lambdabot> foldl1 _ [] = undefined
01:49 <monochrom> @src foldr1
01:49 <lambdabot> foldr1 _ [x] = x
01:49 <lambdabot> foldr1 f (x:xs) = f x (foldr1 f xs)
01:49 <lambdabot> foldr1 _ [] = undefined
01:50 <monochrom> You are probably better off with foldr1 instead of foldr and your own seeding.
01:50 <rstefanic> Yeah, I know. I'm just trying to see why foldr wouldn't work
01:50 <monochrom> Allow me to use ^ for your (\a b -> if f a b == GT then ...) OK?
01:50 <rstefanic> I might just try writing it out with foldr
01:51 <rstefanic> Okay.
01:51 <monochrom> Your foldl version is doing ((a^b)^c)^d, if the input list is [a,b,c,d], OK?
01:52 <monochrom> But your foldr version is not doing a^(b^(c^d)). It is doing b^(c^(d^a)). You coded it that way.
01:52 <rstefanic> Okay. I follow so far.
01:52 <rstefanic> Oh wait.
01:52 <rstefanic> So that would explain why I'm getting 2 for the (\_ _ -> LT) version
01:53 <monochrom> Now study the @src foldr1 above. See how/why it does a^(b^(c^d)) correctly.
01:53 cschneid_ joined
01:54 ysgard joined
01:58 <thang1> sweet, thanks
01:59 <thang1> it was bugging me forever trying to get that foldr to work. I finally left it and just moved on
01:59 takle joined
02:01 <rstefanic> is foldl1 missing a base case?
02:01 <thang1> The point of fold_1 is that they only work on non-empty structures
02:02 <monochrom> No, it calls foldl.
02:02 <thang1> oh whoops, nvm
02:02 <monochrom> whereas foldr1 calls foldr1 and never involves foldr
02:02 <rstefanic> Okay. I'm going to write out the function and see how it would evaluate
02:03 <thang1> They still only work on non-empty structures :p
02:04 <thang1> ಠ_ಠ I have no idea how I feel about writing = undefined to get rid of a lint error complaining about non exhaustive pattern matching
02:05 <monochrom> If you intend a partial function, I think it is a good idea, consider it self-documenting code.
02:05 <monochrom> But if you intend a total function, I think it is a bad idea, and I learned the reason from other people.
02:05 <MarcelineVQ> you might prefer an error message over undefined though
02:06 <monochrom> Suppose you have ADT "data X = A | B | C" and there is non-zero probability of adding more cases in the future.
02:06 <thang1> your data constructor better be total to make sure that things complain when you add a new case :)
02:06 <monochrom> And suppose you write "f A = 0; f B = 1; f _ = 2"
02:07 <MarcelineVQ> _ = unsafePerformIO maxVolSample "screamingWoman.wav" -- base case silencer
02:07 <monochrom> Then when you add D later, no one will warn you that "f _ = 2" is wrong.
02:08 <thang1> True. So you generally want to avoid f _ type of patterns as a way to make it total, then?
02:08 <monochrom> Yes.
02:08 carlomagno joined
02:08 <monochrom> But of course there are exceptions. "isA A = True; isA _ = False" is robust.
02:09 <thang1> Now in the case of myMaximumBy or myMinimumBy, the function is total if it can operate successfully on an empty list, list of one item, or list of n items
02:09 <thang1> but I have no idea how to do anything useful on an empty list because it expects a single value, not a list
02:09 <monochrom> RIght, it is meant to be a partial function.
02:09 <monochrom> Or you use a non-empty list type.
02:10 <thang1> "what's the largest nothing" -> nothing useful can come from answering that.
02:10 <monochrom> Or you use Maybe but it gets verbose.
02:11 <thang1> So part of me would prefer to not have the function explode if I send it an empty list, the other part of me hates using Maybe for things like this, and lastly another part of me would rather guarantee non-emptiness in the type (which is harder to do generically)
02:13 dni- joined
02:13 <monochrom> A non-empty container is simply a tuple of a datum and a may-empty container.
02:14 <monochrom> In terms of passing it to functions, it is equivalent to simply passing two parameters, the datum and the may-empty container.
02:14 <thang1> where the datum is the default value?
02:15 <monochrom> Yes. Or, equivalently, witness of non-emptiness.
02:15 <monochrom> May as well use the witness as seed/default.
02:15 <thang1> Ah, okay. So a list [1..10] could be alternatively written as (1,[2..10]) as a "non empty" container?
02:15 takle joined
02:15 <monochrom> Yes.
02:15 <monochrom> It's how NonEmpty does it.
02:16 <thang1> got it, that makes sense. Guess I was overcomplicating things in my head :p
02:16 <monochrom> "data NonEmpty a = a :| [a]" from Data.List.NonEmpty
02:17 <monochrom> tuple of datum and vanilla list
02:17 <thang1> Just out of curiosity, they defined the :| constructor in that package, right? Because I've never seen it before
02:17 <monochrom> Yes.
02:18 <monochrom> user-defined infix data constructor
02:18 systemhalted joined
02:18 <thang1> neat, glad I'm able to read hackage and make sense of it now
02:19 <* thang1> sees "Constructor" label right above a :| [a]
02:19 <thang1> Well... that explains it
02:19 <monochrom> Try this at home! data X = Int :/ Bool | Char :\ Double
02:19 <monochrom> (Two infix data constructors, each 2-ary)
02:19 <monochrom> "the making-face ADT"
02:21 louispan joined
02:22 takle joined
02:23 <thang1> hah, that's neat
02:35 systemfault joined
02:37 <rstefanic> So I sat down, and wrote out the evaluation for foldr and foldl with my maximumBy function. with foldr, the last thing that's evaluated is the start value, while with foldl it's the first thing that's evaluated.
02:38 exferenceBot joined
02:38 <rstefanic> That's why foldr wouldn't work with my maximumBy function. because the first thing evaluated was (4 and 1)
02:38 takle joined
02:38 <rstefanic> where with foldl, the first thing evaluated was (1 and 2)
02:38 <rstefanic> thang1 and monochrom thanks for your help
02:41 <monochrom> You're welcome.
02:42 hexagoxel joined
02:46 <glguy> You can tell that :| is a constructor operator symbol because it starts with a :
02:47 <benzrf> :|
02:47 <MarcelineVQ> :>
02:47 <glguy> Yes, these are great examples!
02:48 aqualogic joined
02:49 takle joined
02:49 <thang1> glguy: But do all constructor operator symbols start with :?
02:49 <glguy> Yes
02:49 <glguy> unless you mean literally ":?"
02:49 <MarcelineVQ> :0
02:49 <glguy> That's not an operator symbol, so it's not elligible to be a constructor operator symbol
02:50 <thang1> hmm, I was under the impression that operator symbols could be pretty much anything
02:50 <geekosaur> constructors need a lexical indicator to distinguish them from type variables in patterns. for identifiers that is upper vs. lower case. symbols lack that, so : was designated as "uppercase" (since the degenerate case (:) is a list constructor)
02:50 <geekosaur> and operator symbols are anything that is a Unicode symbol character
02:51 <glguy> thang1: "constructor operator symbol" is a special class of "operator symbol"
02:51 <geekosaur> as opposed to letter, digit, etc.
02:51 <thang1> ah, got it
02:51 <glguy> With normal identifiers constructors are the capitalized names, with operator symbols they're the : prefixed ones
02:53 <glguy> data Birds = (:<) | (:>)
02:54 <MarcelineVQ> :➤
02:56 <* qu1j0t3> quacks
02:57 louispan joined
02:59 louispan joined
03:03 <benzrf> :t (:?)
03:03 <lambdabot> error:
03:03 <lambdabot> • Data constructor not in scope: :?
03:03 <lambdabot> • Perhaps you meant one of these:
03:03 <benzrf> glguy: whatre u on about?
03:03 <benzrf> @let dataa Wat = Int :? String
03:04 <lambdabot> .L.hs:170:7: error:
03:04 <lambdabot> Not in scope: data constructor ‘Wat’
03:04 <lambdabot> Perhaps you meant one of these:
03:04 <benzrf> @let data Wat = Int :? String deriving Show
03:04 <lambdabot> Defined.
03:04 <benzrf> > 3 :? 4
03:04 <lambdabot> error:
03:04 <lambdabot> • No instance for (Num String) arising from the literal ‘4’
03:04 <lambdabot> • In the second argument of ‘(:?)’, namely ‘4’
03:04 <benzrf> > 3 :? "4"
03:04 <lambdabot> 3 :? "4"
03:04 <thang1> oh ho ho, I wonder if I could define ? as a ternary operator in haskell :D
03:05 <glguy> benzrf: What was your point?
03:05 <thang1> I miss that ternary whenever I have to write a super simple if then else
03:05 <geekosaur> it's been done, I think. precedence games
03:05 <glguy> > let (?) True x _ = x; (?) False _ x = x in True ? 'a' $ b
03:05 <lambdabot> error:
03:05 <lambdabot> • Couldn't match expected type ‘Char’ with actual type ‘Expr’
03:05 <lambdabot> • In the second argument of ‘($)’, namely ‘b’
03:06 <glguy> > let (?) True x _ = x; (?) False _ x = x in True ? 'a' $ 'b'
03:06 <lambdabot> 'a'
03:06 <glguy> > let (?) True x _ = x; (?) False _ x = x in False ? 'a' $ 'b'
03:06 <lambdabot> 'b'
03:06 ysgard joined
03:06 <thang1> nice
03:06 <benzrf> 10:49:49 glguy │ That's not an operator symbol, so it's not elligible to be a constructor operator symbol
03:06 <glguy> benzrf: Yeah ":0" is not one
03:06 <benzrf> but you wrote :?
03:06 <glguy> no
03:06 <benzrf> ohhh
03:06 <benzrf> i skimmed over MarcelineVQ's line
03:06 <benzrf> hehe
03:06 <thang1> I wrote : as the last "word" in a sentence
03:07 <thang1> but that sentence was a question so I wrote :?
03:07 takle joined
03:07 <thang1> I really should've made that sentence more clear in general :p
03:07 <glguy> and then it was asked if *all* constructor operator symbols started with :? and I said yes for : and no for :?. The part about :? was a joke
03:08 argent0 joined
03:09 systemhalted joined
03:14 systemfault joined
03:15 rstefanic joined
03:16 <thang1> Elvis operators are neat
03:17 <benzrf> thang1: hah
03:23 takle joined
03:25 eacameron joined
03:31 leothrix joined
03:36 takle joined
03:39 systemhalted joined
03:40 louispan joined
03:44 takle joined
03:44 begriffs joined
03:46 louispan joined
03:58 permagreen joined
04:02 dni- joined
04:08 shayan_ joined
04:10 aarvar joined
04:13 machinedgod joined
04:15 systemhalted joined
04:16 louispan joined
04:17 takle joined
04:26 eacameron joined
04:34 takle joined
04:42 takle joined
04:47 mniip joined
04:48 begriffs joined
04:50 takle joined
05:04 hphuoc25 joined
05:04 hphuoc25 joined
05:08 fluffystub joined
05:09 takle joined
05:14 machinedgod joined
05:17 takle joined
05:27 louispan joined
05:31 louispan joined
05:37 louispan joined
05:39 takle joined
05:40 aarvar joined
05:43 argent0 joined
05:43 ali_bush joined
05:43 ali_bush joined
05:48 louispan joined
05:51 dni- joined
05:52 mstruebing joined
05:53 cur8or joined
06:00 machinedgod joined
06:04 eatman joined
06:05 takle joined
06:12 hphuoc25 joined
06:21 systemfault joined
06:26 louispan joined
06:27 eacameron joined
06:31 takle joined
06:34 louispan joined
06:35 Pupnik joined
06:37 nickolay joined
06:41 galderz joined
06:45 haskelleksah joined
06:57 louispan joined
06:59 Gloomy joined
07:01 hphuoc25 joined
07:04 takle joined
07:07 louispan joined
07:11 louispan joined
07:24 Durbley joined
07:24 mattyw joined
07:25 louispan joined
07:28 takle joined
07:28 bvad joined
07:30 Durbley joined
07:39 Levex joined
07:40 dni- joined
07:42 takle joined
07:46 louispan joined
07:52 mstruebing joined
07:54 ysgard joined
07:55 colt44 joined
07:58 grdryn joined
08:02 tusj joined
08:03 takle joined
08:09 ysgard joined
08:14 kritzcreek joined
08:16 takle joined
08:21 Levex joined
08:28 eacameron joined
08:28 thc202 joined
08:44 alqatari joined
08:46 dni- joined
08:56 zero_byte joined
08:56 galderz joined
09:05 Gurkenglas_ joined
09:08 takle joined
09:18 <Akii> what is monad base and monad base control?
09:21 <geekosaur> a way to handle resources without leaking them when exceptions occur
09:32 hphuoc25 joined
09:40 cschneid_ joined
09:40 deank joined
09:57 takle joined
10:04 romank joined
10:05 jship joined
10:12 eacameron joined
10:13 ysgard joined
10:27 hphuoc25 joined
10:28 govg joined
10:43 netheranthem joined
10:48 dedgrant_ joined
10:48 Durbley_ joined
10:49 Gloomy joined
10:49 dni-_ joined
10:53 xificurC joined
10:57 pungi-man joined
11:01 Gloomy joined
11:01 geekosaur joined
11:08 geekosaur joined
11:13 abhiroop joined
11:14 <abhiroop> Is there some function in base that could help me with this transformation `[(IO a, IO a)] -> IO [(a,a)]`
11:14 expo873_ joined
11:14 <abhiroop> If it was `[IO (a,a)] -> IO[(a,a)]` I think I could have used `sequenceA`
11:18 acarrico joined
11:19 ThomasLocke joined
11:21 <abhiroop> I tried `sequenceA $ fmap sequenceA x` where x :: [(IO a, IO a)]
11:22 <abhiroop> I get IO [(IO a, a)]
11:22 <abhiroop> Its because of the way the traversable nature of (,) is defined
11:24 Gloomy joined
11:28 abhiroop joined
11:33 <hexagoxel> :t traverse (uncurry (liftA2 (,)))
11:33 <lambdabot> (Applicative f, Traversable t) => t (f a, f b) -> f (t (a, b))
11:33 abhiroop joined
11:34 Levex joined
11:34 <hexagoxel> abhiroop: ^, you could golf this further with lens stuff
11:37 xificurC joined
11:40 cschneid_ joined
11:48 <Gurkenglas> :t traverse (both id) :: [(IO a, IO a)] -> IO [(a,a)] -- yyup
11:48 <lambdabot> [(IO a, IO a)] -> IO [(a, a)]
11:49 xificurC joined
12:04 chlong joined
12:07 mstruebing joined
12:13 Gloomy joined
12:22 m1dnight1 joined
12:27 JoeBiden joined
12:27 <JoeBiden> Hello Everyone. Is there a german-speaking fella who would be so kind and take a look at my problem?
12:34 abhiroop joined
12:34 hphuoc25 joined
12:36 Gloomy joined
12:37 dni- joined
12:37 <Gurkenglas> JoeBiden, #haskell.de and etiquette has it to skip asking whether you may ask
12:38 pbrant joined
12:41 nil_ joined
12:42 aqualogic joined
12:49 <nil_> I can't believe there's no library function divides :: Int -> Int -> Bool
12:51 <nil_> Does everybody type out "... where n `divides` m = 0 /= m `mod` n"?
12:51 <nil_> ...each time you need it?
12:53 <abhiroop> Gurkenglas: Thats cool
12:53 <abhiroop> Btw is it possible to do this without using lens
12:53 <abhiroop> Just the base functions
12:53 Gurkenglas_ joined
12:53 hphuoc25 joined
12:54 cur8or_ joined
12:56 mstruebi1 joined
12:57 acarrico joined
13:00 eviltwin_b joined
13:01 mniip_ joined
13:03 netheranthem joined
13:03 leothrix joined
13:08 m1dnight1 joined
13:09 ThomasLocke joined
13:10 pixelfog joined
13:11 mizu_no_oto_work joined
13:12 <abhiroop> Okay did it with a small helper and no `lens` http://lpaste.net/355228
13:13 <hexagoxel> :t traverse (uncurry (liftA2 (,))) :: [(IO a, IO a)] -> IO [(a,a)] -- abhiroop
13:13 <lambdabot> [(IO a, IO a)] -> IO [(a, a)]
13:13 <abhiroop> I hope I am not missing out some obvious helper
13:14 jship joined
13:14 kritzcreek joined
13:14 fluffystub joined
13:14 bytesighs joined
13:14 <abhiroop> hexagoxel: Oh! thats really cool :) Thanks
13:16 <hexagoxel> abhiroop: but your version is fine too, depending on what level of golfing you are used to :p
13:16 <hexagoxel> abhiroop: only note that \f -> sequenceA . fmap f = traverse
13:16 <abhiroop> Yeah thats what I was missing out. Good point
13:17 <abhiroop> That actually clarifies my understanding of `traverse`
13:21 tourn joined
13:26 kritzcreek joined
13:27 jship joined
13:27 bytesighs joined
13:27 fluffystub joined
13:35 iAmerikan joined
13:45 nil_ joined
13:45 jathan joined
13:46 texasmynsted joined
13:47 eacameron joined
13:49 mengu joined
14:01 takle joined
14:07 pranitbauva1997 joined
14:12 crave joined
14:23 cschneid_ joined
14:26 dni- joined
14:40 ysgard joined
14:52 galderz joined
14:53 prophile joined
15:02 takle joined
15:09 peterbecich joined
15:12 alqatari joined
15:16 uglyfigurine joined
15:21 kykim joined
15:24 skeet70 joined
15:29 crave joined
15:31 cschneid_ joined
15:37 BOOKBOOK joined
16:06 hphuoc25 joined
16:13 meandi_2 joined
16:14 dni- joined
16:17 bvad joined
16:21 Xion_ joined
16:31 iAmerikan joined
16:38 wildlander joined
16:44 <saylu> Is there a preferred way to organize tables and queries in Opaleye? All tables together, all queries together? Or each table & its queries together?
16:48 bungoman joined
16:53 bitemyap1 joined
16:53 uglyfigurine joined
16:57 ebw joined
17:14 NeverDie joined
17:15 iAmerikan joined
17:17 carlomagno joined
17:20 ebw joined
17:23 argent0 joined
17:25 Gloomy joined
17:27 mengu joined
17:32 <srhb> saylu: Everything together until it gets too large or the namespace is polluted too much :-)
17:32 <srhb> (But you probably already knew my opinion ;-))
17:48 pilne joined
17:56 pranitbauva1997 joined
17:59 cschneid_ joined
18:00 <saylu> ha! yes, that's what I'd expect :)
18:04 dni- joined
18:07 hphuoc25 joined
18:08 delexi joined
18:15 haskelleksah joined
18:22 peterbecich joined
18:30 uglyfigurine joined
18:32 asdfjkljkl joined
18:33 deank joined
18:35 mojjo joined
18:35 nobodyzxc joined
18:35 iAmerikan joined
18:37 <asdfjkljkl> Hello! I'm starting with the Haskell book and I'm currently at the lambda section. I've got a question about alpha equivalence. Are those two expressions equivalent? In the book it seems to be implied but I'm confused because the number of arguments doesn't seem to match:
18:38 <asdfjkljkl> ({lambda}xy.xxy) ({lambda}x.xy) ({lambda}x.xz) = ({lambda}xyz.xz(yz)) ({lambda}mn.m) ({lambda}x.xz)
18:38 carlomagno joined
18:39 <asdfjkljkl> prettier version:
18:39 <asdfjkljkl> (λxy.xxy) (λx.xy) (λx.xz) = (λxyz.xz(yz)) (λmn.m) (λx.xz)
18:40 <asdfjkljkl> it's on page 12 in the haskell book
18:56 mengu joined
18:57 argent0 joined
19:21 <LiaoTao> So list notation is just syntactic sugar for monad chaining
19:22 <LiaoTao> This language just keeps getting funkier and funkier
19:22 <monochrom> No. List notation is syntax sugar for using :
19:22 <monochrom> [1,2,3] is syntax sugar for 1:(2:(3:[])). My parentheses are optional. No monad.
19:23 <LiaoTao> Sorry, I meant list comprehension notation
19:23 <LiaoTao> :)
19:24 <monochrom> I think neither Haskell 2010 nor GHC actually officially ties list comprehension to monad.
19:24 <qu1j0t3> LiaoTao: 'do notation' maybe?
19:25 <monochrom> But it is a correct inference. As in, the rules don't say it directly, but the rules imply it.
19:26 <monochrom> Just be careful that when GHC generates code it has a separate generator for list comprehension rather than translating to monad stuff first.
19:26 <LiaoTao> "In fact, list comprehensions are just syntactic sugar for using lists as monads. In the end, list comprehensions and lists in do notation translate to using >>= to do computations that feature non-determinism."
19:26 <LiaoTao> I was just going by that sentence in LYAH
19:26 <LiaoTao> But maybe that's incorrect, then?
19:26 <monochrom> It is wrong.
19:26 <LiaoTao> Okay!
19:27 <LiaoTao> Thanks for the correction
19:27 <monochrom> Because "X is syntax sugar for Y" is a very strong statement about compilers.
19:30 takle joined
19:45 romank joined
19:52 carlomagno joined
19:52 dni- joined
19:53 <Xion_> It seems accurate wrt to how I understand do notation, tbh.
19:55 takle joined
19:56 <monochrom> Yes, mathematically comprehension syntax is equivalent to do-notation.
19:57 <monochrom> But "syntax sugar" is much more than mathematical equivalence.
20:02 nickolay joined
20:03 takle joined
20:04 <Xion_> Well, it does desugar to >>= bindings, doesn't it?
20:08 Iceland_jack joined
20:13 jship joined
20:13 ebw joined
20:14 romank joined
20:17 <MarcelineVQ> Xion_: but then what would the definition of >>= for [] 'desugar' into?
20:17 malaclyps joined
20:17 romank joined
20:19 <Xion_> something something take elements and use (:) :)
20:21 nobodyzxc joined
20:24 <MarcelineVQ> eventually that's the case :> but what I mean is that >>= for [] is defined via a list comprehension, if a list comprehension becomes >>= there's a definition loop
20:25 <Xion_> Ah, fair enough.
20:26 takle joined
20:26 kykim left
20:27 chlong joined
20:29 peterbecich joined
20:30 dni- joined
20:35 <benzrf> MarcelineVQ: its defined with a lisp comp?
20:38 <MarcelineVQ> yep, unless the lisp comp is a joke I don't get ehe
20:39 <benzrf> just a typo
20:40 takle joined
20:41 <MarcelineVQ> there's a note about it in Base.hs that's pretty interesting too explaining why it's not just concatMap
20:45 <monochrom> Xion_: That's the thing, GHC does not desugar list comprehension to >>=.
20:46 <Xion_> Oh well. I'll just go back to making direct analogies to Python then :)
20:47 <monochrom> I think people are too obsessed with "syntax sugar".
20:47 <monochrom> You seldom need to know. Logical equivalence is all you need.
20:48 <monochrom> You don't see people going around saying "1+1 is syntax sugar for 2" and you don't care.
20:48 <monochrom> (And the compiler does compile 1+1 to 2.)
20:56 dni- joined
20:58 haskellbro joined
21:07 carlomagno1 joined
21:10 takle joined
21:11 carlomagno joined
21:14 madjestic joined
21:19 aarvar joined
21:20 albertus1 joined
21:20 takle joined
21:22 carlomagno joined
21:27 Gurkenglas joined
21:29 <glguy> However if you enable the MonadComprehensions extension, then list comprehensions actually do desugar to Monad (and Alternative) class operations
21:32 kadoban joined
21:33 carlomagno1 joined
21:36 alem0lars joined
21:42 xacktm joined
21:43 cschneid_ joined
21:48 shayan__ joined
21:53 carlomagno joined
21:53 hiratara joined
22:00 takle joined
22:08 mengu joined
22:26 albertus1 joined
22:31 argent0 joined
22:34 hiratara joined
22:39 takle joined
22:44 dni- joined
22:51 aarvar joined
22:52 m0d joined
22:55 Durbley joined
22:56 Durbley joined
22:58 peterbecich joined
22:59 takle joined
23:03 uglyfigurine joined
23:06 NeverDie joined
23:15 takle joined
23:35 malaclyps joined
23:36 NeverDie joined
23:44 chlong joined
23:44 cschneid_ joined
23:51 mojjo joined
23:52 uglyfigurine joined