Home freenode/#haskell: Logs Calendar

Logs: freenode/#haskell

←Prev  Next→ 502,152 events total
2021-05-06 05:49:14 zaquest joins (~notzaques@5.128.210.178)
2021-05-06 05:57:40 Kortantic joins (43b122a6@c-67-177-34-166.hsd1.ut.comcast.net)
2021-05-06 05:58:11 × pieguy128_ quits (~pieguy128@bas1-quebec14-67-70-101-46.dsl.bell.ca) (Quit: ZNC 1.8.2 - https://znc.in)
2021-05-06 05:58:30 pieguy128 joins (~pieguy128@bras-base-mtrlpq5031w-grc-47-67-70-101-46.dsl.bell.ca)
2021-05-06 05:58:40 × Kortantic quits (43b122a6@c-67-177-34-166.hsd1.ut.comcast.net) (Client Quit)
2021-05-06 06:02:25 tromp joins (~tromp@dhcp-077-249-230-040.chello.nl)
2021-05-06 06:03:08 <xerox_> can anyone think of a different way to write this that is somehow better? https://pastebin.com/raw/i0RG2Dkc I can't see how to avoid producing the Bool and just use the result of the guard comparison whilst returning the correct second element of the pair, conditional on the direction
2021-05-06 06:04:59 <xerox_> lil typo on the directions while massaging this down to a more manageable snippet of code :) https://pastebin.com/raw/8xtjrCMS
2021-05-06 06:06:50 × tromp quits (~tromp@dhcp-077-249-230-040.chello.nl) (Ping timeout: 246 seconds)
2021-05-06 06:06:54 × nbloomf quits (~nbloomf@2600:1700:ad14:3020:3c82:1c53:1e38:e2d9) (Quit: My MacBook has gone to sleep. ZZZzzz…)
2021-05-06 06:08:52 nicholasbulka joins (~nicholasb@2601:900:4301:da0:d09a:226b:917d:ae5f)
2021-05-06 06:09:00 cole-h joins (~cole-h@c-73-48-197-220.hsd1.ca.comcast.net)
2021-05-06 06:09:36 thc202 joins (~thc202@unaffiliated/thc202)
2021-05-06 06:11:35 Codaraxis joins (~Codaraxis@92.223.89.162)
2021-05-06 06:12:46 × myShoggoth quits (~myShoggot@97-120-89-117.ptld.qwest.net) (Ping timeout: 240 seconds)
2021-05-06 06:14:27 × nicholasbulka quits (~nicholasb@2601:900:4301:da0:d09a:226b:917d:ae5f) (Ping timeout: 250 seconds)
2021-05-06 06:15:18 × Codaraxis_ quits (~Codaraxis@ip68-5-90-227.oc.oc.cox.net) (Ping timeout: 260 seconds)
2021-05-06 06:16:53 × wonko7 quits (~wonko7@62.115.229.50) (Quit: See You Space Cowboy..)
2021-05-06 06:16:59 _ht joins (~quassel@82-169-194-8.biz.kpn.net)
2021-05-06 06:23:19 tromp joins (~tromp@dhcp-077-249-230-040.chello.nl)
2021-05-06 06:24:23 × Tene quits (~tene@poipu/supporter/slacker/tene) (Ping timeout: 252 seconds)
2021-05-06 06:24:32 × ByronJohnson quits (~bairyn@unaffiliated/bob0) (Ping timeout: 240 seconds)
2021-05-06 06:25:47 anandprabhu joins (~AnandPrab@94.202.236.255)
2021-05-06 06:25:59 <siers> what am I doning wrong here? http://sprunge.us/aLE3jD instance (Enum a) => (Cyclic a) where ... is complaining about Illegal isntance declaration
2021-05-06 06:27:03 malumore joins (~malumore@151.62.126.202)
2021-05-06 06:29:52 × mceier quits (~mceier@89-68-132-187.dynamic.chello.pl) (Ping timeout: 240 seconds)
2021-05-06 06:30:00 × toppler quits (~user@mtop.default.momentoftop.uk0.bigv.io) (Read error: Connection reset by peer)
2021-05-06 06:30:20 cfricke joins (~cfricke@unaffiliated/cfricke)
2021-05-06 06:30:21 toppler joins (~user@mtop.default.momentoftop.uk0.bigv.io)
2021-05-06 06:31:01 <Axman6> What does the error say? I think it tells yuo how to fix the problem ;)
2021-05-06 06:35:28 <siers> ah, I guess a1 is needed in T a1 ... an, but I have just T
2021-05-06 06:35:51 bahamas joins (~lucian@unaffiliated/bahamas)
2021-05-06 06:36:24 mceier joins (~mceier@89-68-132-187.dynamic.chello.pl)
2021-05-06 06:37:58 danvet joins (~Daniel@2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa)
2021-05-06 06:39:59 <siers> ok, I still can't write it http://sprunge.us/lAcoqZ
2021-05-06 06:41:53 <siers> the idea is to get Cyclic instances free for all bounded enums
2021-05-06 06:44:42 xprl-gjf joins (~gavin@98.154.147.147.dyn.plus.net)
2021-05-06 06:47:26 nut joins (~gtk@roc37-h01-176-170-197-243.dsl.sta.abo.bbox.fr)
2021-05-06 06:47:54 Varis joins (~Tadas@unaffiliated/varis)
2021-05-06 06:48:19 ddellaco_ joins (~ddellacos@ool-44c73afa.dyn.optonline.net)
2021-05-06 06:48:28 × tzh quits (~tzh@c-24-21-73-154.hsd1.or.comcast.net) (Quit: zzz)
2021-05-06 06:52:06 × geowiesnot quits (~user@i15-les02-ix2-87-89-181-157.sfr.lns.abo.bbox.fr) (Ping timeout: 260 seconds)
2021-05-06 06:52:41 × ddellaco_ quits (~ddellacos@ool-44c73afa.dyn.optonline.net) (Ping timeout: 260 seconds)
2021-05-06 06:58:20 michalz joins (~user@185.246.204.43)
2021-05-06 07:03:12 olle joins (~olle@i577BC827.versanet.de)
2021-05-06 07:04:42 × sord937 quits (~sord937@gateway/tor-sasl/sord937) (Remote host closed the connection)
2021-05-06 07:05:03 sord937 joins (~sord937@gateway/tor-sasl/sord937)
2021-05-06 07:05:39 × stree quits (~stree@68.36.8.116) (Ping timeout: 246 seconds)
2021-05-06 07:05:46 × howdoi quits (uid224@gateway/web/irccloud.com/x-txrflotqmtwxkura) (Quit: Connection closed for inactivity)
2021-05-06 07:06:24 <olle> Question about code organization. Imagine you have a Point module, properties x and y, and three functions: save, draw, area
2021-05-06 07:06:43 <olle> You also have Rectangle
2021-05-06 07:06:56 <olle> And you want to organize modules in different shapes
2021-05-06 07:07:55 <olle> Rectangle has properties two points (bottomLeft, topRight)
2021-05-06 07:08:45 <olle> In an OOP perspective, it was an open question if save and draw belongs together with area or not, since save and draw are both effectful and depend on services from the outside, say dbConnection and surface.
2021-05-06 07:09:50 <olle> But I guess in FP you'd just do type shape = Point {x, y} | Rectangle {Point, Point}, and then area would pattern match on all shapes.
2021-05-06 07:09:54 × toppler quits (~user@mtop.default.momentoftop.uk0.bigv.io) (Read error: Connection reset by peer)
2021-05-06 07:10:07 <tdammers> that depends on the kind of extensibility you need
2021-05-06 07:10:15 <tdammers> and how far you want to take type safety
2021-05-06 07:10:15 toppler joins (~user@mtop.default.momentoftop.uk0.bigv.io)
2021-05-06 07:10:18 <olle> tdammers: That's the thing, right?
2021-05-06 07:10:36 <olle> In OOP it's also a question of class vs modular cohesion.
2021-05-06 07:10:50 × Rudd0 quits (~Rudd0@185.189.115.103) (Ping timeout: 260 seconds)
2021-05-06 07:11:03 <tdammers> you could just do `data Shape = Shape { shapeType :: Text, shapeData :: [Point] }`, and then validate data on the consumer side
2021-05-06 07:12:10 <tdammers> but you actually have several decisions to make here
2021-05-06 07:12:33 <tdammers> first one is what the data structures themselves look like, second one is how you design operations on them
2021-05-06 07:13:24 <tdammers> for the second one, I'd recommend a mindset of "pushing effects out to the edges" - that is, aim to keep as much of your logic as possible free of effects
2021-05-06 07:13:45 × Varis quits (~Tadas@unaffiliated/varis) (Remote host closed the connection)
2021-05-06 07:14:15 <tdammers> for example, your first design for `save` might be that each type of shape has its own distinct code for storing it in a database. that's fine in principle, but it means that you have effects close to your core data structures
2021-05-06 07:14:41 <tdammers> instead, you could try and push that effectfulness out, by defining an auxiliary type that sits between the pure logic and the database
2021-05-06 07:15:20 royal_screwup213 joins (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9)
2021-05-06 07:16:42 <tdammers> e.g., you could have data Point = Point Double Double; data Rectangle = Rectangle Point Point; and then *also* data DBShape { shapeType :: ShapeType, shapeData :: [Point] }. And then you'd say class IsDBShape a where { toDBShape :: a -> ToDBShape; fromDBShape :: DBShape -> Maybe a }, write instances for both shapes, and write a generic save function that stores DBShapes
2021-05-06 07:17:27 <olle> tdammers: OK, so here's a goal: When adding a new shape, say Circle, I shouldn't have to touch old code.
2021-05-06 07:18:27 Varis joins (~Tadas@unaffiliated/varis)
2021-05-06 07:18:49 stree joins (~stree@68.36.8.116)
2021-05-06 07:19:00 <tdammers> that's pretty much impossible. it's impossible in OOP too.
2021-05-06 07:19:11 <tdammers> you will have to touch *something*
2021-05-06 07:19:27 <olle> Actually, you can use reflection in OOP to load dynamically whatever.
2021-05-06 07:19:31 <olle> But yeah
2021-05-06 07:19:38 × royal_screwup213 quits (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9) (Ping timeout: 246 seconds)
2021-05-06 07:19:54 <dibblego> it's possible, but not with reflection
2021-05-06 07:19:57 × jacks2 quits (~bc8134e3@217.29.117.252) (Quit: http://www.okay.uz/)
2021-05-06 07:19:59 olligobber joins (olligobber@gateway/vpn/privateinternetaccess/olligobber)
2021-05-06 07:20:03 <olle> tdammers: Would you put dbshape in a separate module?
2021-05-06 07:20:07 jacks2 joins (~bc8134e3@217.29.117.252)
2021-05-06 07:20:19 <dibblego> FWIW, a good chunk of my day job is deleting code that uses reflection, and actually solving the problem
2021-05-06 07:20:36 <olle> ^^
2021-05-06 07:20:51 <jacks2> olle, what other properties does each shape have, besides a list of Point, and a name?
2021-05-06 07:21:23 <olle> jacks2: that should be "open", I guess, e.g. 5 years later someone decides to make everything 3D instead. :)
2021-05-06 07:21:37 <olle> And then point has x, y, z, etc
2021-05-06 07:21:53 <tdammers> "make everything 3D" is a different concern than "adding more shape types", and requires different facilitation
2021-05-06 07:21:53 gehmehgeh joins (~ircuser1@gateway/tor-sasl/gehmehgeh)
2021-05-06 07:21:59 <olle> Absolutely.
2021-05-06 07:22:07 <olle> It's the expression problem.
2021-05-06 07:22:16 <tdammers> if you want to extend the Point type, you could go `data Shape p = Point p | Rectangle p p`
2021-05-06 07:22:39 <olle> But, about functional core/pushing effects out - there's no OOP concept for "pure" vs "effectful" classes, other than "entity/domain class" and "service/resource class", which is a shame.
2021-05-06 07:22:41 alexander joins (~alexander@2a02:587:dc0a:2700:39fb:67a3:1f47:16d)
2021-05-06 07:22:41 <tdammers> and then you can use Shape Point2 or Shape Point3 as you see fit
2021-05-06 07:22:49 <dibblego> class PointLike p f a where _Point :: Optic' p f a Point
2021-05-06 07:23:06 <jacks2> olle, make everything 3d, as in draw a shape in 3d? and your current version, would draw it in 2d?
2021-05-06 07:23:10 alexander is now known as Guest99456

All times are in UTC.