Home liberachat/#haskell: Logs Calendar

Logs: liberachat/#haskell

←Prev  Next→ 1,803,992 events total
2021-08-05 20:59:42 <yahb> dsal: * -> Constraint
2021-08-05 20:59:48 <dsal> % :k Ordering
2021-08-05 20:59:48 <yahb> dsal: *
2021-08-05 21:00:28 <dsal> % :k Ordering
2021-08-05 21:00:28 <yahb> dsal: Type
2021-08-05 21:00:44 <seydar> dsal: thank you! How would you describe the relationship between a datatype and a class?
2021-08-05 21:00:50 <dsal> (we used to call type `*` for some reason)
2021-08-05 21:01:12 lavaman joins (~lavaman@98.38.249.169)
2021-08-05 21:01:29 <dsal> The way I did above, mostly. Classes are used to constrain the possible types.
2021-08-05 21:01:37 <dsal> % :t abs
2021-08-05 21:01:37 <yahb> dsal: Num a => a -> a
2021-08-05 21:02:13 <seydar> I guess I'm struggling in describing what Ordering is
2021-08-05 21:02:28 <dsal> % :t Ordering
2021-08-05 21:02:28 <yahb> dsal: ; <interactive>:1:1: error: Data constructor not in scope: Ordering
2021-08-05 21:02:32 <dsal> % :t k Ordering
2021-08-05 21:02:32 <yahb> dsal: ; <interactive>:1:1: error: Variable not in scope: k :: t0 -> t; <interactive>:1:3: error: Data constructor not in scope: Ordering
2021-08-05 21:02:34 <dsal> % :k Ordering
2021-08-05 21:02:34 <yahb> dsal: Type
2021-08-05 21:02:38 <dsal> Ordering is just a type.
2021-08-05 21:02:42 <dsal> % :i Ordering
2021-08-05 21:02:42 <yahb> dsal: type Ordering :: Type; data Ordering = LT | EQ | GT; -- Defined in `GHC.Types'; instance Eq Ordering -- Defined in `GHC.Classes'; instance Monoid Ordering -- Defined in `GHC.Base'; instance Ord Ordering -- Defined in `GHC.Classes'; instance Semigroup Ordering -- Defined in `GHC.Base'; instance Enum Ordering -- Defined in `GHC.Enum'; instance Show Ordering -- Defined in `GHC.Show'; instance Data Ordering
2021-08-05 21:02:52 <geekosaur> Ordering is not directly related to Ord
2021-08-05 21:03:10 <geekosaur> althoiugh it has an Ord instance
2021-08-05 21:03:48 <dsal> And `Ord` *uses* `Ordering` in `compare`
2021-08-05 21:03:54 jmct_ joins (sid160793@tinside.irccloud.com)
2021-08-05 21:03:54 hongminhee joins (sid295@tinside.irccloud.com)
2021-08-05 21:03:55 agander_m joins (sid407952@tinside.irccloud.com)
2021-08-05 21:03:58 <geekosaur> types which have an Ord instance promise to have instance methods one of which happens to return Ordering
2021-08-05 21:04:16 <dsal> But there's nothing particularly special about it. It might be slightly confusing that `Ordering`s are orderable themselves.
2021-08-05 21:04:38 <geekosaur> but there's nothing in the class which requires a class member to do something like that, it's just how Ord works
2021-08-05 21:04:54 <dsal> % LT < GT
2021-08-05 21:04:54 <yahb> dsal: True
2021-08-05 21:04:54 eggplantade joins (~Eggplanta@108-201-191-115.lightspeed.sntcca.sbcglobal.net)
2021-08-05 21:05:08 <dsal> That's actually a little weird. heh
2021-08-05 21:05:14 <seydar> When we say that Int is an instance of the Ord class, we're saying that Int implements the constraints prescribed by Ord
2021-08-05 21:05:42 × _ht quits (~quassel@82-169-194-8.biz.kpn.net) (Remote host closed the connection)
2021-08-05 21:05:46 <dsal> I don't think we say "Int is an instance of the Ord class" -- the language is slightly backwards there.
2021-08-05 21:05:50 <dsal> We say "Int has an Ord instance"
2021-08-05 21:06:24 <dsal> But otherwise, yeah.
2021-08-05 21:06:52 <seydar> Ordering is just an arbitrary constructor that the Ord class uses in the implementation of `compare` because it needs to return something
2021-08-05 21:06:53 <dsal> The subtle difference is that "Int" doesn't do anything to "implement" the class. The instance can come from somewhere else altogether.
2021-08-05 21:07:16 <dsal> seydar: Yes! Some languages use int there, but that's bad for numerous reasons.
2021-08-05 21:07:18 <seydar> Ordering is a datatype that can be use by anyone and anything and just happens to be used by the Ord class
2021-08-05 21:07:21 × norias quits (~jaredm@c-98-219-195-163.hsd1.pa.comcast.net) (Remote host closed the connection)
2021-08-05 21:09:02 <dsal> Ordering also has a really useful semigroup instance such that you can append multiple orderings together in a useful way. Int can't exactly do that because what it means to append to Ints is too specific to what you're doing.
2021-08-05 21:09:13 <dsal> > EQ <> LT <> GT
2021-08-05 21:09:14 <lambdabot> LT
2021-08-05 21:10:31 <dsal> e.g., you couldn't do something like this if it returned an int:
2021-08-05 21:10:31 <dsal> > (comparing fst <> comparing snd) (0, 'c') (0, 'a')
2021-08-05 21:10:33 <lambdabot> GT
2021-08-05 21:11:26 × dhouthoo quits (~dhouthoo@178-117-36-167.access.telenet.be) (Quit: WeeChat 3.2)
2021-08-05 21:12:35 <dsal> But in general, you can think of the class from the consumer point of view. If I want to write a function that does some addition, I don't need to specify something concrete like an Int or whatever, I just need to specify that the type I'm operating on knows how to add to values of itself together. This lets me work with Ints or types I've never heard of.
2021-08-05 21:13:53 <seydar> Thank you!
2021-08-05 21:13:59 <seydar> This has been super helpful
2021-08-05 21:14:16 × seydar quits (~seydar@154-27-113-252.starry-inc.net) (Quit: leaving)
2021-08-05 21:14:29 hubvu joins (sid495858@tinside.irccloud.com)
2021-08-05 21:18:31 jakalx parts (~jakalx@base.jakalx.net) (Error from remote client)
2021-08-05 21:19:35 jess is now known as j
2021-08-05 21:25:51 × mastarija quits (~mastarija@78-3-210-70.adsl.net.t-com.hr) (Quit: Leaving)
2021-08-05 21:26:31 × eggplantade quits (~Eggplanta@108-201-191-115.lightspeed.sntcca.sbcglobal.net) (Remote host closed the connection)
2021-08-05 21:26:58 × mikoto-chan quits (~mikoto-ch@ip-193-121-10-50.dsl.scarlet.be) (Ping timeout: 240 seconds)
2021-08-05 21:27:15 shailangsa joins (~shailangs@host86-186-142-59.range86-186.btcentralplus.com)
2021-08-05 21:29:47 jakalx joins (~jakalx@base.jakalx.net)
2021-08-05 21:32:15 × MoC quits (~moc@user/moc) (Quit: Konversation terminated!)
2021-08-05 21:34:58 eggplantade joins (~Eggplanta@108-201-191-115.lightspeed.sntcca.sbcglobal.net)
2021-08-05 21:35:34 × machinedgod quits (~machinedg@135-23-192-217.cpe.pppoe.ca) (Ping timeout: 256 seconds)
2021-08-05 21:37:42 arkho joins (~ccc@dynamic-acs-24-112-153-241.zoominternet.net)
2021-08-05 21:46:31 × Brumaire quits (~quassel@81-64-14-121.rev.numericable.fr) (Ping timeout: 258 seconds)
2021-08-05 21:57:11 enoq joins (~enoq@194-208-179-35.lampert.tv)
2021-08-05 21:59:10 × agua_pesada quits (~agua_pesa@2804:14c:8793:8e2f:48b4:3d09:2f3b:552b) (Ping timeout: 258 seconds)
2021-08-05 22:00:52 merijn joins (~merijn@83-160-49-249.ip.xs4all.nl)
2021-08-05 22:03:36 × Atum_ quits (~IRC@user/atum/x-2392232) (Quit: Atum_)
2021-08-05 22:04:22 × eggplantade quits (~Eggplanta@108-201-191-115.lightspeed.sntcca.sbcglobal.net) (Remote host closed the connection)
2021-08-05 22:05:27 × Neuromancer quits (~Neuromanc@user/neuromancer) (Remote host closed the connection)
2021-08-05 22:05:40 × pschorf quits (~user@c-73-77-28-188.hsd1.tx.comcast.net) (Ping timeout: 272 seconds)
2021-08-05 22:08:01 × fendor quits (~fendor@178.115.49.9.wireless.dyn.drei.com) (Remote host closed the connection)
2021-08-05 22:12:20 agua_pesada joins (~agua_pesa@2804:14c:8793:8e2f:48b4:3d09:2f3b:552b)
2021-08-05 22:14:18 × amahl quits (~amahl@dsl-jklbng12-54fbca-64.dhcp.inet.fi) (Ping timeout: 276 seconds)
2021-08-05 22:15:09 typetetris joins (sid275937@tinside.irccloud.com)
2021-08-05 22:18:20 × MQ-17J quits (~MQ-17J@d14-69-206-129.try.wideopenwest.com) (Quit: Quit)
2021-08-05 22:18:20 × xff0x_ quits (~xff0x@2001:1a81:5296:aa00:d57e:94f9:9f5a:1218) (Ping timeout: 258 seconds)
2021-08-05 22:18:34 MQ-17J joins (~MQ-17J@8.21.10.94)
2021-08-05 22:19:08 xff0x_ joins (~xff0x@2001:1a81:5296:aa00:8dc0:fe3f:5c9e:fa3a)
2021-08-05 22:25:07 × sheepduck quits (~sheepduck@user/sheepduck) (Quit: Konversation terminated!)
2021-08-05 22:25:15 meinside_ joins (uid24933@id-24933.brockwell.irccloud.com)
2021-08-05 22:27:12 eggplantade joins (~Eggplanta@108-201-191-115.lightspeed.sntcca.sbcglobal.net)
2021-08-05 22:28:03 × barzo quits (~hd@159.146.18.173) (Read error: Connection reset by peer)
2021-08-05 22:30:00 Guest34 joins (~Guest34@2406:3003:2006:447e:fc93:a477:b13c:4b43)
2021-08-05 22:33:07 × Guest34 quits (~Guest34@2406:3003:2006:447e:fc93:a477:b13c:4b43) (Client Quit)
2021-08-05 22:33:09 × agua_pesada quits (~agua_pesa@2804:14c:8793:8e2f:48b4:3d09:2f3b:552b) (Quit: CoreIRC for Android - www.coreirc.com)
2021-08-05 22:35:26 × merijn quits (~merijn@83-160-49-249.ip.xs4all.nl) (Ping timeout: 272 seconds)
2021-08-05 22:36:41 werneta joins (~werneta@70-142-214-115.lightspeed.irvnca.sbcglobal.net)
2021-08-05 22:36:42 × werneta quits (~werneta@70-142-214-115.lightspeed.irvnca.sbcglobal.net) (Client Quit)
2021-08-05 22:36:52 wrengr is now known as wrengr_away
2021-08-05 22:37:10 werneta joins (~werneta@70-142-214-115.lightspeed.irvnca.sbcglobal.net)
2021-08-05 22:37:31 wrengr_away is now known as wrengr
2021-08-05 22:48:08 × jgeerds quits (~jgeerds@55d45555.access.ecotel.net) (Ping timeout: 252 seconds)
2021-08-05 22:48:33 aman joins (~aman@user/aman)
2021-08-05 22:59:26 dajoer joins (~david@user/gvx)
2021-08-05 23:05:43 × Nahra quits (~user@static.161.95.99.88.clients.your-server.de) (Remote host closed the connection)

All times are in UTC.