Home freenode/#haskell: Logs Calendar

Logs: freenode/#haskell

←Prev  Next→ 502,152 events total
2020-11-19 07:16:10 <dsal> It's really easy to follow if you don't try to think about how you'd write it as a singly linked list in C.
2020-11-19 07:16:32 <n0042> Conditioning is hard to break '=D
2020-11-19 07:16:44 <n0042> But thank you for bearing with me. I really appreciate it
2020-11-19 07:17:10 <dsal> What is `a`? It's a list where the head is 'x' and the tail is some other stuff. If you only need the head, you're done. If you need the tail, you look at that. Oh, it's `a, that's a list where...
2020-11-19 07:18:39 × alx741 quits (~alx741@181.196.68.148) (Ping timeout: 265 seconds)
2020-11-19 07:19:03 Amras joins (~Amras@unaffiliated/amras0000)
2020-11-19 07:21:16 chaosmasttter joins (~chaosmast@p200300c4a70b2a01441f1455f36b3658.dip0.t-ipconnect.de)
2020-11-19 07:21:33 sord937 joins (~sord937@gateway/tor-sasl/sord937)
2020-11-19 07:23:51 × sfvm quits (~sfvm@37.228.215.148) (Remote host closed the connection)
2020-11-19 07:25:08 p8m_ joins (p8m@gateway/vpn/protonvpn/p8m)
2020-11-19 07:26:32 × p8m quits (p8m@gateway/vpn/protonvpn/p8m) (Ping timeout: 272 seconds)
2020-11-19 07:27:41 <n0042> If I replace `take 5` with `tail` that sequence generates `x`s forever. That is wild.
2020-11-19 07:30:50 acidjnk_new joins (~acidjnk@p200300d0c719ff57608036dc958592ad.dip0.t-ipconnect.de)
2020-11-19 07:31:16 alx741 joins (~alx741@181.196.68.156)
2020-11-19 07:32:21 dan64- joins (~dan64@dannyadam.com)
2020-11-19 07:32:52 <dsal> @src tail
2020-11-19 07:32:52 <lambdabot> tail (_:xs) = xs
2020-11-19 07:32:52 <lambdabot> tail [] = error "Prelude.tail: empty list"
2020-11-19 07:34:49 × dan64 quits (~dan64@dannyadam.com) (Ping timeout: 256 seconds)
2020-11-19 07:34:59 <dsal> :t tail . tail . tail
2020-11-19 07:35:01 <lambdabot> [a] -> [a]
2020-11-19 07:35:16 dhouthoo joins (~dhouthoo@ptr-eiv6509pb4ifhdr9lsd.18120a2.ip6.access.telenet.be)
2020-11-19 07:35:47 <dsal> Or you could `drop ∞` and get to that appended bit.
2020-11-19 07:36:01 <dsal> @src drop
2020-11-19 07:36:01 <lambdabot> drop n xs | n <= 0 = xs
2020-11-19 07:36:01 <lambdabot> drop _ [] = []
2020-11-19 07:36:01 <lambdabot> drop n (_:xs) = drop (n-1) xs
2020-11-19 07:36:13 <dsal> drop isn't partial.
2020-11-19 07:36:26 <dsal> I wonder why `tail` isn't `drop 1`
2020-11-19 07:36:41 <dsal> @check \l -> tail l === drop 1 l
2020-11-19 07:36:43 <lambdabot> *Exception: Prelude.tail: empty list
2020-11-19 07:36:55 <dsal> 👍
2020-11-19 07:37:11 <n0042> That's what I was trying to do. I was trying to see what I could put in there to get to the appended part
2020-11-19 07:37:12 <dsal> Partial functions aren't awesome.
2020-11-19 07:37:33 <dsal> It's an infinitely long list, do you'd have to drop infinite items first.
2020-11-19 07:39:47 <n0042> I was trying to get a better grip on the "let" and "in" syntax earlier today, and that was a pretty useful practical example. Thank you.
2020-11-19 07:42:11 SourOatMilk joins (SourOatMil@gateway/vpn/protonvpn/souroatmilk)
2020-11-19 07:42:12 <dsal> This is one of the things I like about the book mentioned earlier. If you think about eager evaluation in C or something, you'll find haskell confusing. If you stop pretending you know things, it'll make a lot more sense.
2020-11-19 07:42:25 × Sgeo quits (~Sgeo@ool-18b982ad.dyn.optonline.net) (Read error: Connection reset by peer)
2020-11-19 07:42:59 <dsal> (also worth noting that list isn't mentioned for like, several chapters, and you make it yourself)
2020-11-19 07:43:03 gehmehgeh joins (~ircuser1@gateway/tor-sasl/gehmehgeh)
2020-11-19 07:44:23 <n0042> That sounds pretty intense
2020-11-19 07:44:29 <n0042> I'll check it out for sure
2020-11-19 07:44:33 <dsal> No, there's nothing very special about it.
2020-11-19 07:44:54 <dsal> There are three or four books you can read and end up finding haskell is actually pretty boring and doesn't have a lot of magic.
2020-11-19 07:45:14 <dsal> It's just that most other languages are worse and don't give the user much power or ability to generalize things.
2020-11-19 07:46:14 <dsal> @let data MyList a = Item a | EOL deriving Show
2020-11-19 07:46:16 <lambdabot> .L.hs:162:1: error:
2020-11-19 07:46:16 <lambdabot> Multiple declarations of ‘MyList’
2020-11-19 07:46:16 <lambdabot> Declared at: .L.hs:158:1
2020-11-19 07:46:31 × Flonk quits (~Flonk@ec2-52-40-29-25.us-west-2.compute.amazonaws.com) (Ping timeout: 246 seconds)
2020-11-19 07:46:34 <n0042> The things that I really like about it so far are the amazing REPL, the list comprehensions, and recursion-friendly syntax. It's just really easy to write most things I want to write. Except I/O, but I'll get there.
2020-11-19 07:46:39 <dsal> Er. Ignore the error. That's basically List, plus a few other things (and a slightly fancier Show)
2020-11-19 07:46:48 <dibblego> Maybe
2020-11-19 07:47:13 <dsal> er, I messed that up anyway
2020-11-19 07:47:38 × bob_twinkles quits (~quassel@ec2-52-37-66-13.us-west-2.compute.amazonaws.com) (Quit: No Ping reply in 180 seconds.)
2020-11-19 07:47:53 bob_twinkles joins (~quassel@ec2-52-37-66-13.us-west-2.compute.amazonaws.com)
2020-11-19 07:48:03 × gehmehgeh quits (~ircuser1@gateway/tor-sasl/gehmehgeh) (Ping timeout: 240 seconds)
2020-11-19 07:48:28 <dsal> @let data MyList a = Item a (MyList a) | EOL deriving Show
2020-11-19 07:48:29 <lambdabot> Defined.
2020-11-19 07:48:30 Flonk joins (~Flonk@ec2-52-40-29-25.us-west-2.compute.amazonaws.com)
2020-11-19 07:48:50 × clog quits (~nef@bespin.org) (Ping timeout: 256 seconds)
2020-11-19 07:49:05 <dsal> > let a = Item 'x' a in a
2020-11-19 07:49:07 <lambdabot> Item 'x' (Item 'x' (Item 'x' (Item 'x' (Item 'x' (Item 'x' (Item 'x' (Item '...
2020-11-19 07:49:44 gehmehgeh joins (~ircuser1@gateway/tor-sasl/gehmehgeh)
2020-11-19 07:51:13 <dsal> > let mytake _ EOL = EOL; mytake 0 _ = EOL; mytake n (Item x l) = Item x (mytake (n-1) l); a = Item 'x' a in mytake 3 a
2020-11-19 07:51:15 <lambdabot> Item 'x' (Item 'x' (Item 'x' EOL))
2020-11-19 07:51:18 × jedws quits (~jedws@101.184.150.93) (Quit: My MacBook has gone to sleep. ZZZzzz…)
2020-11-19 07:51:57 × coot quits (~coot@37.30.49.253.nat.umts.dynamic.t-mobile.pl) (Quit: coot)
2020-11-19 07:55:29 coot joins (~coot@37.30.49.253.nat.umts.dynamic.t-mobile.pl)
2020-11-19 07:58:33 coco joins (~coco@212-51-146-87.fiber7.init7.net)
2020-11-19 07:58:40 <dsal> @let instance Foldable MyList where foldMap _ EOL = mempty; foldMap f (Item a l) = f a <> foldMap f l
2020-11-19 07:58:41 <lambdabot> Defined.
2020-11-19 07:58:55 <dsal> > toList (Item 1 (Item 2 (Item 3 EOL)))
2020-11-19 07:58:57 <lambdabot> error:
2020-11-19 07:58:57 <lambdabot> Ambiguous occurrence ‘toList’
2020-11-19 07:58:57 <lambdabot> It could refer to
2020-11-19 07:59:05 <dsal> > sum (Item 1 (Item 2 (Item 3 EOL)))
2020-11-19 07:59:08 <lambdabot> 6
2020-11-19 07:59:11 <dsal> woo
2020-11-19 07:59:20 kritzefitz joins (~kritzefit@fw-front.credativ.com)
2020-11-19 07:59:22 <n0042> nice
2020-11-19 07:59:42 × SourOatMilk quits (SourOatMil@gateway/vpn/protonvpn/souroatmilk) (Quit: leaving)
2020-11-19 08:00:02 <dsal> :t fmap
2020-11-19 08:00:06 <lambdabot> Functor f => (a -> b) -> f a -> f b
2020-11-19 08:01:15 <dsal> @let instance Functor MyList where fmap _ EOL = EOL; fmap f (Item x l) = Item (f x) (fmap f l)
2020-11-19 08:01:17 <lambdabot> Defined.
2020-11-19 08:01:42 <dsal> > (2 ^) <$> Item 1 (Item 2 (Item 3 EOL))
2020-11-19 08:01:44 <lambdabot> Item 2 (Item 4 (Item 8 EOL))
2020-11-19 08:03:40 <dsal> Throw in monoid, monad, applicative, and probably a few other things and that's basically list.
2020-11-19 08:06:20 chele joins (~chele@ip5b416ea2.dynamic.kabel-deutschland.de)
2020-11-19 08:07:10 cfricke joins (~cfricke@unaffiliated/cfricke)
2020-11-19 08:09:08 <n0042> From the POV of someone who's still pretty new to the language, that's impressive stuff.
2020-11-19 08:15:07 jedws joins (~jedws@101.184.150.93)
2020-11-19 08:16:26 <dsal> n0042: It gets cooler. e.g.
2020-11-19 08:16:44 <dsal> % [1, 2, 3] :: MyList Int
2020-11-19 08:16:44 <yahb> dsal: Item 1 (Item 2 (Item 3 EOL))
2020-11-19 08:16:47 LKoen joins (~LKoen@169.244.88.92.rev.sfr.net)
2020-11-19 08:16:59 <dsal> I taught yahb how to understand my list from normal list syntax.
2020-11-19 08:17:26 merijn joins (~merijn@83-160-49-249.ip.xs4all.nl)

All times are in UTC.