Home freenode/#haskell: Logs Calendar

Logs: freenode/#haskell

←Prev  Next→ 502,152 events total
2021-03-30 15:19:06 × tefter quits (~bmaxa@62.240.24.69) (Ping timeout: 260 seconds)
2021-03-30 15:19:07 ddellaco_ joins (~ddellacos@ool-44c73afa.dyn.optonline.net)
2021-03-30 15:21:52 dandart joins (~Thunderbi@home.dandart.co.uk)
2021-03-30 15:23:26 × merijn quits (~merijn@83-160-49-249.ip.xs4all.nl) (Ping timeout: 268 seconds)
2021-03-30 15:23:40 merijn joins (~merijn@83-160-49-249.ip.xs4all.nl)
2021-03-30 15:25:46 <CatWithMoustache> what does this syntax do?: instance Something a => Something [a] where
2021-03-30 15:26:22 <tomsmeding> CatWithMoustache: if 'a' has a Something instance, then '[a]' has a Something instance as follows
2021-03-30 15:26:44 <merijn> I'd actually say the reverse (but that's nitpicking) :p
2021-03-30 15:27:07 <merijn> i.e. "[a] has a Something instance if (and only if) 'a' has a Something instance"
2021-03-30 15:27:19 kritzefitz joins (~kritzefit@212.86.56.80)
2021-03-30 15:27:33 <CatWithMoustache> so if I can apply a function to a (I assume it has to be of type "Something") I can now apply it to a list of a's?
2021-03-30 15:28:00 <tomsmeding> CatWithMoustache: do you understand what 'instance Something [a] where' does?
2021-03-30 15:28:14 <CatWithMoustache> not entirely
2021-03-30 15:28:32 × dandart quits (~Thunderbi@home.dandart.co.uk) (Ping timeout: 252 seconds)
2021-03-30 15:29:25 <CatWithMoustache> I think it forces all functions of "Something" to now be applied to the type after
2021-03-30 15:29:34 <CatWithMoustache> (or allows them to be applicable)
2021-03-30 15:29:36 <tomsmeding> it provides definitions for all the methods of the class 'Something' for lists of any type 'a'
2021-03-30 15:29:41 <tomsmeding> not "forces", provides
2021-03-30 15:30:11 <tomsmeding> % class Something a where foo :: a -> Int
2021-03-30 15:30:11 <yahb> tomsmeding:
2021-03-30 15:30:23 <tomsmeding> % instance Something [a] where foo l = length l
2021-03-30 15:30:23 <yahb> tomsmeding:
2021-03-30 15:30:27 <tomsmeding> % foo [1,2,3]
2021-03-30 15:30:27 <yahb> tomsmeding: 3
2021-03-30 15:30:35 <tomsmeding> % foo 42
2021-03-30 15:30:35 <yahb> tomsmeding: ; <interactive>:30:1: error:; * Ambiguous type variable `a0' arising from a use of `foo'; prevents the constraint `(Something a0)' from being solved.; Probable fix: use a type annotation to specify what `a0' should be.; These potential instance exist:; instance [safe] Something [a] -- Defined at <interactive>:28:10; * In the expression: foo 42; In an equation for `i
2021-03-30 15:30:49 <tomsmeding> % instance Something Int where foo i = i
2021-03-30 15:30:49 <yahb> tomsmeding:
2021-03-30 15:30:53 <tomsmeding> % foo (42 :: Int)
2021-03-30 15:30:53 <yahb> tomsmeding: 42
2021-03-30 15:31:32 <CatWithMoustache> ah, so "instance Something a => Something [a] where" guarantees me, that I get an a of type "Something" and I'll be able to apply all functions on it - and then relies on me to implement all those functions if i get a [a]
2021-03-30 15:31:34 <tomsmeding> CatWithMoustache: see? before I added the 'instance Something Int where', 'foo' could not be applied to an integer; it only had a definition for lists
2021-03-30 15:31:59 <tomsmeding> kind of
2021-03-30 15:32:22 <tomsmeding> you're allowed to assume that Something's methods are already defined for 'a' when writing the method definitions for '[a]'
2021-03-30 15:32:50 <tomsmeding> because that declaration only makes [a] an instance of Something for all 'a' that are already an instance of Something
2021-03-30 15:33:35 <tomsmeding> % class C1 a where foo :: a -> Int ; instance C1 [a] where foo l = length l
2021-03-30 15:33:35 <yahb> tomsmeding: ; <interactive>:33:36: error: parse error on input `instance'
2021-03-30 15:33:43 <tomsmeding> % class C1 a where { foo :: a -> Int } ; instance C1 [a] where foo l = length l
2021-03-30 15:33:43 <yahb> tomsmeding:
2021-03-30 15:33:54 <tomsmeding> % foo [1,1,1]
2021-03-30 15:33:55 <yahb> tomsmeding: 3
2021-03-30 15:34:16 <tomsmeding> % class C2 a where { foo :: a -> Int } ; instance C2 a => C2 [a] where foo l = length l
2021-03-30 15:34:16 <yahb> tomsmeding:
2021-03-30 15:34:20 <CatWithMoustache> thx. I think i got it
2021-03-30 15:34:22 <tomsmeding> % foo [1,1,1]
2021-03-30 15:34:23 <yahb> tomsmeding: ; <interactive>:37:1: error:; * Ambiguous type variable `a0' arising from a use of `foo'; prevents the constraint `(C2 a0)' from being solved.; Probable fix: use a type annotation to specify what `a0' should be.; These potential instance exist:; instance [safe] C2 a => C2 [a] -- Defined at <interactive>:36:49; * In the expression: foo [1, 1, 1]; In an equation for `
2021-03-30 15:34:30 <tomsmeding> % instance C2 Int where foo _ = 42
2021-03-30 15:34:30 <yahb> tomsmeding:
2021-03-30 15:34:32 <tomsmeding> % foo [1,1,1]
2021-03-30 15:34:32 <yahb> tomsmeding: ; <interactive>:39:1: error:; * Ambiguous type variable `a0' arising from a use of `foo'; prevents the constraint `(C2 a0)' from being solved.; Probable fix: use a type annotation to specify what `a0' should be.; These potential instances exist:; instance [safe] C2 Int -- Defined at <interactive>:38:10; instance [safe] C2 a => C2 [a] -- Defined at <interactive>:36:49
2021-03-30 15:34:37 <tomsmeding> % foo [1 :: Int,1,1]
2021-03-30 15:34:38 <yahb> tomsmeding: 3
2021-03-30 15:34:48 <tomsmeding> (that annotation is not the point of my story...)
2021-03-30 15:35:07 ezrakilty joins (~ezrakilty@97-113-58-224.tukw.qwest.net)
2021-03-30 15:35:07 <tomsmeding> C1 is available for all lists, C2 only for lists that also have C2 on the elements
2021-03-30 15:35:22 <CatWithMoustache> how do I apply a function with map on a list, if I the function takes two arguments (so the current element and a constant I wish to supply)
2021-03-30 15:35:27 × chele quits (~chele@ip5b40237d.dynamic.kabel-deutschland.de) (Remote host closed the connection)
2021-03-30 15:35:34 <tomsmeding> and for C2, I could've written 'foo l = sum (map foo l)', because foo works on the elements
2021-03-30 15:35:37 <tomsmeding> for C1 I could not have
2021-03-30 15:35:49 <monochrom> map (\x -> x*5) [1,2,3]
2021-03-30 15:35:53 isBEKaml joins (~isBEKaml@unaffiliated/isbekaml)
2021-03-30 15:35:56 Tuplanolla joins (~Tuplanoll@91-159-68-239.elisa-laajakaista.fi)
2021-03-30 15:36:02 <tomsmeding> where (*) is your function
2021-03-30 15:36:38 tefter_ is now known as tefter
2021-03-30 15:36:55 <CatWithMoustache> monochrom, perfect!
2021-03-30 15:38:55 × Tario quits (~Tario@201.192.165.173) (Read error: Connection reset by peer)
2021-03-30 15:39:32 Tario joins (~Tario@201.192.165.173)
2021-03-30 15:40:30 tzh joins (~tzh@c-24-21-73-154.hsd1.or.comcast.net)
2021-03-30 15:41:00 pavonia joins (~user@unaffiliated/siracusa)
2021-03-30 15:42:07 <kamotaketsunumin> but i didn't join this channel, how come
2021-03-30 15:42:16 <peanut_> one of us
2021-03-30 15:42:28 kamotaketsunumin is now known as fnlaai
2021-03-30 15:44:09 heatsink joins (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net)
2021-03-30 15:44:27 errst joins (~errst@unaffiliated/tirej)
2021-03-30 15:45:41 × graf_blutwurst quits (~user@2001:171b:226e:adc0:5cae:c3e0:4b1f:9d86) (Remote host closed the connection)
2021-03-30 15:51:05 cr3 joins (~cr3@192-222-143-195.qc.cable.ebox.net)
2021-03-30 15:53:21 tefter_ joins (~bmaxa@62.240.24.69)
2021-03-30 15:54:31 × zjp quits (~zjp@66-45-138-104-dynamic.midco.net) (Remote host closed the connection)
2021-03-30 15:56:03 × tefter quits (~bmaxa@62.240.24.69) (Ping timeout: 246 seconds)
2021-03-30 15:58:13 wroathe joins (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net)
2021-03-30 16:00:14 xe4_ is now known as xe4
2021-03-30 16:00:27 jakalx parts (~jakalx@base.jakalx.net) ("Error from remote client")
2021-03-30 16:00:28 × xe4 quits (~xe4@157.245.246.119) (Changing host)
2021-03-30 16:00:28 xe4 joins (~xe4@unaffiliated/xe4)
2021-03-30 16:01:23 nbloomf joins (~nbloomf@2600:1700:ad14:3020:60a8:622c:9ce0:9670)
2021-03-30 16:02:40 nbloomf_ joins (~nbloomf@2600:1700:ad14:3020:c108:ff87:d06f:ca72)
2021-03-30 16:06:07 × nbloomf quits (~nbloomf@2600:1700:ad14:3020:60a8:622c:9ce0:9670) (Ping timeout: 258 seconds)
2021-03-30 16:08:42 Rudd0 joins (~Rudd0@185.189.115.103)
2021-03-30 16:08:46 geekosaur joins (82650c7a@130.101.12.122)
2021-03-30 16:10:21 Tops2 joins (~Tobias@dyndsl-095-033-026-062.ewe-ip-backbone.de)
2021-03-30 16:11:20 <geekosaur> I noticed the we interface is now remembering what channels you were last in
2021-03-30 16:11:43 <geekosaur> *web
2021-03-30 16:13:17 <CatWithMoustache> how do I combine two lists linearely without in a list comprehension? (so [0,1,2] [5,6,7] to [(0,1),(1,6),(2,7)])
2021-03-30 16:13:18 × LKoen quits (~LKoen@65.250.88.92.rev.sfr.net) (Remote host closed the connection)
2021-03-30 16:13:31 <CatWithMoustache> without cross-summing?
2021-03-30 16:13:32 <CatWithMoustache> *
2021-03-30 16:13:46 × heatsink quits (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net) (Remote host closed the connection)
2021-03-30 16:13:55 mach1speed joins (~textual@S0106f0b4d2c39cee.va.shawcable.net)
2021-03-30 16:13:56 <geekosaur> > zip [0,1,2] [5,6,7]
2021-03-30 16:13:58 <lambdabot> [(0,5),(1,6),(2,7)]

All times are in UTC.