Home freenode/#haskell: Logs Calendar

Logs: freenode/#haskell

←Prev  Next→ 502,152 events total
2021-04-27 14:06:01 × kritzefitz quits (~kritzefit@2003:5b:203b:200::10:49) (Remote host closed the connection)
2021-04-27 14:07:44 <gaff> ulidtko: i see (on your earlier comment that i need to list out all the types i need to test out explicitly)
2021-04-27 14:08:44 Sheilong joins (uid293653@gateway/web/irccloud.com/x-wmcvcprqxoaligba)
2021-04-27 14:08:47 × immae quits (immaematri@gateway/shell/matrix.org/x-dzpquvhgzhzvsdfa) (Quit: issued !quit command)
2021-04-27 14:09:35 <ulidtko> gaff, correct. for the same reason it's not easy (to my knowledge) to have a magic_generator :: Ord a => Gen a which'd spew out generators of various types with Arbitrary and Ord instances. Might be doable, but not easy. Definitely harder than listing those types you care about the most -- and trusting parametric polymorphism to not produce behaviors dependent on specific types.
2021-04-27 14:10:48 <ulidtko> in other words, if your sorting function under test is parametric in Ord a, than ensuring it works for Ints will ensure it works for any other type
2021-04-27 14:11:45 immae joins (~immae@2a01:4f8:141:53e7::)
2021-04-27 14:12:03 <gaff> ulidtko: coorect, absolutely. so you are saying there is no need to test for other types, if things work well for say Int?
2021-04-27 14:12:51 <gaff> sort function i am testing is parametric in Ord a, by the way.
2021-04-27 14:13:01 acidjnk_new2 joins (~acidjnk@p200300d0c72b9524d9e45372e00f3038.dip0.t-ipconnect.de)
2021-04-27 14:13:07 <ulidtko> that's a so-called "free theorem" I think. f :: Ord a => [a] -> [a] -> [a] *isn't allowed* to know what a is.
2021-04-27 14:13:20 <gaff> i see
2021-04-27 14:13:24 <ulidtko> so if it works on Int, it must work on anything else. yeah
2021-04-27 14:13:41 <gaff> ulidtko: great. i am relieved.
2021-04-27 14:14:20 <ulidtko> gaff, nice, glad to help!
2021-04-27 14:14:33 hypercube joins (~hypercube@2603-6011-f901-9e5b-0000-0000-0000-08cf.res6.spectrum.com)
2021-04-27 14:14:34 × acidjnk_new quits (~acidjnk@p200300d0c72b95883ddaf449c9d144e9.dip0.t-ipconnect.de) (Ping timeout: 245 seconds)
2021-04-27 14:14:37 × proofofkeags quits (~proofofke@97-118-239-55.hlrn.qwest.net) (Ping timeout: 252 seconds)
2021-04-27 14:16:36 waleee-cl joins (uid373333@gateway/web/irccloud.com/x-yppqkxzvcrpccgyz)
2021-04-27 14:16:58 <gaff> also, one clarification: when you say you can't match on types, what exactly are you implying? are you saying that something like this can not be done, for example: Case x of {A -> g (f :: [Int] -> [Int]), B -> g (f :: [Char] -> [Char]) }. this can not be done.
2021-04-27 14:17:33 × timCF quits (~i.tkachuk@254-149-20-81.sta.estpak.ee) (Ping timeout: 252 seconds)
2021-04-27 14:18:09 <ulidtko> this usage isn't pattern-matching on f
2021-04-27 14:18:46 <gaff> ulidtko: but the usage i describe will not compile
2021-04-27 14:18:55 <ulidtko> yes
2021-04-27 14:19:04 <ulidtko> oh wait it could
2021-04-27 14:19:12 <ulidtko> but it inspects x -- which must be the same type in both case arms
2021-04-27 14:19:27 <ulidtko> I guess what I'm saying is, not a good example
2021-04-27 14:20:31 ystael joins (~ystael@209.6.50.55)
2021-04-27 14:20:31 <gaff> ulidtko: yeah, because it isn't the same type on both arms, it won't compile. and it doesn't.
2021-04-27 14:20:53 × mmfood_1 quits (~mmfood@185.176.246.118) (Quit: Leaving)
2021-04-27 14:21:16 <gaff> i can not imagine any other way to do it.
2021-04-27 14:21:18 rj joins (~x@gateway/tor-sasl/rj)
2021-04-27 14:21:43 <ulidtko> you can use type-families to "conceptually" pattern-match on types. that wouldn't look like a case {} expression though
2021-04-27 14:22:06 <gaff> i see
2021-04-27 14:23:36 <gaff> so as i understood from what you said earlier, the example i have described is not exactly pattern matching on types?
2021-04-27 14:24:14 × Lycurgus quits (~niemand@98.4.118.65) (Quit: Exeunt)
2021-04-27 14:28:48 <ulidtko> that's right. it's pattern-match on variable x, of sum-type with constructors A and B
2021-04-27 14:29:14 <ulidtko> (not on two functions named f with different signatures)
2021-04-27 14:29:55 × frozenErebus quits (~frozenEre@37.231.244.249) (Ping timeout: 268 seconds)
2021-04-27 14:30:32 × stree quits (~stree@68.36.8.116) (Ping timeout: 240 seconds)
2021-04-27 14:31:00 <ulidtko> (you could as well say, two different specializations of polymorphic f)
2021-04-27 14:34:45 kiweun joins (~kiweun@2607:fea8:2a62:9600:8cec:67b2:253b:dec)
2021-04-27 14:34:46 cr3 joins (~cr3@192-222-143-195.qc.cable.ebox.net)
2021-04-27 14:35:49 <gaff> ulidtko: i see
2021-04-27 14:36:18 pengjiz joins (~user@2601:547:902:6d00::2)
2021-04-27 14:36:54 × rdivyanshu quits (uid322626@gateway/web/irccloud.com/x-mteqqlxhxtokcodc) (Quit: Connection closed for inactivity)
2021-04-27 14:37:18 <dexterfoo> geekosaur: I tried it and it doesn't work :/
2021-04-27 14:37:24 <gaff> ulidtko: and that can be done (the case business) because the types in both arms of the case do not match.
2021-04-27 14:37:55 × hypercube quits (~hypercube@2603-6011-f901-9e5b-0000-0000-0000-08cf.res6.spectrum.com) (Quit: WeeChat 3.1)
2021-04-27 14:38:19 <gaff> sorry, i meant, that can not be done.
2021-04-27 14:39:09 × kiweun quits (~kiweun@2607:fea8:2a62:9600:8cec:67b2:253b:dec) (Ping timeout: 250 seconds)
2021-04-27 14:39:43 Berndt joins (~Berndt@dynamic-095-112-089-113.95.112.pool.telefonica.de)
2021-04-27 14:39:53 × Berndt quits (~Berndt@dynamic-095-112-089-113.95.112.pool.telefonica.de) (Quit: WeeChat 3.1)
2021-04-27 14:40:10 Berndt joins (~Berndt@dynamic-095-112-089-113.95.112.pool.telefonica.de)
2021-04-27 14:42:25 Berndt parts (~Berndt@dynamic-095-112-089-113.95.112.pool.telefonica.de) ()
2021-04-27 14:42:53 slack1256 joins (~slack1256@200-112-79-247.baf.movistar.cl)
2021-04-27 14:43:54 hypercube joins (~hypercube@2603-6011-f901-9e5b-0000-0000-0000-08cf.res6.spectrum.com)
2021-04-27 14:44:13 stree joins (~stree@68.36.8.116)
2021-04-27 14:44:18 <ulidtko> gaff, well... not exactly. You _can_ have different types in case arms, e.g. main = case bool_variable of {True -> print 3.14; False -> print ([1..4] :: [Int])}. You cannot have different _return types_ so to say, the expressions in case arms must unify; this won't work: print (case bool_variable of {True -> 3.14; False -> ([1..4] :: [Int])})
2021-04-27 14:44:27 × sh9 quits (~sh9@softbank060116136158.bbtec.net) (Quit: WeeChat 2.8)
2021-04-27 14:44:41 <slack1256> My failing HLS terminates on emacs with the following message: "exited with status exit(check corresponding stderr buffer for details" but I don't see any emacs buffer with info. Does anyone have any idea where to find it?
2021-04-27 14:45:05 <slack1256> Nevermind, found it.
2021-04-27 14:50:00 <gaff> ulidtko: correct. what confuses me is in the example i described -- g (f :: [Int] -> [Int]), g (f :: [Char] -> [Char]), g is polymorphic, having the type signature g :: Ord a => ([a] -> [a}) -> IO (), yet the compiler complains, even though both arms of the case statement return IO (). i couldn't understand that.
2021-04-27 14:51:03 <ulidtko> gaff, can you post a self-contained example? i think that usage should be fine, it's likely you're missing something
2021-04-27 14:51:15 <gaff> ok
2021-04-27 14:52:12 × idhugo__ quits (~idhugo@87-49-45-4-mobile.dk.customer.tdc.net) (Ping timeout: 240 seconds)
2021-04-27 14:52:46 <joel135> I was looking at some purescript docs and saw "setPersonPostcode pc p = p { address { postCode = pc } }". First question: Does haskell have the same syntax feature? Second question: Now imagine that there are more clauses after address and after postCode. Can this be achieved with a haskell lens library?
2021-04-27 14:53:39 <ulidtko> joel135, yes and yes. see "record update syntax", lens can do it in a different way
2021-04-27 14:59:23 <geekosaur> dexterfoo, sorry, what is the context of this? I've lost it
2021-04-27 15:00:14 <nicholasbulka> how might I write a function that requires subtracting 1 on every second iteration?
2021-04-27 15:00:17 <nicholasbulka> for example
2021-04-27 15:00:34 <nicholasbulka> next y n = reverse $ transpose (chunks n $ concat $ tail y)
2021-04-27 15:01:12 <nicholasbulka> next (next (next (next (next (next (next y 4 ) 3 ) 3 ) 2) 2 ) 1) 1
2021-04-27 15:02:03 <nicholasbulka> I'm basically flipping rotating a matrix to deconstruct it in a spiral fashion.
2021-04-27 15:02:40 <joel135> ulidtko: I can't find how the syntax works recursively https://paste.tomsmeding.com/UkviUQv0
2021-04-27 15:03:19 <joel135> For the lens approach, could you show me / link to an example like that?
2021-04-27 15:05:35 × bennofs_ quits (~quassel@x4dbffbc2.dyn.telefonica.de) (Read error: Connection reset by peer)
2021-04-27 15:05:56 bennofs_ joins (~quassel@x4dbffbc2.dyn.telefonica.de)
2021-04-27 15:06:59 × hiroaki quits (~hiroaki@2a02:8108:8c40:2bb8:4afc:980e:3b22:8734) (Ping timeout: 260 seconds)
2021-04-27 15:08:40 cole-h joins (~cole-h@c-73-48-197-220.hsd1.ca.comcast.net)
2021-04-27 15:09:57 zmijunkie1 joins (~Adium@109.90.32.89)
2021-04-27 15:11:50 × zmijunkie quits (~Adium@87.122.222.91) (Ping timeout: 268 seconds)
2021-04-27 15:13:35 × jespada quits (~jespada@87.74.37.248) (Quit: Leaving)
2021-04-27 15:14:32 ep1ctetus joins (~epictetus@ip72-194-54-201.sb.sd.cox.net)
2021-04-27 15:15:09 <gaff> ulidtko: see https://pastebin.com/SXSDri7q for an example
2021-04-27 15:17:31 × enoq quits (~textual@194-208-146-143.lampert.tv) (Quit: Textual IRC Client: www.textualapp.com)
2021-04-27 15:20:47 × jgt quits (~jgt@78.162.43.217) (Ping timeout: 240 seconds)
2021-04-27 15:21:29 idhugo__ joins (~idhugo@80-62-116-231-mobile.dk.customer.tdc.net)
2021-04-27 15:21:29 jgt joins (~jgt@78.162.43.217)
2021-04-27 15:21:56 aerona joins (~aerona@2600:6c54:4600:f300:79a1:e32c:5e1f:ee48)
2021-04-27 15:24:34 <gaff> that code i pasted doesn't compile.
2021-04-27 15:24:43 <gaff> i am not exactly clear why
2021-04-27 15:25:36 <gaff> also, i there anyother way to rewrite it?
2021-04-27 15:25:50 × geekosaur quits (930099da@rrcs-147-0-153-218.central.biz.rr.com) (Quit: Connection closed)
2021-04-27 15:26:02 <gaff> is there any other way to rewrite it?
2021-04-27 15:26:49 geekosaur joins (930099da@rrcs-147-0-153-218.central.biz.rr.com)
2021-04-27 15:28:56 Deide joins (~Deide@217.155.19.23)
2021-04-27 15:30:25 × Sarcarean quits (4582bfd4@h69-130-191-212.bendor.broadband.dynamic.tds.net) (Quit: Connection closed)
2021-04-27 15:31:09 wroathe joins (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net)
2021-04-27 15:31:28 <gaff> ulidtko: the stuff i pasted at https://pastebin.com/SXSDri7q pretty much simulates the problem i have described earlier.

All times are in UTC.