Home freenode/#haskell: Logs Calendar

Logs: freenode/#haskell

←Prev  Next→
Page 1 .. 80 81 82 83 84 85 86 87 88 89 90 .. 5022
502,152 events total
2020-09-20 01:18:13 <MarcelineVQ> fyi using record syntax on sum types like this is avoided for that reason, if you forget to make sure what constructor you have your field accesor could crash your program since it might try to get 'index' from LBSNode which doesn't have one
2020-09-20 01:18:33 <divVerent> same in the second one
2020-09-20 01:18:43 × ntwhaaci^ quits (ntwoaaci@ip98-184-89-2.mc.at.cox.net) ()
2020-09-20 01:19:00 <divVerent> yes, but here technically the compiler should already know which record case is taken
2020-09-20 01:19:33 <OmegaDoug> Is there a way in to tell stack where to write the executable when running "stack build"? I'd like to put in the root of the "stack-work" folder.
2020-09-20 01:19:44 <sim590> MarcelineVQ: OK, but on line 120, I'm using the "same technique" but it doesn't complain. Am I not?
2020-09-20 01:20:03 <sim590> Oh I'm sorry. You said the right side, so it's not the same thing
2020-09-20 01:20:09 × xpika quits (~alan@2001:8003:5d32:1f00:65e7:740e:363f:f90f) (Ping timeout: 244 seconds)
2020-09-20 01:20:15 <lechner> jumper149: thanks!
2020-09-20 01:20:27 <sim590> But isn't the type of the right side determined by the left side since l is just the name of the pattern matched?
2020-09-20 01:21:07 <lechner> what is the difference between the <- and the =<< operator, please?
2020-09-20 01:21:49 <MarcelineVQ> sim590: afaict the issue is that you're updating `l` and `l` might not always have `index` as a field, appearantly pattern matching it didn't inform ghc that `l` is LBSLeaf and thus safe. I think this is weird but is the only explanation I can think of
2020-09-20 01:21:51 <ski> lechner : `=<<' is an ordinary operator, defined in a library. `<-' is special syntax, like `=' or `::'
2020-09-20 01:21:55 <jumper149> lechner: First of all <- is a keyword and part of the do-nation and =<< is a function
2020-09-20 01:22:16 <ski> @type (=<<)
2020-09-20 01:22:17 <lambdabot> Monad m => (a -> m b) -> m a -> m b
2020-09-20 01:23:25 <ski> f =<< act = do x <- act
2020-09-20 01:23:28 <ski> f x
2020-09-20 01:23:39 <ski> is how it could be defined
2020-09-20 01:23:56 <ski> (the actual definition is probably something like
2020-09-20 01:23:59 <ski> @src =<<
2020-09-20 01:23:59 <lambdabot> f =<< x = x >>= f
2020-09-20 01:24:00 <lechner> ski: thanks, that's what I thought!
2020-09-20 01:24:14 <MarcelineVQ> sim590: I'm could be wrong though, something about that warning is bugging me
2020-09-20 01:24:24 <ski> where the `do'-notation syntactic sugar expands to calls to `>>=' (and `>>'))
2020-09-20 01:25:09 <ski> `<-' is part of `do'-notation (the same symbol `<-' is also used in list comprehensions)
2020-09-20 01:25:22 × thc202 quits (~thc202@unaffiliated/thc202) (Ping timeout: 260 seconds)
2020-09-20 01:25:33 <sim590> MarcelineVQ: Yeah... I find that weird also. It really seems to be related to https://gitlab.haskell.org/ghc/ghc/-/issues/5728, but this issue is quite old and since they flagged it as a duplicate of some issue that they claim having fixed, I'm a bit confused.
2020-09-20 01:26:25 <MarcelineVQ> the answer is likely in the haskell report or ghc manual since it's related to record update syntax
2020-09-20 01:27:00 × nbloomf quits (~nbloomf@104-183-67-6.lightspeed.fyvlar.sbcglobal.net) (Quit: My MacBook has gone to sleep. ZZZzzz…)
2020-09-20 01:29:02 <MarcelineVQ> sim590: really though the answer you're gonna get mostly is do not use record syntax for sum types like Trees :>
2020-09-20 01:30:00 × merijn quits (~merijn@83-160-49-249.ip.xs4all.nl) (Ping timeout: 272 seconds)
2020-09-20 01:30:26 <sim590> MarcelineVQ: but I'm really just updating a Node inside a Tree, not the Tree itself!
2020-09-20 01:30:44 <sim590> I mean that I have a complex type that is a the Node here. It's LBSNode.
2020-09-20 01:30:47 × acidjnk_new2 quits (~acidjnk@p200300d0c7365818803e8c849f4b43fc.dip0.t-ipconnect.de) (Ping timeout: 240 seconds)
2020-09-20 01:31:20 justsomeguy joins (~justsomeg@unaffiliated/--/x-3805311)
2020-09-20 01:31:27 <ski> > Node {rootLabel = (),subForest = []}
2020-09-20 01:31:30 <lambdabot> Node {rootLabel = (), subForest = []}
2020-09-20 01:31:31 <ski> > (Node) {rootLabel = (),subForest = []}
2020-09-20 01:31:33 <lambdabot> error:
2020-09-20 01:31:33 <lambdabot> • Couldn't match expected type ‘Tree a1’
2020-09-20 01:31:33 <lambdabot> with actual type ‘a0 -> Forest a0 -> Tree a0’
2020-09-20 01:33:18 <MarcelineVQ> But you are updating a tree, `index` takes a tree not a leaf, it just only works if the tree was a leaf right?
2020-09-20 01:33:37 <MarcelineVQ> this is the most relevant report section I can find https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-490003.15
2020-09-20 01:34:20 <MarcelineVQ> starting with "data T = T1 { y :: Int } | T2 { y :: Bool } -- BAD" :>
2020-09-20 01:35:33 <sim590> MarcelineVQ: no. Look at the full file: http://sprunge.us/PxW93j. The type of `index` is `LBSNode a -> Int`. A LBSNode has a LBSLeaf as constructor.
2020-09-20 01:35:38 nbloomf joins (~nbloomf@2600:1700:83e0:1f40:b852:f831:8cd4:429)
2020-09-20 01:36:13 × maroloccio quits (~marolocci@2a02:8084:601d:7f80:164f:8aff:fed8:411d) (Ping timeout: 272 seconds)
2020-09-20 01:36:46 <MarcelineVQ> alright then, a sum datatype still
2020-09-20 01:37:06 <MarcelineVQ> All that aside what I'd try, if I wanted to keep the labels, is probably incIndex LBSLeaf{index = i, leafContent = c} = return $ LBSLeaf {index = i+amount, leafContent = c}
2020-09-20 01:37:36 <MarcelineVQ> so that we're not updating `l` but making a LBSLeaf
2020-09-20 01:37:46 <MarcelineVQ> and you can probably use RecordWildcards or punning to shorten that if you want
2020-09-20 01:38:32 <MarcelineVQ> idk if that's the exact right syntax for record construction since I've never really needed to do it, hopefully the idea comes across
2020-09-20 01:39:00 <ski> it is
2020-09-20 01:39:22 <sim590> Hmmm. Yeah. I guess I can do that in order to avoid the warning. But definitely, GHC should not display a warning in principle. May be I can file a bug.
2020-09-20 01:39:23 <ski> (also that `$' is redundant)
2020-09-20 01:39:38 <MarcelineVQ> Really ghc should be satisfied that you matched on LBSLeaf but it's being a bit of a penis
2020-09-20 01:40:08 × oxide quits (~lambda@unaffiliated/mclaren) (Ping timeout: 272 seconds)
2020-09-20 01:40:18 <MarcelineVQ> satisfied as in: should understand that `l` has to be LBSLeaf
2020-09-20 01:40:58 eric joins (~eric@2804:431:c7d4:402a:4dc9:97ef:220b:73aa)
2020-09-20 01:41:34 × jumper149 quits (~jumper149@ip185225.wh.uni-hannover.de) (Quit: WeeChat 2.9)
2020-09-20 01:42:14 jumper149 joins (~jumper149@ip185225.wh.uni-hannover.de)
2020-09-20 01:43:11 × jumper149 quits (~jumper149@ip185225.wh.uni-hannover.de) (Client Quit)
2020-09-20 01:43:47 jumper149 joins (~jumper149@ip185225.wh.uni-hannover.de)
2020-09-20 01:44:04 <sim590> Yeah. So, this is a bug. May be it's already reported.. Ahhh. 4,060 bugs to look through. Mehhhh. ;).
2020-09-20 01:45:23 <sim590> Is there a performance difference between both ways of writing it? What I mean is Between record-update and Construction of the same type with the same values. Will GHC be able use some properties of persistent data structure in order to avoid copying things? Does update-record even do that?
2020-09-20 01:45:43 × eric quits (~eric@2804:431:c7d4:402a:4dc9:97ef:220b:73aa) (Ping timeout: 272 seconds)
2020-09-20 01:45:56 × gestone quits (~gestone@c-98-225-37-68.hsd1.wa.comcast.net) (Ping timeout: 256 seconds)
2020-09-20 01:47:27 hackage regex-pcre-builtin 0.95.1.1.8.44 - PCRE Backend for "Text.Regex" (regex-base) https://hackage.haskell.org/package/regex-pcre-builtin-0.95.1.1.8.44 (AudreyTang)
2020-09-20 01:47:42 × jumper149 quits (~jumper149@ip185225.wh.uni-hannover.de) (Client Quit)
2020-09-20 01:48:27 hackage source-constraints 0.0.2 - Source constraints GHC plugin https://hackage.haskell.org/package/source-constraints-0.0.2 (mbj)
2020-09-20 01:48:31 <MarcelineVQ> Pretty much the same steps are taken regardless.
2020-09-20 01:48:54 <MarcelineVQ> check out the translation table in section 3.15.3
2020-09-20 01:49:23 kleisli_ joins (~kleisli@2600:1700:4640:c560:68bd:9d76:dbd8:24e7)
2020-09-20 01:49:45 <MarcelineVQ> Either you case and build a record or update syntax is gonna case and build a record
2020-09-20 01:50:18 <MarcelineVQ> Which is surely also our source for the unmatched pattern warning
2020-09-20 01:51:38 <ski> (hm, in Mercury, if it can prove the old reference is unique, it will do an update-in-place, iirc)
2020-09-20 01:52:20 Jeanne-Kamikaze joins (~Jeanne-Ka@static-198-54-131-172.cust.tzulo.com)
2020-09-20 01:52:34 jumper149 joins (~jumper149@ip185225.wh.uni-hannover.de)
2020-09-20 01:52:34 <MarcelineVQ> ski: ghc is probably smarter than the report here, but just based on this it's not something to be too concerned about
2020-09-20 01:53:03 gestone joins (~gestone@c-98-225-37-68.hsd1.wa.comcast.net)
2020-09-20 01:53:15 <MarcelineVQ> sim590: it you're worried about it it could be an interesting benchmark to do
2020-09-20 01:54:28 × jumper149 quits (~jumper149@ip185225.wh.uni-hannover.de) (Client Quit)
2020-09-20 01:54:40 × kyagrd__ quits (sid102627@gateway/web/irccloud.com/x-mzcjmohivbettnaw) (Read error: Connection reset by peer)
2020-09-20 01:54:42 × mcfilib quits (sid302703@gateway/web/irccloud.com/x-jpgleryxlbiywuvp) (Read error: Connection reset by peer)
2020-09-20 01:54:56 kyagrd__ joins (sid102627@gateway/web/irccloud.com/x-umexjnjqxisrtwcp)
2020-09-20 01:55:39 jumper149 joins (~jumper149@ip185225.wh.uni-hannover.de)
2020-09-20 01:56:15 × jumper149 quits (~jumper149@ip185225.wh.uni-hannover.de) (Client Quit)
2020-09-20 01:56:28 mcfilib joins (sid302703@gateway/web/irccloud.com/x-mcvztaukmltliuld)
2020-09-20 01:57:49 <sim590> Well. It's not very worrying. I was mainly wondering in order to know for other use cases.
2020-09-20 01:58:40 <sim590> But then since I have to use the constructor, I can go back to the following syntax `incIndex (LBSLeaf i c) = return $ LBSLeaf (i+amount) c` which is the default I normally use.
2020-09-20 01:58:46 merijn joins (~merijn@83-160-49-249.ip.xs4all.nl)
2020-09-20 01:58:59 jumper149 joins (~jumper149@ip185225.wh.uni-hannover.de)
2020-09-20 01:58:59 × pera quits (~pera@unaffiliated/pera) (Ping timeout: 240 seconds)
2020-09-20 01:59:18 <sim590> The main point of using the record syntax is to update things, but since I cannot do that here without creating a warning, then it's not worth writing the fields in the record syntax.
2020-09-20 01:59:47 × Amras quits (~Amras@unaffiliated/amras0000) (Remote host closed the connection)
2020-09-20 02:00:01 × jumper149 quits (~jumper149@ip185225.wh.uni-hannover.de) (Client Quit)
2020-09-20 02:00:35 jumper149 joins (~jumper149@ip185225.wh.uni-hannover.de)
2020-09-20 02:00:36 × jumper149 quits (~jumper149@ip185225.wh.uni-hannover.de) (Client Quit)
2020-09-20 02:00:48 mpereira joins (~mpereira@2a02:810d:f40:d96:b46b:1e98:8653:4550)
←Prev  Next→
Page 1 .. 80 81 82 83 84 85 86 87 88 89 90 .. 5022

All times are in UTC.