Home liberachat/#haskell: Logs Calendar

Logs: liberachat/#haskell

←Prev  Next→ 1,804,084 events total
2021-08-15 18:10:59 <tomsmeding> and then inside of the method in question, loop over that list comparing all the TypeReps, and if there's a match you get the Show dictionary from there
2021-08-15 18:11:02 <hololeap> then you don't get the duplicate instance declarations error
2021-08-15 18:11:25 <opqdonut> hololeap: that's kinda what quickcheck does, except it has a newtype for unshowable things
2021-08-15 18:12:07 <hololeap> there's also all this: https://wiki.haskell.org/GHC/AdvancedOverlap
2021-08-15 18:12:09 <opqdonut> https://hackage.haskell.org/package/QuickCheck-2.14.2/docs/Test-QuickCheck-Modifiers.html#t:Blind
2021-08-15 18:12:15 <tomsmeding> hololeap: how would that allow you do determine whether a particular type 'a' implements Show at runtime?
2021-08-15 18:13:08 <opqdonut> wow that's a nice wiki page
2021-08-15 18:13:19 wroathe joins (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net)
2021-08-15 18:14:38 <hololeap> tomsmeding: why would it need to be known at runtime? wouldn't the compiler catch it first?
2021-08-15 18:14:42 <tomsmeding> oh that's smart; you still need the instance enumeration but then you're done and it's all nice haskell
2021-08-15 18:15:30 <tomsmeding> hololeap: the point (I think) is that we have a method 'foo :: a -> Something' that wants to call foo1 when 'a' is Show, and foo2 otherwise
2021-08-15 18:15:37 <tomsmeding> how would you implement foo using your thing?
2021-08-15 18:16:27 hseg joins (~gesh@IGLD-84-228-238-79.inter.net.il)
2021-08-15 18:16:48 <tomsmeding> I used the word "runtime" because you might still want this to work if foo is used in a polymorphic context, but then later indirectly gets applied to a concrete, Showable type
2021-08-15 18:17:22 <tomsmeding> the wiki version actually wouldn't compile in that situation, I think, because in that polymorphic context, no ShowPred instance could be chosen
2021-08-15 18:17:22 <hololeap> idk, this is what I was playing around with, and it seems to work fine when I load it in GHCi: https://dpaste.com/DMPY66STS
2021-08-15 18:18:14 <tomsmeding> hololeap: would you need to manually wrap the argument in Showable as the caller of foo, with your thing?
2021-08-15 18:18:24 <hololeap> yeah
2021-08-15 18:18:32 <tomsmeding> right, and that's precisely the thing that I was trying to avoid
2021-08-15 18:18:45 <hseg> just ran into the "would be able to make an instance for this class if I could add constraints to some methods" annoyance again. are there any proposals being considered that would make it easier to refactor classes so they could support such instances?
2021-08-15 18:18:58 <tomsmeding> because if you can manually type Showable, then you can also manually type fooShow instead of foo
2021-08-15 18:19:09 <hseg> (classic example: FAM for map-like types)
2021-08-15 18:19:27 <hololeap> tomsmeding: fair point
2021-08-15 18:19:31 <hseg> (in this case, it's a Witherable instance for map-like types)
2021-08-15 18:20:14 <tomsmeding> hseg: there is mono-traversable but that's probably not what you're looking for
2021-08-15 18:20:24 <tomsmeding> since you come asking
2021-08-15 18:21:04 <tomsmeding> that exposes non-type-changing methods like fmap :: (a -> a) -> f a -> f a
2021-08-15 18:21:10 <hseg> no, am asking for the general "will writing classes to support such restrictions become easy enough that I can reasonably push library authors for it"
2021-08-15 18:21:11 <tomsmeding> (s/fmap/omap/)
2021-08-15 18:21:38 <tomsmeding> ah, then no idea
2021-08-15 18:23:34 × Neuromancer quits (~Neuromanc@user/neuromancer) (Ping timeout: 268 seconds)
2021-08-15 18:24:02 <hseg> like, you could unify (Mono)Functor by defining a Functor (-->) (~~>) f where { map :: (a --> b) -> (f a ~~> f b) }, and then instantiate (-->), (~~>) as constrained arrow types
2021-08-15 18:24:58 <tomsmeding> where (-->) and (~~>) implement some class so that they can be called as functions by the implementation of 'map'?
2021-08-15 18:25:07 <hseg> so for MonoFunctor, pass for (-->) something like data MonoidC a b where arrMonoid :: a -> a -> MonoidC a a
2021-08-15 18:25:12 <hseg> y
2021-08-15 18:25:14 <tomsmeding> (well, only -->)
2021-08-15 18:25:29 <hseg> well, depending on your usecase
2021-08-15 18:25:30 × sagax quits (~sagax@213.138.71.146) (Ping timeout: 240 seconds)
2021-08-15 18:25:44 <hseg> like, you could subsume Witherable into Functor with this
2021-08-15 18:25:54 <hseg> by setting ~~> ~ Kleisli Maybe
2021-08-15 18:26:56 <hseg> ofc, at a certain point too much overloading is unclear -- a key point in good design is separating what must be separated, not just unifying what should be unified
2021-08-15 18:27:11 <tomsmeding> without additional language support, this would make calling 'map' quite a bit more cumbersome for the non-(->) cases
2021-08-15 18:28:36 <hseg> yeah. might want some specializations/coercions to help use this
2021-08-15 18:29:04 <hseg> though ig kmett's hask is aiming to go for this
2021-08-15 18:29:05 × notzmv quits (~zmv@user/notzmv) (Ping timeout: 252 seconds)
2021-08-15 18:29:14 <hseg> *this design
2021-08-15 18:29:21 × Vajb quits (~Vajb@hag-jnsbng11-58c3ab-85.dhcp.inet.fi) (Ping timeout: 248 seconds)
2021-08-15 18:29:40 × eggplantade quits (~Eggplanta@108-201-191-115.lightspeed.sntcca.sbcglobal.net) (Remote host closed the connection)
2021-08-15 18:29:42 Vajb joins (~Vajb@hag-jnsbng11-58c3ab-85.dhcp.inet.fi)
2021-08-15 18:30:05 <hseg> still leaves the question open of whether some parts design can/should be pushed into base, and what kind of timescale we're looking at if so
2021-08-15 18:33:12 × euandreh quits (~euandreh@2804:14c:33:9fe5:8577:297f:c78a:d1b2) (Quit: WeeChat 3.2)
2021-08-15 18:36:35 HeisenLearnsHask joins (~HeisenLea@2a02:aa1:1010:e9f8:2cf9:9af4:b41e:73e9)
2021-08-15 18:48:46 Erutuon joins (~Erutuon@user/erutuon)
2021-08-15 18:52:41 × HeisenLearnsHask quits (~HeisenLea@2a02:aa1:1010:e9f8:2cf9:9af4:b41e:73e9) (Quit: Ping timeout (120 seconds))
2021-08-15 18:54:57 × MQ-17J quits (~MQ-17J@d14-69-206-129.try.wideopenwest.com) (Read error: Connection reset by peer)
2021-08-15 18:55:21 MQ-17J joins (~MQ-17J@8.6.144.209)
2021-08-15 18:56:14 mrckndt joins (~mrckndt@user/mrckndt)
2021-08-15 18:57:09 mt404 parts (~mt404@cpe1056118081ac-cm1056118081aa.cpe.net.cable.rogers.com) ()
2021-08-15 18:57:28 × adium_ quits (adium@user/adium) (Remote host closed the connection)
2021-08-15 18:59:37 <kuribas> Is haskell the only language where you mess around two hours, and end up with 20 lines of code?
2021-08-15 19:00:15 <kuribas> It's crazy how you end up with deceivingly simple code (especially using generics).
2021-08-15 19:00:26 <kuribas> That looks like it took 5 minutes.
2021-08-15 19:00:26 <hseg> >:)
2021-08-15 19:00:52 <tomsmeding> kuribas: https://github.com/Co-dfns/Co-dfns/tree/master/cmp
2021-08-15 19:01:21 <kuribas> tomsmeding: I don't even know what that is?
2021-08-15 19:01:25 <tomsmeding> a compiler
2021-08-15 19:01:39 <tomsmeding> see the readme in the root
2021-08-15 19:01:51 <kuribas> ahhhh APL :)
2021-08-15 19:01:55 <tomsmeding> :D
2021-08-15 19:02:42 <tomsmeding> oh it seems there's more stuff here apparently https://github.com/Co-dfns/Co-dfns/blob/master/codfns.dyalog
2021-08-15 19:03:02 <tomsmeding> but yeah, point was lots of stuff in few lines :p
2021-08-15 19:03:19 Arthur joins (IRC@gateway/vpn/airvpn/arthurmelo/x-07739757)
2021-08-15 19:03:23 <kuribas> tomsmeding: but I am not even try to code golf it...
2021-08-15 19:03:36 <tomsmeding> I know, it was not a very serious response :)
2021-08-15 19:03:38 × Arthur quits (IRC@gateway/vpn/airvpn/arthurmelo/x-07739757) (Client Quit)
2021-08-15 19:04:40 <tomsmeding> I guess it mostly depends on what you're doing though. I can spend 2 hours on 50 lines of C code if it's a complicated algorithm and I want to get every detail right
2021-08-15 19:04:56 <tomsmeding> (I replaced 20 with 50 because haskell is more concise than C, but same thing)
2021-08-15 19:05:16 <tomsmeding> I once spent a day on a 100-line recursive mutex implementation in C++
2021-08-15 19:05:38 eggplantade joins (~Eggplanta@108-201-191-115.lightspeed.sntcca.sbcglobal.net)
2021-08-15 19:05:50 <kuribas> but does the C++ code look simple?
2021-08-15 19:06:11 arthur_melo joins (IRC@gateway/vpn/airvpn/arthurmelo/x-07739757)
2021-08-15 19:06:13 <kuribas> It took me two hours to end up with: genCollectFields tables sqid $ splitTranspActMaybe curry prev $ lookupFeature tables sqid
2021-08-15 19:06:16 <tomsmeding> depends on what you call simple :p
2021-08-15 19:06:34 <tomsmeding> that looks very complicated to me, given that I don't know what those functions do :p
2021-08-15 19:06:46 × wallymathieu quits (~wallymath@81-234-151-21-no94.tbcn.telia.com) (Quit: My MacBook has gone to sleep. ZZZzzz…)
2021-08-15 19:06:54 <tomsmeding> if you know what the functions do, it probably looks very simple
2021-08-15 19:07:26 <kuribas> it does if you have an IDE that shows the types.
2021-08-15 19:07:45 × arthur_melo quits (IRC@gateway/vpn/airvpn/arthurmelo/x-07739757) (Client Quit)
2021-08-15 19:07:58 <tomsmeding> the individual operations in that C++ code were quite simple -- no long lines anywhere -- but the code was _very_ complex simply because it tried to do locking right in a multithreading context, and there some delicate things in there
2021-08-15 19:08:25 adium joins (adium@user/adium)
2021-08-15 19:08:28 <tomsmeding> the only complex thing was the comments, so to speak :)
2021-08-15 19:08:36 × vysn quits (~vysn@user/vysn) (Quit: WeeChat 3.2)
2021-08-15 19:09:06 drd joins (~drd@2001:b07:a70:9f1f:1562:34de:f50f:77d4)
2021-08-15 19:09:53 × mei quits (~mei@user/mei) (Ping timeout: 248 seconds)
2021-08-15 19:09:57 <kuribas> sounds very tricky indeed
2021-08-15 19:10:50 vysn joins (~vysn@user/vysn)
2021-08-15 19:11:40 <tomsmeding> haskell does tend to invite fiddling with abstractions more than other languages do, simply because they're closer at hand, I guess :)
2021-08-15 19:11:51 markpythonicbitc joins (~markpytho@2601:647:5a00:35:5f5:523b:3c0:9fe)
2021-08-15 19:12:06 arthur_melo joins (IRC@gateway/vpn/airvpn/arthurmelo/x-07739757)
2021-08-15 19:12:16 <tomsmeding> and fiddling with abstractions means writing and re-writing the same code until it has the structure you want, and repeated code-rewriting has the effect of producing little code in the end

All times are in UTC.