Home freenode/#haskell: Logs Calendar

Logs: freenode/#haskell

←Prev  Next→
Page 1 .. 234 235 236 237 238 239 240 241 242 243 244 .. 5022
502,152 events total
2020-09-26 19:44:56 <sm[m]> dsal++ !
2020-09-26 19:45:48 adam_wespiser joins (~adam_wesp@209.6.42.110)
2020-09-26 19:46:28 hackage x86-64bit 0.4.6.1 - Runtime code generation for x86 64 bit machine code https://hackage.haskell.org/package/x86-64bit-0.4.6.1 (PeterDivianszky)
2020-09-26 19:46:51 <fluturel> Say, if I have two generic types in a function declaration, they can be the same when i use the function, right?
2020-09-26 19:47:01 flex14 joins (~flex14@2601:280:c780:7ea0:d233:9ddf:c010:c113)
2020-09-26 19:47:27 <fluturel> sum' :: (Num a, Num b) => [a] -> b
2020-09-26 19:47:31 <geekosaur> they can be, but you can't know what they are so you can't check for the specific case where they're the same
2020-09-26 19:47:31 <koz_> fluturel: If you mean something like 'f :: a -> b -> a', yes, it is possible to have a and b both be the same type.
2020-09-26 19:47:55 <koz_> The only difference that use of a different type variable makes is that the types are _allowed_ to be different.
2020-09-26 19:47:59 <koz_> (not forced)
2020-09-26 19:48:06 <geekosaur> and that particular signature looks like a problem to me, tbh
2020-09-26 19:48:10 <fluturel> yeah, that's what i thought as well
2020-09-26 19:48:26 × aplainzetakind quits (~johndoe@captainludd.powered.by.lunarbnc.net) (Quit: Free ZNC ~ Powered by LunarBNC: https://LunarBNC.net)
2020-09-26 19:48:27 <fluturel> but ghci complains and i can't figure out why
2020-09-26 19:48:35 × fxg quits (~fxg@unaffiliated/fxg) (Client Quit)
2020-09-26 19:48:38 <koz_> fluturel: What exact complaint are you seeing?
2020-09-26 19:48:39 <dsal> fluturel: what's the complaint?
2020-09-26 19:48:46 <geekosaur> :t (+)
2020-09-26 19:48:48 <lambdabot> Num a => a -> a -> a
2020-09-26 19:48:49 <koz_> geekosaur is right that the signature looks suspect.
2020-09-26 19:49:06 <fluturel> Couldn't match expected type 'b' with type 'a'
2020-09-26 19:49:15 <monochrom> "use the function" is the opposite of "implement the function"
2020-09-26 19:49:18 <dsal> That makes sense. Where would b come from?
2020-09-26 19:49:19 vicfred joins (~vicfred@unaffiliated/vicfred)
2020-09-26 19:49:24 <fluturel> and then some more lines about 'a' and 'b' being rigid types
2020-09-26 19:49:25 Tuplanolla joins (~Tuplanoll@91-159-68-239.elisa-laajakaista.fi)
2020-09-26 19:49:34 <monochrom> Everything the user can do, the implementer cannot.
2020-09-26 19:49:45 × Lycurgus quits (~niemand@98.4.96.130) (Quit: Exeunt)
2020-09-26 19:49:50 <geekosaur> you told the compiler they *could* be different. then you presumably used (+)
2020-09-26 19:49:52 <geekosaur> :t (+)
2020-09-26 19:49:54 <lambdabot> Num a => a -> a -> a
2020-09-26 19:50:09 <koz_> Which says 'the types gotta be the same, yo'.
2020-09-26 19:50:25 <fluturel> Well, i thought that since i am summing things of type a in a list of type [a], the ghci can finfer that the output is b, but it can't
2020-09-26 19:50:38 <koz_> fluturel: How does it do that exactly?
2020-09-26 19:50:40 <dsal> Well, you're specifically saying it can be any type as long as it's a Num
2020-09-26 19:50:49 <koz_> Suppose a ~ Int and b ~ some matrix type?
2020-09-26 19:51:10 <koz_> How exactly do you go from 'an Int produced by summing other Ints' to 'some matrix type'?
2020-09-26 19:51:24 <fluturel> well, you can't..
2020-09-26 19:51:25 aplainzetakind joins (~johndoe@captainludd.powered.by.lunarbnc.net)
2020-09-26 19:51:37 falafel_ joins (~falafel@2605:e000:1527:d491:f090:20fe:cddf:2a1a)
2020-09-26 19:51:45 <geekosaur> but that's what you told it with that signature
2020-09-26 19:51:45 <koz_> fluturel: But your signature says that you can.
2020-09-26 19:51:53 <koz_> So GHC is disagreeing with the signature.
2020-09-26 19:52:11 <fluturel> I see
2020-09-26 19:52:17 <koz_> (I think I owe geekosaur a soda, lol)
2020-09-26 19:52:41 Majiir joins (~Majiir@2601:18c:ca00:a400:211:32ff:fe42:6eda)
2020-09-26 19:54:05 × adam_wespiser quits (~adam_wesp@209.6.42.110) (Ping timeout: 240 seconds)
2020-09-26 19:54:24 × Saten-san quits (~Saten-san@ip-213-49-124-100.dsl.scarlet.be) (Quit: WeeChat 2.9)
2020-09-26 19:54:55 adam_wespiser joins (~adam_wesp@209.6.42.110)
2020-09-26 19:55:03 <dsal> I set up github actions for all my haskell projects, and then at some point, all of them started failing.
2020-09-26 19:55:30 <fluturel> let's say the function doesn't do a sum, but it does something else depending on the input. Let's say if it gets an empty list, it returns a double (for some reason). Then it wouldn't complain anymore, would it? Because it sees that in certain cases, b is the same as a, an int, but sometimes it isn't, so my signature would be correct
2020-09-26 19:56:35 <geekosaur> with respect to a type signature, your implementation does not choose the types; the caller does
2020-09-26 19:56:39 × o1lo01ol1o quits (~o1lo01ol1@bl8-213-81.dsl.telepac.pt) (Remote host closed the connection)
2020-09-26 19:56:57 ericsagnes joins (~ericsagne@2405:6580:0:5100:b877:8b34:4984:caf9)
2020-09-26 19:57:06 <geekosaur> so your signature tells a caller that it can request a Double result from an [Int], for example
2020-09-26 19:57:28 <koz_> fluturel: The best way to think of a signature like that (namely, with type variables) is that the caller of the function is allowed to set those variables to be anything, provided those things are both instances of Num.
2020-09-26 19:57:36 <geekosaur> your implementation, on the other hand, does not get to pick Double for an empty list or Int otherwise; it has to be the same type in both cases
2020-09-26 19:57:45 <koz_> Therefore, you as the _implementer_ must, in all cases, accomodate absolutely any such choice, now and forever.
2020-09-26 19:58:03 <koz_> Having it work _some of the time_ or for _some choices_ of arguments or types isn't sufficient.
2020-09-26 19:58:13 <koz_> Essentially, this is a contract between you and your caller.
2020-09-26 19:58:21 <ski> @quote freedom.is
2020-09-26 19:58:21 <lambdabot> monochrom says: in fact, freedom is the freedom to write 2.2 = 4
2020-09-26 19:58:23 <ski> @quote freedom.is
2020-09-26 19:58:24 <lambdabot> monochrom says: in fact, freedom is the freedom to write 2.2 = 4
2020-09-26 19:58:28 <ski> hm
2020-09-26 19:58:32 <koz_> Which says 'as long as you ensure that a and b are both instances of Num, then I will have this work'.
2020-09-26 19:58:41 <ski> @quote freedom.is.your
2020-09-26 19:58:41 <lambdabot> monochrom says: Programming is a dialectic class struggle between the author and the user. My freedom is your slavery. Your ignorance is my strength.
2020-09-26 19:58:47 <sm[m]> dsal: stack casa timeouts ? this was affecting folks recently
2020-09-26 19:58:47 <koz_> And therefore, those facts are the only things you are allowed to use.
2020-09-26 19:59:33 × adam_wespiser quits (~adam_wesp@209.6.42.110) (Ping timeout: 260 seconds)
2020-09-26 19:59:46 <dsal> I don't even quite understand. It's been this way for a month or so. I got it all set up and then it all broke and I've just not gone into figuring it out. I figured if all of them were broken, it might work itself out.
2020-09-26 20:00:07 × thir quits (~thir@p200300f27f0fc60094e773283d7bf825.dip0.t-ipconnect.de) (Ping timeout: 240 seconds)
2020-09-26 20:00:11 × shad0w_ quits (~shad0w_@160.202.37.29) (Ping timeout: 246 seconds)
2020-09-26 20:01:40 × dhil quits (~dhil@11.29.39.217.dyn.plus.net) (Ping timeout: 246 seconds)
2020-09-26 20:02:29 × chaosmasttter quits (~chaosmast@p200300c4a7105f0120adba39e14d4586.dip0.t-ipconnect.de) (Quit: WeeChat 2.9)
2020-09-26 20:02:43 <int-e> oh monochrom... but what if the user is also the programmer?
2020-09-26 20:02:52 <ski> > (2 . 2) 4
2020-09-26 20:02:54 <lambdabot> 2
2020-09-26 20:03:10 <int-e> that Num instance again :-(
2020-09-26 20:03:34 <int-e> @undef
2020-09-26 20:03:35 <lambdabot> Undefined.
2020-09-26 20:06:06 <fluturel> koz_ : I understand what the type signature entails, i was asking more something like: can a function return different types depending on what the caller inputs?
2020-09-26 20:06:32 <geekosaur> it cannot
2020-09-26 20:06:46 <geekosaur> that's what I was saying earlier
2020-09-26 20:06:58 <geekosaur> >> your implementation, on the other hand, does not get to pick Double for an empty list or Int otherwise; it has to be the same type in both cases
2020-09-26 20:07:14 adam_wespiser joins (~adam_wesp@209.6.42.110)
2020-09-26 20:07:15 <fluturel> Then it was i who misunderstood, i am sorry
2020-09-26 20:07:21 × ggole quits (~ggole@2001:8003:8119:7200:7423:d49d:a274:5670) (Quit: Leaving)
2020-09-26 20:08:07 <fluturel> Haskell is giving me the headaches and i am tired
2020-09-26 20:08:07 <ski> the caller can pick a different type, that's used both as input type and output type
2020-09-26 20:08:11 <Cale> It can produce different types of result based on the type of the argument...
2020-09-26 20:08:14 <geekosaur> (that's what the compiler meant by "rigid", by the way)
2020-09-26 20:08:30 <Cale> but not the value of the argument
2020-09-26 20:08:46 <ski> but you, as the implementor, can't decide to pick different output types here, depending on what input values you see (you can't even detect which types of input you're getting)
2020-09-26 20:09:11 <fluturel> yeah, so no reflection
2020-09-26 20:09:39 <fluturel> I can only guarantee that if it is an instance of Num, the function behaves correctly, no funny business
2020-09-26 20:10:06 <fluturel> If it isn't, the caller gets an error
2020-09-26 20:10:15 <dsal> You *can* write that function, but it's usually a bad idea.
2020-09-26 20:11:06 <fluturel> by that function, you mean the one with the signature i showed earlier?

All times are in UTC.