<    March 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:01 Levex joined
00:16 guampa joined
00:21 eacameron joined
00:24 tom7942 joined
00:24 abhiroop joined
00:25 hphuoc25 joined
00:25 eacameron joined
00:29 eacamero_ joined
00:30 louispan joined
00:37 abhiroop joined
00:38 eacameron joined
00:42 takle joined
00:44 pie_ joined
00:44 eacameron joined
01:09 andrei_chiffa__ joined
01:12 eacameron joined
01:13 <contiver_> A question on quickcheck. I have a bunch of tests, mostly unit tests, with a couple of quickcheck tests in-between. For some reason, when quickcheck is able to falsify a property, but the rest of the tests succeed, then tests as a whole succeed. What could be causing that?
01:18 abhiroop joined
01:20 <geraldodev> exit
01:20 <geraldodev> exit
01:20 <geraldodev> exit
01:20 <geraldodev> quit
01:20 <geraldodev> :q
01:20 geraldodev left
01:21 MotherFlojo joined
01:26 peterbecich joined
01:29 eacameron joined
01:37 eacameron joined
01:42 Rizy joined
01:43 Levex joined
01:46 kadoban joined
01:51 hexagoxel joined
01:55 abhiroop joined
02:00 Rizy joined
02:03 eacameron joined
02:15 pie_ joined
02:16 cschneid_ joined
02:19 eacameron joined
02:22 systemfault joined
02:24 tom7942 joined
02:29 argent0 joined
02:31 argent0 left
02:31 eacameron joined
02:36 eacameron joined
02:38 patbecich joined
02:46 conal joined
02:46 eacameron joined
02:51 eacameron joined
02:58 eacameron joined
03:02 Rizy joined
03:12 hexagoxel joined
03:19 wei2912 joined
03:22 MotherFlojo joined
03:26 Levex joined
03:31 takle joined
03:32 MotherFlojo joined
03:35 wei2912 joined
03:39 systemfault joined
03:46 emmanuel` left
03:48 MotherFlojo joined
03:49 ljc joined
03:54 andrei_chiffa_ joined
04:00 exferenceBot joined
04:03 MotherFlojo joined
04:05 hexagoxel joined
04:05 lspitzner joined
04:10 andrei_chiffa__ joined
04:17 systemfault joined
04:19 MotherFlojo joined
04:19 systemfault joined
04:29 systemfault joined
04:29 nomotif joined
04:31 systemfault joined
04:31 MotherFlojo joined
04:34 systemfault joined
04:36 \Mike joined
04:37 systemfault joined
04:40 systemfault joined
04:40 takle joined
04:47 patbecich joined
04:50 takle joined
04:52 kini joined
04:56 LiaoTao joined
04:57 patbecich joined
05:02 takle joined
05:25 takle joined
05:26 conal joined
05:31 dezren39 joined
05:48 Rizy joined
05:49 nirvinm joined
05:57 takle joined
05:58 patbecich joined
06:00 hexagoxel joined
06:16 HEGX64 joined
06:19 geekosaur joined
06:22 geekosaur joined
06:23 geekosaur joined
06:32 louispan joined
06:35 takle joined
06:35 unmanbearpig joined
06:47 MotherFlojo joined
06:51 pie_ joined
06:54 howdoi joined
06:57 hoffmeyer joined
06:57 takle joined
06:59 michbad joined
07:00 hexagoxel joined
07:03 MotherFlojo joined
07:04 takle joined
07:07 hoffmeyer joined
07:09 dezren39 joined
07:13 emmanuel_erc joined
07:25 eacameron joined
07:28 louispan joined
07:31 nirvinm left
07:31 hphuoc25 joined
07:32 hoffmeyer joined
07:34 eacameron joined
07:36 unmanbearpig joined
07:45 eacameron joined
07:45 hexagoxel joined
07:46 michbad joined
07:49 takle joined
07:49 jtcs joined
07:54 eacameron joined
07:55 cschneid_ joined
07:56 MotherFlojo joined
07:58 eacamero_ joined
08:00 patbecich joined
08:02 unmanbearpig joined
08:02 takle joined
08:02 eacameron joined
08:09 eacameron joined
08:10 takle joined
08:15 eacameron joined
08:33 MotherFlojo joined
08:37 gk_1wm_su joined
08:38 jle` joined
08:39 eacameron joined
08:40 takle joined
08:48 MotherFlojo joined
08:51 eacameron joined
08:51 lithie joined
08:55 eacameron joined
08:55 jtcs joined
08:58 takle joined
08:59 hexagoxel joined
09:00 eacameron joined
09:01 nil_ joined
09:03 eacamero_ joined
09:04 MotherFlojo joined
09:08 averell joined
09:13 initiumdoeslinux joined
09:15 Rizy joined
09:19 MotherFlojo joined
09:19 jtcs joined
09:21 takle joined
09:23 ilja_kuklic joined
09:29 gfixler joined
09:30 Levex joined
09:34 tsmish joined
09:39 takle joined
09:39 t0by joined
09:39 t0by joined
09:40 thc202 joined
09:45 louispan joined
09:52 takle joined
09:54 HEGX64 joined
10:01 patbecich joined
10:04 Gurkenglas joined
10:09 simendsjo joined
10:12 nek0 joined
10:15 louispan joined
10:25 hexagoxel joined
10:28 takle joined
10:34 emmanuel_erc joined
10:40 <nil_> I just completed Week 8 of CIS 194, but read gives me a "no parse" here: https://github.com/nilthehuman/cis194/blob/master/Homework8.hs#L76
10:40 <nil_> Why?
10:56 mjs2600 joined
10:58 binaryplease joined
11:09 hphuoc25 joined
11:09 hexagoxel joined
11:11 sys1 joined
11:13 mounty joined
11:13 GAZUMP joined
11:14 <GAZUMP> Is "Introduction to Functional Programming Using Haskell" by Richard Bird a good book? Is it outdated?
11:16 nadirs joined
11:16 <GAZUMP> Is "Introduction to Functional Programming Using Haskell" by Richard Bird a good book? Is it outdated?
11:16 xx_ joined
11:17 Gazump_ joined
11:18 binaryplease joined
11:23 louispan joined
11:25 MotherFlojo joined
11:30 <zaquest> nil_, what ghc version do you use?
11:31 <nil_> zaquest: 7.6 apparently.
11:32 flounders joined
11:34 Miroboru joined
11:35 amuck joined
11:36 <zaquest> nil_, then this is because of lazy IO, you call `withFile` and use it's result, but `withFile` closes the file before you read the whole file, hence `read` is unable to parse the tree. in newer version of ghc you'd get a better error message "delayed read on closed handle". i suggest switching to readFile.
11:36 <nil_> zaquest: huh, thanks, that's really helpful. Why is the file closed early though?
11:40 <zaquest> nil_, you do not consume the whole string before withFile finishes, you just create a thunk that should consume the string and pass it further to mapM_, the string is being consumed somewhere in putStrLn long time after withFile
11:40 <nil_> Hmm, okay, that makes sense.
11:41 louispan joined
11:41 <nil_> What would an appropriate use of withFile look like though?
11:45 vadimich joined
11:45 <zaquest> nil_, i guess one uses withFile when he performs all the processing inside a function similar to your `go`, like: withFile f ReadMode (\h -> hGetContents h >>= putStrLn)
11:51 louispan joined
11:56 xx_ joined
11:58 hexagoxel joined
12:02 patbecich joined
12:06 <xx_> hello! I'm trying to implement a tree structure in Haskell, but the way I intuitively did it doesn't work. if somebody could point me to the right direction, I'd be very grateful! here's my code: http://pastebin.com/XM23PWLL (error: "Multiple declarations of ‘Node’")
12:07 contiver_ joined
12:11 <zaquest> xx_, you have multiple constructors named `Node`, this isn't allowed. you have to rename them. like Empty | AtomicSentenceNode AtomicSentence | UnaryLogicOperatorNode UnaryLogicOperator LogicTree | ...
12:11 jtcs joined
12:14 mthek joined
12:20 abhiroop joined
12:21 netheranthem joined
12:22 <xx_> thank you zaquest! I wasn't sure if this was the idiomatic way of doing it. I'll do it this way then!
12:25 j-keck joined
12:25 hoffmeyer joined
12:27 <j-keck> hello, i'm figthing with a simple example: get the current time with a prue type signatrue - with the use of 'unsafePerformIO'. this examples yield's always the same time: http://lpaste.net/8959234829505789952
12:29 <j-keck> what did i missing, to get the actual time every second - thanks.
12:31 <zaquest> xx_, im not sure if it's idiomatic way but you often can see such trees being flat as in data LogicTree = Not LogicTree | And LogicTree LogicTree | Or LogicTree LogicTree | ...
12:33 <zaquest> j-keck, why would haskell evaluate a pure value again and again, it evaluates it once and keeps it
12:35 <xx_> ah I see. thanks.
12:35 <j-keck> zaquest: that make sense, sure. but how can i prevent this optimization? - i test with '-O0', '-fno-cse' ghc flags - but i don't get it.
12:36 NoCreativity joined
12:39 <zaquest> j-keck, ts :: () -> POSIXTime
12:40 cschneid_ joined
12:43 <zaquest> j-keck, not sure if you can disable it with any flags, it seems like a fundamental thing
12:43 <j-keck> thanks, but then the function signature changes. this is only a simple example.
12:44 <j-keck> in my real code, i have a pure function. but at dev time / 'debug time' i have some io site effects: i need to read a file - which can change over time.
12:45 <zaquest> well it satisfies your original question the signature is pure
12:45 <j-keck> yes - my specification was not clear enough.
12:46 <j-keck> but thanks - i need to go the rabbit hole deeper.
12:54 hoffmeyer joined
13:00 <contiver_> j-keck, the thing is, what you are doing is fundamentally impure. Why not just stick to IO? Is it a requirement of your problem?
13:02 hoffmeyer joined
13:03 <j-keck> in the 'real core code' there is nothing impure. only at dev / debug time. it has a bad taste that i need to lift the pure code in the io monad - only for the dev / debug use case.
13:04 <contiver_> j-keck, have you tried Debug.Trace?
13:05 <j-keck> yes - but trace is only to 'produce output effects'. i need to read a file. if i wrap readFile in the trace call, it execute the trace / read the file only at the first time.
13:06 vadimich joined
13:08 <j-keck> in the 'real core code' there is nothing impure. only at dev / debug time. it has a bad taste that i need to lift the pure code in the io monad - only for the dev / debug use case.
13:09 <j-keck> sorry - 'up, enter' in the wrong terminal!
13:09 <contiver_> j-keck, no problem :)
13:11 <contiver_> I don't know of a workaround. You might want to try in the #haskell channel though (or hopefully someone more savvy answers here).
13:13 atz__ joined
13:14 Levex joined
13:15 lspitzner joined
13:15 <j-keck> contiver_: thanks for your try. i don't give up.
13:20 hphuoc25 joined
13:22 takle joined
13:25 MotherFlojo joined
13:30 hphuoc25 joined
13:39 vadimich joined
13:40 vadimich joined
13:45 abh joined
13:48 abhiroop joined
13:50 takle joined
13:53 Levex joined
14:03 takle joined
14:04 patbecich joined
14:04 contiver joined
14:08 pilne joined
14:16 delexi joined
14:17 HEGX64 joined
14:19 prophile joined
14:26 <nitrix> I'll add that you should really stay away from any unsafePerformIO hackery unless you understand all the implications (in regards to lazy evaluation, referential transparency, inlining/optimizations, monomorphic restriction, and so forth).
14:28 mjs2600 joined
14:34 CptCaptain joined
14:34 takle joined
14:38 atz__ joined
14:45 mjs2600 joined
14:46 Levex joined
14:51 mjs2600 joined
14:54 <j-keck> but, but - it's only at dev time!
14:54 takle joined
14:59 atz__ joined
15:04 takle joined
15:05 patbecich joined
15:08 wildlander joined
15:15 takle joined
15:22 hphuoc25 joined
15:26 MotherFlojo joined
15:30 takle joined
15:33 Levex joined
15:34 NoCreativity joined
15:38 shayan_ joined
15:42 takle joined
15:48 ilja_kuklic joined
15:52 owiecc joined
15:56 Levex joined
16:03 takle joined
16:06 pie_ joined
16:07 atz__ joined
16:09 conal joined
16:10 Big_G joined
16:18 andrei_chiffa_ joined
16:20 jgertm joined
16:23 hphuoc25 joined
16:24 andrei_chiffa__ joined
16:39 Levex joined
16:41 cschneid_ joined
16:41 andrei_chiffa_ joined
16:52 simendsjo joined
16:58 mthek joined
16:59 lak joined
17:05 jespada joined
17:06 owiecc joined
17:07 patbecich joined
17:09 nomotif joined
17:12 exferenceBot joined
17:17 lak joined
17:19 sablib joined
17:24 hphuoc25 joined
17:24 conal joined
17:24 g-k--1-w-m--s-u- joined
17:27 MotherFlojo joined
17:27 takle joined
17:28 takle joined
17:30 contiver_ joined
17:33 patbecich joined
17:37 takle_ joined
17:38 j-keck left
17:41 takle joined
17:47 saylu joined
17:54 MotherFlojo joined
18:01 hoffmeyer joined
18:03 dabd joined
18:06 johs joined
18:13 Levex joined
18:17 Big_G joined
18:18 hoffmeyer joined
18:22 lithie joined
18:28 albertus1 joined
18:30 HazyPurple joined
18:48 sablib left
18:51 conal joined
18:52 Levex joined
18:52 nil_ joined
18:53 baamonde joined
18:56 <nil_> Is there a difference between the terms "identity functor" and "identity morphism"?
19:09 MotherFlojo joined
19:09 systemfault joined
19:10 lspitzner joined
19:18 <zaquest> nil_, i think yes, but i know nothing about category theory :)
19:18 <geekosaur> nil_, in what context? My "gut feeling" is "no in Haskell, yes in CT" but I am no CT expert
19:18 <nil_> geekosaur: we're talking CT now.
19:18 <nil_> Wikipedia tends to use both terms without saying if they are interchangeable or not.
19:19 lak joined
19:19 <geekosaur> my understanding is that a functor is a morphism with some additional restrictions
19:19 <geekosaur> but my understanding may well be wrong :)
19:20 <ski> identify functor is identity morphism in a functor category
19:20 Levex joined
19:20 <geekosaur> and I don;t think I;d trust wikipedia for good CT information. try ncatlab maybe
19:20 <ski> a functor is a morphism of categories
19:21 <ski> while e.g. a linear transformation is a morphism of vector spaces
19:21 <ski> iow, a linear transformation is a morphism in the category of vector spaces
19:21 <ski> while a functor is a morphism in the category of categories
19:23 NoCreativity joined
19:25 <benzrf> ski: no, 'functor category' is a category where objects are functors
19:25 <ski> sorry, yes. you're right
19:25 <benzrf> the identity morphsims in a functor category are natural transformations - you meant that functors are id morphisms in a category of categories
19:26 <ski> yes
19:27 hoffmeyer joined
19:27 hphuoc25 joined
19:27 mjs2600 joined
19:28 <nil_> geekosaur: ncatlabs looks really nice, thanks.
19:29 chrissl joined
19:29 <benzrf> uh oh
19:30 <geekosaur> heh
19:32 <nil_> benzrf: something wrong with that site? :S
19:34 <benzrf> among other things: it's kind of like tvtropes, except you never get to the bottom
19:34 <nil_> benzrf: do you mean in the time sink sense or the lack of strict precision sense?
19:34 <benzrf> in the reading/browsing-pattern sense
19:36 <nil_> But is it a fine source otherwise?
19:36 <benzrf> maybe not a terribly helpful one
19:36 <benzrf> also it's kind of...... how do u put it
19:37 <benzrf> https://ncatlab.org/nlab/show/nPOV
19:37 <benzrf> >To some extent the nPOV is just the observation that category theory and higher category theory, hence in particular of homotopy theory, have a plethora of useful applications.
19:37 <benzrf> this is a lie
19:38 <benzrf> there is a certain definite cluster in concept-space and mindset-space where the nlab dwells, and reading too much of it pollutes you
19:38 <benzrf> this isnt necessarily a bad thing, but
19:38 <benzrf> depending on what other math you do, it can produce a certain kind of understanding that's...
19:38 <benzrf> eh, i dunno
19:39 <benzrf> it's not really that bad of a thing - i was being kinda jokey when i said 'uh oh' :)
19:39 <nil_> Alright then. I'll try and filter out the opinionated stuff. :)
19:39 <benzrf> nah, dont worry
19:39 <benzrf> also, you cant
19:39 <nil_> :D
19:40 \Mike joined
19:40 <nil_> Semigroupoids are "categories without identity morphisms". What the hell? How can you *not* have an identity morphism? What's an example of such an object?
19:40 <benzrf> i'm a bit tempted to suggest that giving an nLab link to a haskell programmer with a little bit of math interest is kind of like giving atlas shrugged to a kid with a little bit of economics/politics interest, but honestly there are a lot of things wrong with that comparison
19:40 <benzrf> like a lot of things
19:40 <nil_> benzrf: That's a helpful analogy though!
19:41 <benzrf> heheh
19:41 grayjoc joined
19:41 <benzrf> nil_: they are "categories without identity morphisms" in the sense that identity morphisms are not part of the required structure of the object
19:42 <nil_> I realize. That's why I'm asking for an example.
19:42 <benzrf> ah, ok
19:42 <benzrf> well, quick note - just to clarify, in case -
19:43 <benzrf> when talking about types of mathematical object, it's common to say "an X is a Y without Z" when what you mean is "an X is a Y except that it need not have Z, which Y's normally have, but every Y is still an X"
19:43 <nil_> I realize that too. :)
19:43 <benzrf> anyway, a trivial example of a non-category semigroupoid would be if you take any category and simply remove the identity morphisms from the hom-sets
19:43 <benzrf> :p
19:43 <benzrf> kk, good
19:43 <benzrf> let me see if i can think of an interesting example
19:44 <benzrf> hmm... i suppose you could turn any relation into a semigroupoid in the same way you can turn a reflexive relation into a category
19:45 <benzrf> i can't say i've read much about semigroupoids though
19:45 <benzrf> sorry
19:45 <nil_> I'm not sure what a reflexive relation is.
19:46 <benzrf> a binary relation R is reflexive if forall x in its domain, x R x
19:46 <nil_> Ah, I see.
19:47 taksuyu joined
19:48 <benzrf> in any case i can't really condemn sending the nlab to math-curious haskellers given that i myself am in large part a product of that :>
19:48 <nil_> So semigroupoids are not too useful after all because their instances tend to either be categories too or totally artificial like "let's take any category and remove the id morphisms"?
19:48 <benzrf> that said: read some actual textbooks too
19:48 owiecc joined
19:48 <benzrf> hmmm, i dunno about that
19:49 <benzrf> those are the ones i come up with off the top of my head, but that's because im mostly used to thinking about categories
19:49 <benzrf> i'm sure there's interesting semigroupoids out there
19:49 <benzrf> just are there are interesting monoids that aren't just mangled groups
19:50 <nil_> Like N+ under addition?
19:51 <benzrf> yeah
19:51 lspitzner joined
19:51 <geekosaur> re benzrf earlier: you start seeing categories under your bed?
19:51 <benzrf> heuh
19:52 <benzrf> you start interrupting in your math class to say "ohhh hold on, so this is just a functor from the poset category to Set?"
19:52 <geekosaur> pretty much, yes
19:52 takle_ joined
19:52 <geekosaur> (I wasn;t quite *that* bad in school, but had much the same effect on other students... and sometimes teachers)
19:53 mac10688 joined
19:53 <geekosaur> ("we're still on long division, what is this...")
19:53 <benzrf> oh, long division!
19:53 <benzrf> i relearned that a few weeks ago!
19:53 <benzrf> it makes sense this time :>
19:54 <monochrom> I proved it correct.
19:54 <nil_> Going back to the "identity functor" vs "identity morphism" question for a moment: a functor is two morphisms extended with each other (one for objects, one for morphisms), yes? So an *identity* functor is two *identity* morphisms together?
19:55 <monochrom> I also figured out that one about "a method of taking square roots or nth roots remotely like long division"
19:55 <benzrf> nil_: no, a functor is two functions
19:55 <monochrom> ObHaskell: I also wrote Haskell code to implement it. :)
19:56 <benzrf> nil_: functions are indeed morphisms of Set, but it's the only kind of morphism that goes into an (ordinary) functor
19:57 <nil_> benzrf: right, I see that. So what I just typed is fine except it's weaker than saying two /functions/ extended with each other?
19:57 <benzrf> umm, kind of
19:58 <benzrf> but if i were to assign a quasiformal meaning to that, it would suggest that i could pick any two morphisms satisfying the unspecified criteria
19:58 <benzrf> as opposed to just Set ones
19:58 <benzrf> so what you said is too strong
19:58 <nil_> Oh. I guess that's a better way to look at it.
19:59 <benzrf> that said - there's a concept of an "enriched category" where instead of normal hom-sets you have objects from another category (basically) -
19:59 <benzrf> so then the morphism mappings might be non-Set morphisms :)
19:59 <nil_> Alright then, an identity functor is necessarily an identity _function_. How's that?
19:59 <benzrf> sure
19:59 <nil_> Okay.
19:59 <benzrf> (in each of its mappings)
19:59 <nil_> Say what?
20:00 <benzrf> well, since a functor is a pair of functions, it isn't literally an identity function - it's a pair of identity functions
20:00 <benzrf> that's all
20:00 <benzrf> but it probably just depends on how you make your formal definitions
20:00 <nil_> But hey... two identity functions extended with each other are an identity function by definition, no? o_O
20:00 <benzrf> wait
20:00 <benzrf> what do you mean by "extended"?
20:01 <nil_> I mean this: let foo True = True ; let bar False = False ; let extended True = foo True ; let extended False = bar False
20:01 <nil_> foo and bar are "or'd together".
20:02 <benzrf> oh
20:02 <benzrf> you mean the sum of the functions?
20:02 lak joined
20:02 <nil_> And then extended = id :: Bool -> Bool
20:02 <nil_> That's right, except I didn't know that word.
20:02 <benzrf> i.e. we have f : A -> D and g : B -> D, so we have [f, g] : A + B -> D
20:03 <benzrf> (that's a new notation, not 'list')
20:03 <nil_> Precisely.
20:03 <benzrf> so you're thinking of a functor as a mapping out of Ob(C) + Mor(C) ?
20:03 <nil_> A = Objects in C, B = morphisms in C
20:03 <nil_> Yep.
20:03 <benzrf> that's not the usual way of thinking about it, but if that's your definition, then yes - just a single identity function
20:04 <benzrf> it's more typical to have one function from Ob(C) to Ob(D), then an indexed family of functions F_{A,B} : Hom_C(A, B) -> Hom_D(F(A), F(B))
20:04 <nil_> Alright. Wikipedia using both words from time to time had me confused a bit, I thought there would be some subtle difference there.
20:04 <benzrf> 'both words'?
20:04 <nil_> "identity functor" vs "identity function"
20:05 <benzrf> (note that "+" means coproduct, not 'union' - in Set, that's disjoint union)
20:05 <benzrf> ah
20:05 <nil_> Each thing is also automatically the other thing, right?
20:05 <benzrf> umm
20:05 <benzrf> you can have an identity function whose domain is not a category
20:05 <nil_> If we are in a category C.
20:05 <benzrf> you mean if the function has type Ob(C) + Mor(C) -> Ob(C) + Mor(C)
20:05 <nil_> That's right. :)
20:06 <benzrf> then the identity function of that type is exactly the same as the identity functor of C, yes
20:06 <nil_> Thanks for rendering everything I say into proper math.
20:06 <benzrf> no problem!
20:08 mjs2600 joined
20:08 <nil_> Is it the case that all Traversables admit a special kind of fold "size :: Traversable t => t a -> Integer"?
20:08 <nil_> ...or not?
20:09 <benzrf> (note that everything i've been saying tacitly acts as though categories in general have Ob(C) as a set)
20:09 <benzrf> (which breaks when you notice that i've mentioned the category Set, which certainly can't have Ob(Set) a set)
20:09 <benzrf> (but don't worry about it ;p)
20:09 <benzrf> nil_: yes
20:09 <nil_> benzrf: Why can't it have Ob(Set) as a set again?
20:09 <benzrf> :t traverse (const (Const (Sum 1)))
20:09 <lambdabot> (Traversable t, Num a) => t b1 -> Const (Sum a) (t b)
20:09 <benzrf> nil_: because that would be the set of all sets
20:10 <nil_> ^Awesome, thanks! I knew it should work.
20:10 <benzrf> i think all traversables are foldables anyway, though, and
20:10 <benzrf> :t length
20:10 <nil_> Oh, and you can't have that in modern set theory, right?
20:10 <lambdabot> Foldable t => t a -> Int
20:10 <benzrf> depends on which set theory you use, i guess, but certainly not in ZFC
20:10 <nil_> Gotcha.
20:12 tienkajreen joined
20:13 <nil_> The "not too much difference between categories and a typical semigroupoid" thing reminded me of another question I've got:
20:13 <nil_> Basically all Functors are Applicatives, right? It's hard to come up with one that /isn't/.
20:14 <nil_> So just hypothetically, do you think it would be a loss if base presented the two merged into one and got rid of plain Functor?
20:14 <benzrf> not all functors are applicatives
20:14 <nil_> I know. :)
20:14 <nil_> But the ones that aren't look seriously marginal.
20:14 <benzrf> well, what would be the gain from merging them
20:15 <benzrf> the loss would be that code which is generic over Functor no longer works for types that aren't applicatives
20:15 <benzrf> which, you're right, might be a fair sacrifice if there's a gain - not many types would lose out
20:15 <benzrf> but what would the gain be?
20:18 <nil_> ...I guess I can't come up with a convincing one.
20:18 <benzrf> :)
20:19 <nil_> I know PureScript does the opposite: they separate everything into tiny classes that add one function at a time.
20:21 <benzrf> nil_: btw, there are cases where the type is only applicative when some constraint is met
20:21 <benzrf> for example, ((,) w) requires Monoid w for Applicative
20:21 <benzrf> but i can do this fine:
20:21 <nil_> Right.
20:21 <benzrf> > fmap (+1) (3, 2)
20:21 <lambdabot> (3,3)
20:22 <benzrf> so ((,) Int) is a Functor but not an Applicative
20:22 Deide joined
20:22 <benzrf> well... that's a lie. it's an Applicative under, say, the `First' semigroup
20:22 <benzrf> that is,
20:22 <nil_> So your point is you couldn't fmap over a type that's not Monoid m => f m?
20:22 <benzrf> er, wait no
20:22 aarvar joined
20:23 <benzrf> well, not with the instance we've settled on anyway
20:23 <nil_> Okay
20:23 <benzrf> there are cases where i'd like to fmap over a tuple without introducing a monoid constraint on my arguments
20:24 <benzrf> actually, there's a good example of this in lens!
20:24 <benzrf> lenses, by only requiring Functor, allow you to be certain that you're getting a result
20:25 <benzrf> do you know how van laarhoven lenses work?
20:25 <nil_> I don't
20:26 louispan joined
20:28 Uniaika joined
20:29 <benzrf> oh
20:29 <benzrf> have you ever touched lens before?
20:31 <nil_> I've read the introductory paragraph of the package plus skimmed a few tutorials...
20:32 <nil_> My understanding is they modify arbitrary elements of a data structure in a pure fashion.
20:32 <nil_> And they can be derived automatically for most types with Template Haskell.
20:33 <benzrf> yeh
20:33 <benzrf> ok, well
20:33 <benzrf> lets look at a simplified version of the full type, here:
20:34 <benzrf> type Lens' s a = forall f. Functor f => (a -> f a) -> s -> f s
20:34 <benzrf> now, can you write me a function of type: Lens' s a -> s -> a ?
20:34 <benzrf> you don't have to think too hard about why this is a sane way to represent lenses
20:34 <benzrf> just try playing type tetris
20:35 <nil_> Sorry, making pasta for dinner so expect high turnround right about now...
20:36 <benzrf> hah
20:38 takle joined
20:38 <nil_> I've got nothing in Lens' s a that produces an a. I can get an (f s) but that's not too useful.
20:39 andrei_chiffa__ joined
20:39 <benzrf> nil_: look closer
20:39 <nil_> Okay, I'm looking...
20:39 <benzrf> nil_: the forall is in the type of the lens, not the type of your function
20:39 <benzrf> you're not writing this:
20:39 takle joined
20:39 <benzrf> forall f. Functor => ((a -> f a) -> s -> f s) -> s -> a
20:39 <benzrf> you're writing this:
20:39 <benzrf> (forall f. Functor => (a -> f a) -> s -> f s) -> s -> a
20:40 <benzrf> in other words, you get to pick what f is, not your caller
20:40 <benzrf> you may treat the argument lens as polymorphic
20:40 <nil_> Hmmm, so I might be able to substitute f = (->) r and get something cool.
20:40 <benzrf> exactly, for example :)
20:40 <nil_> Is that it?
20:40 <benzrf> write the function and tell me
20:40 <nil_> I'm gonna, wait a sec.
20:40 <benzrf> @let MyLens' s a = forall f. Functor f => (a -> f a) -> s -> f s
20:40 <lambdabot> Parse failed: Parse error: =>
20:40 <benzrf> ehm
20:41 <benzrf> @let type MyLens' s a = forall f. Functor f => (a -> f a) -> s -> f s
20:41 <lambdabot> Defined.
20:42 <benzrf> @let mySnd :: MyLens' (a, b) b; mySnd m (x, y) = fmap (\x' -> (x', y)) (m x)
20:42 <lambdabot> .L.hs:164:44: error:
20:42 <lambdabot> • Couldn't match expected type ‘b’ with actual type ‘a’
20:42 <lambdabot> ‘a’ is a rigid type variable bound by
20:42 <benzrf> eh?
20:42 <benzrf> oops, derp
20:42 <benzrf> @let mySnd :: MyLens' (a, b) b; mySnd m (x, y) = fmap (\y' -> (x, y')) (m y)
20:42 <lambdabot> Defined.
20:43 <benzrf> now once u write `myGet :: MyLens' s a -> s -> a' we should be able to do `myGet mySnd ("hello", "world")'
20:43 <nil_> I'm trying.
20:44 lak joined
20:44 <nil_> Looks like I'm going to need an initial x :: a from somewhere. :/
20:45 <benzrf> no you don't!
20:45 <nil_> I don't?
20:45 <benzrf> you're thinking of implementing the lens type
20:45 <benzrf> not the type of myGet
20:46 <benzrf> the lens implementation must supply an a, not you
20:46 <benzrf> try playing with mySnd
20:46 <benzrf> > mySnd Identity (1, 2)
20:46 <lambdabot> Identity (1,2)
20:46 <nil_> Uh-huh.
20:46 <benzrf> > mySnd (\x -> (x, x)) (1, 2)
20:46 <lambdabot> (2,(1,2))
20:47 <benzrf> > mySnd (\x -> Identity 3) (1, 2)
20:47 <lambdabot> Identity (1,3)
20:47 <nil_> Hmm, that's odd.
20:47 <benzrf> yes! pick at the oddness!
20:47 <benzrf> :]
20:47 <nil_> > mySnd (const Nothing) (Just 42, Just 99)
20:48 <lambdabot> Nothing
20:48 <nil_> > mySnd (const $ Identity Nothing) (Just 42, Just 99)
20:48 <lambdabot> Identity (Just 42,Nothing)
20:49 <nil_> I'm going back to my little whiteboard, I'm going to try and wrap up the "type tetris"
20:51 <benzrf> :)
20:52 <nil_> Okay, so not only can I substitute Reader for f, I also get to pick "r", right?
20:53 takle joined
20:54 <benzrf> yeah
20:54 <benzrf> well, to be precise, you swap 'Reader r' for f
20:54 <benzrf> so naturally you get to pick r
20:54 <benzrf> see if this does what you want, though!
20:55 <nil_> But how does either (r = a) or (r = s) help me? Not in any way that I can see.
20:55 <nil_> Perhaps if I ask for a function...
20:57 <nil_> You said Lens is going to supply the a. But the type we want is myGet :: ((a -> r -> a) -> s -> r -> s) -> s -> a (where r is TBD).
20:57 <benzrf> nil_: well, you could also pick something other than Reader to use f as
20:58 <benzrf> try looking at the implementation of mySnd, btw
21:01 conal joined
21:05 <gluegadget> I'm trying to write an instance of a class for a parametered type, but don't know how exactly write it. Here's a simplified version of it: http://lpaste.net/353245 I'm getting the error “Couldn't match expected type ‘Int’ with actual type ‘Bar’”
21:05 takle joined
21:06 <benzrf> gluegadget: it's not clear to me what you're trying to do
21:07 <benzrf> why are you matching on Foo and Bar in your implementation of (==)?
21:14 <benzrf> hmm, i'll be back later
21:14 <gluegadget> benzrf: my simplified version doesn't make much sense. my problem is in the pattern matching part
21:14 albertus1 joined
21:14 <gluegadget> even this fails: (==) (Id (Foo i)) (Id (Foo j)) = (untagId i) == (untagId j)
21:15 <gluegadget> what I'm trying to do in the real project is to write toPersistValue for instances PersistField of persistent library
21:16 louispan joined
21:16 <nil_> :t Const
21:16 <lambdabot> forall k a (b :: k). a -> Const a b
21:17 <MarcelineVQ> ghc panic while working on benzrf's lens exercise :>
21:17 grayjoc joined
21:19 takle joined
21:21 <nil_> @define myGet trans x = getConst . trans Const x
21:21 <lambdabot> Defined.
21:21 <nil_> :t myGe
21:21 <lambdabot> error:
21:21 <lambdabot> • Variable not in scope: myGe
21:21 <nil_> :t myGet
21:21 <lambdabot> • Perhaps you meant ‘myGet’ (line 164)
21:21 <lambdabot> forall k k1 c a (b :: k) a1 (b1 :: k1) t. ((a1 -> Const a1 b1) -> t -> a -> Const c b) -> t -> a -> c
21:22 <nil_> That's not it, but Const seems to make a lot of sense.
21:24 tnks joined
21:25 <nil_> Wait, I could go with ((,) a) instead and even keep the s.
21:26 takle joined
21:28 <nil_> @define fuckYeah trans = fst . trans (\y -> (y,y))
21:28 <lambdabot> Defined.
21:28 <nil_> :t fuckYeah
21:28 <lambdabot> ((t -> (t, t)) -> a -> (c, b)) -> a -> c
21:28 hphuoc25 joined
21:28 <nil_> > fuckYeah id
21:28 <lambdabot> error:
21:28 <lambdabot> • No instance for (Typeable b0)
21:28 <lambdabot> arising from a use of ‘show_M887596973125788968122373’
21:28 <nil_> Oh, wait, of course not.
21:29 <nil_> Um, how do you even use this thing?
21:30 <nil_> > fuckYeah mySnd (Just 42, Just 99)
21:30 <lambdabot> Just 99
21:30 <nil_> Got it!
21:30 mjs2600 joined
21:31 <nil_> I've got the wrong name though.
21:31 <nil_> @define myGet = fuckYeah
21:31 <lambdabot> .L.hs:166:1: error:
21:31 <lambdabot> Multiple declarations of ‘myGet’
21:31 <lambdabot> Declared at: .L.hs:162:1
21:31 <nil_> Whatever. :)
21:33 ploop joined
21:34 <nil_> benzrf, I got there.
21:36 Gurkenglas_ joined
21:38 ploop joined
21:39 mengu joined
21:45 cschneid_ joined
21:53 hiratara joined
21:58 mjs2600 joined
22:02 <nil_> Hello? Where's my cookie?
22:06 smichel17 joined
22:06 m3tti joined
22:14 nil_ joined
22:22 asante joined
22:22 asante joined
22:25 conal joined
22:27 rembo10 joined
22:29 hphuoc25 joined
22:31 hiratara joined
22:32 geekosaur joined
22:32 peterbecich joined
22:34 <MarcelineVQ> holy bageeze that was exercise was confusing
22:35 <nil_> Is benzrf still online?
22:36 <MarcelineVQ> yes but said earlier they were away for a bit
22:37 <MarcelineVQ> You solved that quite quickly :>
22:37 <nil_> Turns out you can do it with Const too, just let myGet f = getConst . f Const
22:37 <nil_> "Quickly"?? Are you kidding?
22:37 <MarcelineVQ> not at all
22:37 <nil_> I spent like an hour on it!
22:38 <MarcelineVQ> yep!
22:39 <nil_> Anyway, I'm here for the extra wisdom and karma, and it looks like benzrf skipped town with it. >:(
22:40 louispan joined
22:43 <MarcelineVQ> here's a trick​ I ended up using that you might find useful, http://lpaste.net/353248
22:43 <MarcelineVQ> it's a useful way to check your assumptions about types
22:43 takle joined
22:43 louispan_ joined
22:43 <MarcelineVQ> if it was wrong the compiler would not allow me to say g = l
22:44 <MarcelineVQ> futhermore it would tell you what g and l really are
22:44 <nil_> Nice!
22:45 <nil_> When I'm trying to fix a long function I usually feed the "tails" of it to ghci and see if each one is the type I expect.
22:46 <MarcelineVQ> nice, these days I use TypeApplications for that but it caused a ghc panic in this case, I need to make a bug report :X
22:47 <nil_> Like if let complicated c f g h = uncurry3 (liftA3 c) . flatten3 . (f && g && h) and I got it wrong the error message is usually indecipherable so I start with just (f && g && h) instead.
22:47 <nil_> Uh, those (&&) are actually (&&&)'s.
22:48 <nil_> Oh, and GHC does typed holes too, right? So if I mess up one part of the above can I ask it to fill it in?
22:49 <MarcelineVQ> yes they're quite useful, though sometimes less informative than one expects, I don't have a particular example in mind when I say that though
22:51 amuck joined
22:51 mjs2600 joined
22:54 <MarcelineVQ> _ (typed holes) and the let example are quite comparable, in fact you can assert a type with _ as well, e.g. foo = show 2 ++ (_ :: Int) though the error is a little more verbose since it reports both the hole and the type error
22:55 <nil_> I find GHC error messages a bit unfriendly in general. Maybe it's just me though.
22:56 <MarcelineVQ> You'll get used to them, and in time rely on that verbosity, I wouldn't mind some color coding in them though
22:57 <nil_> (Still nothing compared to the travesties g++ tends to emit when it starts complaining about templated C++, obviously.)
22:57 <nil_> Yeah, I would love some color too.
22:58 <nil_> ...Isn't there a third-party tool for that already?
22:59 <MarcelineVQ> yes, though I'm not aware of really good ghci integration with them
22:59 <MarcelineVQ> there's some error colors coming in the next major ghc release but it's very basic
23:00 <MarcelineVQ> hscolor is the one that comes to mind btw
23:00 <nil_> I'm going to take a look.
23:00 <nil_> Anyway, what's the lesson about lenses that we're supposed to take home from all this?
23:01 mac10688 joined
23:02 <MarcelineVQ> most directly " <benzrf> there are cases where i'd like to fmap over a tuple without introducing a monoid constraint on my arguments"
23:02 <MarcelineVQ> but also useful is that you've now worked with forall
23:02 <nil_> Yeah, that was trippy. :)
23:03 <MarcelineVQ> and understood how you can get an `a` from an `s`, in a manner of speaking, still seems a little like witchcraft to me :>
23:05 <nil_> I appreciate parametricity more and more every day. It's amazing how powerful such a simple concept ends up being.
23:07 <nil_> I should have called "fuckYeah" "witchcraft" though.
23:07 takle joined
23:08 ploop joined
23:09 amuck joined
23:12 amuck joined
23:13 takle joined
23:17 takle joined
23:21 takle_ joined
23:22 Rizy joined
23:23 Denthir joined
23:28 dni- joined
23:30 hphuoc25 joined
23:41 louispan joined
23:41 exferenceBot joined
23:44 MotherFlojo joined
23:44 stef204 joined
23:48 conal joined
23:51 Denthir left
23:54 Levex joined