Home freenode/#haskell: Logs Calendar

Logs: freenode/#haskell

←Prev  Next→ 502,152 events total
2020-11-20 12:44:28 mlugg joins (c3c2162d@195.194.22.45)
2020-11-20 12:44:45 × kritzefitz quits (~kritzefit@fw-front.credativ.com) (Ping timeout: 240 seconds)
2020-11-20 12:45:53 <ski> Martinsos : "But to me implementing \"OO\" approach in Haskell doesn't seem much harder, we can do it with type classes right?" -- you may note that i haven't mentioned type classes at all. (and the main reason i started talking about this now was to steer you away from comparing with type classes right away). if you do the exercise i suggested, you should not be defining any type classes at all, nor making
2020-11-20 12:45:59 <ski> any instances of any such
2020-11-20 12:46:52 <cads> hey would anyone be willing to pair program with me and show me how they set up and deploy a haskell based microservice?
2020-11-20 12:47:09 <cads> say, something that I can send a string to, and it'll send me back the Sha3-512
2020-11-20 12:47:17 <cads> asking a lot
2020-11-20 12:47:23 <cads> whadda say?
2020-11-20 12:48:06 <ski> Martinsos : and yes, doing the product/record types approach in Haskell is not that hard (but perhaps it must be pointed out to someone that it's possible, if it doesn't occur immediately as an alternative). which is another reason the "FP" term is crude. as is the "OO" term, since OO tends to also include things like implementation inheritance, and open recursion. you can do those in Haskell as well, but
2020-11-20 12:48:12 <ski> you have to do a little bit more work (especially for open recursion)
2020-11-20 12:48:41 gproto023 joins (~gproto23@unaffiliated/gproto23)
2020-11-20 12:49:02 <ski> Martinsos : "Ok here you are basically implementing type classes manually right?" -- emphatically no
2020-11-20 12:49:16 <cads> in return, I can offer to close a bug report in a python script of your choice (within 1 to 2 hours of labor)
2020-11-20 12:49:43 mlugg76 joins (68eeaaef@104.238.170.239)
2020-11-20 12:49:49 <absence> why can i pass a (forall a. IsString a => a) to a function that expects String?
2020-11-20 12:49:51 niko joins (~niko@freenode/staff/ubuntu.member.niko)
2020-11-20 12:50:09 <merijn> absence: Because "instance IsString String"? :)
2020-11-20 12:50:17 <merijn> :t fromString "foo"
2020-11-20 12:50:19 <lambdabot> IsString a => a
2020-11-20 12:50:25 <merijn> > fromString "foo" :: String
2020-11-20 12:50:27 <lambdabot> "foo"
2020-11-20 12:50:31 <ski> absence : because it has type `a', for every type `a' that is an instance of `IsString'. and since `String' is such a type, your input (also) has type `String'
2020-11-20 12:50:38 <mlugg76> (the other mlugg is a timed-out me, sorry!) Can you define a typeclass instance for a type family? E.g. if I have a type family like https://termbin.com/o4le, since every instance of the family has a `Show` instance, can I make `show :: Foo a -> String` valid?
2020-11-20 12:50:54 × mlugg quits (c3c2162d@195.194.22.45) (Ping timeout: 245 seconds)
2020-11-20 12:50:58 <merijn> mlugg76: "no"
2020-11-20 12:51:12 mlugg76 is now known as mlugg
2020-11-20 12:51:14 <merijn> mlugg76: Because a type family is basically a type level function
2020-11-20 12:51:16 <ski> if
2020-11-20 12:51:21 <ski> foo :: forall a. IsString a => a
2020-11-20 12:51:23 da39a3ee5e6b4b0d joins (~da39a3ee5@mx-ll-171.5.161-165.dynamic.3bb.co.th)
2020-11-20 12:51:23 <ski> then also
2020-11-20 12:51:29 × gproto23 quits (~gproto23@unaffiliated/gproto23) (Ping timeout: 256 seconds)
2020-11-20 12:51:32 <absence> merijn, ski: ah, so the fact that the function expects String forces the a to be String via the instance, that makes sence. thanks!
2020-11-20 12:51:33 <ski> foo :: IsString String => String
2020-11-20 12:51:37 <mlugg> merijn: okay, ty
2020-11-20 12:51:45 <ski> and since `IsString String' holds, we further have
2020-11-20 12:51:49 <ski> foo :: String
2020-11-20 12:52:00 <merijn> mlugg: Basically "Foo a" is not a parameteric type, it's "the result of the Foo type family applied to 'a'"
2020-11-20 12:52:19 <ski> absence : so, you're specializing your (overloaded) polymorphic value, to type `String', before passing it to the function. you're passing a `String'
2020-11-20 12:52:34 <merijn> mlugg: So if you have "type instance Foo Bool = Int" (or whatever the right syntax is, then "Foo Bool" isn't 'Foo' (with it's instance) it's "Int"
2020-11-20 12:52:52 <ski> absence, yep
2020-11-20 12:54:55 <ski> Martinsos : btw, you might note that with `Circle = Double',`Rectangle = Double * Double', you have `ShapeS = Circle + Rectangle'. similarly, with `Perimeter = Double',`Area = Double', you have `ShapeP = Perimeter * Area'
2020-11-20 12:56:05 ski . o O ( <https://en.wikipedia.org/wiki/Additive_category#Matrix_representation_of_morphisms> )
2020-11-20 12:56:45 Chi1thangoo joins (~Chi1thang@87.112.60.168)
2020-11-20 12:57:08 kritzefitz joins (~kritzefit@fw-front.credativ.com)
2020-11-20 12:58:36 <ski> MarcelineVQ : "which one is better, if one does not have a ton of information on how the codebase will evolve?" -- i'm not sure there's a good general answer to this. "it depends"
2020-11-20 12:58:40 <ski> er, sorry
2020-11-20 12:58:44 <ski> Martinsos ^
2020-11-20 13:00:02 directhex1 joins (~directhex@195.206.169.184)
2020-11-20 13:00:59 <Martinsos> ski: Thanks for all these explanations, this is great! Hm hm hm. I will try to play with the example more later, but I think I do get the concept. I don't quite understand the problem with recursion, but I can tackle that once I encounter it. And thanks for that link, I will check it in more depth.
2020-11-20 13:01:50 <ski> Martinsos : you can also compare sum/variant/"FP" vs. product/record/"OO" with Deep vs. Shallow embedding, see <https://wiki.haskell.org/Embedded_domain_specific_language>. in this comparision, think of the record version as usually having just one field, but there's nothing stopping someone from doing a shallow embedding with "multiple alternative interpretations" (perhaps a "main/intended" one, and some
2020-11-20 13:01:56 <ski> auxilary ones)
2020-11-20 13:02:20 gproto0023 joins (~gproto23@unaffiliated/gproto23)
2020-11-20 13:02:20 jonatanb joins (jonatanb@gateway/vpn/protonvpn/jonatanb)
2020-11-20 13:02:27 <Martinsos> ski++
2020-11-20 13:02:30 texasmynsted joins (~texasmyns@212.102.45.109)
2020-11-20 13:02:39 ski twitches
2020-11-20 13:03:24 × acidjnk_new2 quits (~acidjnk@p200300d0c719ff35956387e811e01df5.dip0.t-ipconnect.de) (Ping timeout: 240 seconds)
2020-11-20 13:04:25 × gproto023 quits (~gproto23@unaffiliated/gproto23) (Ping timeout: 240 seconds)
2020-11-20 13:05:04 urodna joins (~urodna@unaffiliated/urodna)
2020-11-20 13:06:10 <ski> e.g. for an idiomatic/applicative parser, you could both compute the main parsing action, that is fed parsing input, and does its work. but also compute, "on the side" ("statically", before parsing even starts), `NULLABLE' (can it succeed, consuming no input),`FIRST' (what are the possible tokens that could start an input that is accepted by the parser), for efficiency purposes
2020-11-20 13:08:27 <ski> or, i once did a CGI monad thing, that contained a "play" and a "replay" part. when it emits a form, it generates a page. then when the form is filled in and replied, the computation starts over, but replaying the already done parts, until it gets to the point where it stopped last
2020-11-20 13:08:31 <dminuoso> I finally it, a use for unsafeCatchPure :: Exception e => a -> (e -> a) -> a
2020-11-20 13:08:34 <dminuoso> An evil one ontop!
2020-11-20 13:08:56 <merijn> Is there a non-evil one?
2020-11-20 13:09:25 <dminuoso> No idea, but it's either that or invest a lot of work in phadej's tree-diff
2020-11-20 13:09:28 zariuq joins (~zar@fw1.ciirc.cvut.cz)
2020-11-20 13:09:35 <Martinsos> ski: You slightly lost me there :D, I am afraid this is beyond my current Haskell knowledge, but I stored these more advanced things you said for later reading once I am more knowleagdable :D!
2020-11-20 13:09:39 <dminuoso> Im gonna use pure exceptions to modify control flow!
2020-11-20 13:09:40 <merijn> tree-diif is some fantastic stuff
2020-11-20 13:09:53 <dminuoso> Indeed, it just lacks one thing we sorely miss
2020-11-20 13:09:56 <merijn> dminuoso: I will haunt you until your death
2020-11-20 13:10:08 <ski> (the category theory link is related, but will require some mbackground. and it's not too essential, it's just an "in case you know about CT, this might be interesting to compare to")
2020-11-20 13:11:08 drbean joins (~drbean@TC210-63-209-197.static.apol.com.tw)
2020-11-20 13:11:36 <dminuoso> merijn: No but seriously. The main issue with tree-diff is if you have Rec "foo" (M.fromList [("keyA", 1), ("keyB", 2)]) vs Rec "foo" (M.fromList [("keyA", 1)])
2020-11-20 13:11:54 <dminuoso> There's sadly no way to represent deletion of keys
2020-11-20 13:12:00 <dminuoso> Which causes a lot of ugliness
2020-11-20 13:12:16 <dminuoso> or uh
2020-11-20 13:12:23 <dminuoso> Rec "foo" (M.fromList [("keyA", ...), ("keyB", ...)])
2020-11-20 13:12:33 <dminuoso> Rec "foo" (M.fromList [("keyA", ...)])
2020-11-20 13:12:58 <dminuoso> Instead, you get a Swp operation on the record, and del/add operations on the value pointed by the key
2020-11-20 13:13:12 fendor_ is now known as fendor
2020-11-20 13:13:19 <dminuoso> Im trying really hard to hack this into the Pretty dictionary
2020-11-20 13:14:07 <dminuoso> (or actually, I think its even a Cpy on the record?)
2020-11-20 13:14:57 raehik joins (~raehik@cpc95906-rdng25-2-0-cust156.15-3.cable.virginm.net)
2020-11-20 13:16:44 hlisp joins (~hlisp@223.71.166.151)
2020-11-20 13:18:11 × p-core quits (~Thunderbi@2001:718:1e03:5128:2ab7:7f35:48a1:8515) (Remote host closed the connection)
2020-11-20 13:18:39 × hlisp quits (~hlisp@223.71.166.151) (Remote host closed the connection)
2020-11-20 13:19:39 cfricke joins (~cfricke@unaffiliated/cfricke)
2020-11-20 13:21:38 <ski> Martinsos : anyway .. OO can also be related to lexical/static scoping (in particular non-local variable references. commonly implemented as "closures"), but alternatively also in terms of existential types. Abstract Data Types can also be related to existential types, but in a different way (leading to different ways of and issues with, structuring code)
2020-11-20 13:21:45 <ski> @where on-understanding
2020-11-20 13:21:45 <lambdabot> "On Understanding Types, Data Abstraction, and Polymorphism" by Luca Cardelli,Peter Wegner in 1985-12 at <http://lucacardelli.name/Papers/OnUnderstanding.A4.pdf>
2020-11-20 13:21:48 <ski> @where on-understanding-revisited
2020-11-20 13:21:48 <lambdabot> "On Understanding Data Abstraction, Revisited" by William R. Cook in 2009-10 at <http://www.cs.utexas.edu/~wcook/Drafts/2009/essay.pdf>
2020-11-20 13:23:33 <ski> the latter talks about this. the former talks about different senses of "polymorphism", and also about ADTs as existentials
2020-11-20 13:24:39 × mlugg quits (68eeaaef@104.238.170.239) (Ping timeout: 245 seconds)
2020-11-20 13:26:34 × ClaudiusMaximus quits (~claude@unaffiliated/claudiusmaximus) (Read error: Connection reset by peer)
2020-11-20 13:26:55 <ski> "Polymorphic Type Inference" by Michael I. Schwartzbach in 1995-03 at <https://cs.au.dk/~amoeller/mis/typeinf.p(sdf|df)>,<https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.57.1493> might be interesting to learn more basics of type systems, type inference, also mentioning universals and existentials
2020-11-20 13:27:05 <ski> .. but all this is probably a discussion for another day
2020-11-20 13:27:19 × gxt quits (~gxt@gateway/tor-sasl/gxt) (Quit: WeeChat 2.9)

All times are in UTC.