Home freenode/#haskell: Logs Calendar

Logs: freenode/#haskell

←Prev  Next→ 502,152 events total
2020-11-24 15:07:02 <dminuoso> well the raw parsing is done, I was just really lazy since ParsecT is a monad transformer..
2020-11-24 15:07:08 <dminuoso> so I tohught "why not do more work while Im parsing"
2020-11-24 15:07:30 hackage req 3.8.0 - Easy-to-use, type-safe, expandable, high-level HTTP client library https://hackage.haskell.org/package/req-3.8.0 (mrkkrp)
2020-11-24 15:08:01 × royal_screwup213 quits (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9) (Quit: Connection closed)
2020-11-24 15:08:28 <dminuoso> For some bizarre reason, in this week I've this type of "how do I generate a tree properly from a flat file" in three completely unrelated projects
2020-11-24 15:08:31 royal_screwup213 joins (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9)
2020-11-24 15:08:32 <hekkaidekapus> I would go with the Happy route to record steps taken wwhile parsing and use those to represent the final tidy data.
2020-11-24 15:08:47 <dminuoso> "steps taken"?
2020-11-24 15:08:58 <hekkaidekapus> Production rules.
2020-11-24 15:11:53 <dminuoso> I see, so concretely that could mean annotating the data with fully resolved paths, where I might have a list of nodes each with a sort of path `data Node a = Node { nodeLabel a, nodePath :: NonEmpty Int }`
2020-11-24 15:12:00 <dminuoso> as the result of the parser
2020-11-24 15:12:16 <dminuoso> And then it's just a matter of folding [Node] into a free
2020-11-24 15:12:18 <dminuoso> *tree
2020-11-24 15:12:33 <hekkaidekapus> Yep.
2020-11-24 15:12:55 <hekkaidekapus> The bulk of the work is in writing the grammar.
2020-11-24 15:12:57 × adm_ quits (~adm@43.229.88.197) (Remote host closed the connection)
2020-11-24 15:13:10 × royal_screwup213 quits (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9) (Ping timeout: 256 seconds)
2020-11-24 15:15:25 n0042 joins (d055ed89@208.85.237.137)
2020-11-24 15:16:30 andos joins (~dan@69-165-210-185.cable.teksavvy.com)
2020-11-24 15:17:58 <dminuoso> Mmm, oh. I dont even have to do the folding myself
2020-11-24 15:18:03 <dminuoso> https://hackage.haskell.org/package/tries-0.0.6.1/docs/Data-Trie-Class.html#v:fromFoldable
2020-11-24 15:18:05 <dminuoso> Cute
2020-11-24 15:18:40 <hekkaidekapus> \o/
2020-11-24 15:18:49 × bulters quits (~jeroen@82-161-48-217.ip.xs4all.nl) (Ping timeout: 264 seconds)
2020-11-24 15:19:11 × nr3rsl quits (nr3rsl@94.63.218.65) ()
2020-11-24 15:19:22 hseg joins (~gesh@185.120.126.113)
2020-11-24 15:19:31 <hekkaidekapus> There is also generic-trie (hey glguy) and multi-trie.
2020-11-24 15:19:35 <dminuoso> hekkaidekapus: Guess you didn't just want to make a pun after all. Thanks for trieing.
2020-11-24 15:19:45 <hekkaidekapus> hahaha…
2020-11-24 15:19:57 <n0042> XD
2020-11-24 15:20:28 <arianvp> I have a question about overlapping instances
2020-11-24 15:20:38 <arianvp> https://github.com/haskell-servant/servant/issues/1367
2020-11-24 15:21:01 <arianvp> why would these two instances overlap? There is no `ToJSON` instance for `WithStatus n a`
2020-11-24 15:21:51 <dminuoso> arianvp: instance context is not considered for selection
2020-11-24 15:22:03 <arianvp> aaaah
2020-11-24 15:22:13 <arianvp> so I need to add an explicit `overlaps` here?
2020-11-24 15:22:31 <dminuoso> Well
2020-11-24 15:22:33 <dminuoso> instance MimeRender ctype a => MimeRender ctype (WithStatus _status a)
2020-11-24 15:22:36 <dminuoso> instance [overlappable] ToJSON a => MimeRender JSON a
2020-11-24 15:22:45 <dminuoso> Imagine you're tryng to match `MimeRender JSON (WithStatus 201 ())`
2020-11-24 15:22:48 <dminuoso> This matches *both*
2020-11-24 15:23:08 <dminuoso> Compare the instance heads
2020-11-24 15:23:10 <dminuoso> MimeRender ctype (WithStatus _status a
2020-11-24 15:23:15 <dminuoso> MimeRender JSON a
2020-11-24 15:23:32 <dminuoso> Both match, and none is more specific.
2020-11-24 15:24:40 bulters joins (~jeroen@82-161-48-217.ip.xs4all.nl)
2020-11-24 15:24:49 <arianvp> hmm
2020-11-24 15:25:12 <arianvp> so I should make a instance MimeRender JSON a => MimeRender JSON (WithStatus _s a) instead ?
2020-11-24 15:25:14 × st8less quits (~st8less@2603:a060:11fd:0:b11b:e5d8:ecef:8990) (Ping timeout: 264 seconds)
2020-11-24 15:25:20 <arianvp> (for each content type)
2020-11-24 15:25:34 <arianvp> and mark that as overlapping?
2020-11-24 15:26:05 <dminuoso> Well you wouldnt have to mark it as overlapping, as the other instance is already overlappable
2020-11-24 15:26:07 st8less joins (~st8less@2603:a060:11fd:0:b11b:e5d8:ecef:8990)
2020-11-24 15:26:24 <dminuoso> (for overlap to work, either overlapping or overlappable is enough)
2020-11-24 15:26:28 <arianvp> ah
2020-11-24 15:26:35 <arianvp> thanks!
2020-11-24 15:26:55 adm_ joins (~adm@43.229.88.197)
2020-11-24 15:27:05 × adm_ quits (~adm@43.229.88.197) (Remote host closed the connection)
2020-11-24 15:27:20 × hseg quits (~gesh@185.120.126.113) (Ping timeout: 256 seconds)
2020-11-24 15:28:23 adm_ joins (~adm@43.229.88.197)
2020-11-24 15:29:03 <arianvp> *sends a fix*
2020-11-24 15:29:05 gioyik joins (~gioyik@186.118.238.251)
2020-11-24 15:29:09 <dminuoso> arianvp: https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/instances.html?highlight=overlapping
2020-11-24 15:29:23 <dminuoso> Also https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/instances.html?highlight=overlapping#instance-overlap
2020-11-24 15:32:00 hackage unbounded-delays 0.1.1.1 - Unbounded thread delays and timeouts https://hackage.haskell.org/package/unbounded-delays-0.1.1.1 (RoelVanDijk)
2020-11-24 15:32:12 royal_screwup213 joins (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9)
2020-11-24 15:32:55 × adm_ quits (~adm@43.229.88.197) (Remote host closed the connection)
2020-11-24 15:33:31 <arianvp> I must say the GHC error message is horrible for this
2020-11-24 15:33:50 <arianvp> well in hindsight I understand it now
2020-11-24 15:34:15 <arianvp> it would be nice if it hid the context and highlight the parts that are in conflict
2020-11-24 15:34:23 <dminuoso> Is it horrible?
2020-11-24 15:34:33 <dminuoso> Well, it'd be misleading to hide the context
2020-11-24 15:35:47 <dminuoso> GHC *does* tell you that there's two matching instances for the constraint `MimeRender JSON (WithStatus 201 ())`
2020-11-24 15:35:55 Df joins (5fa448e7@95.164.72.231)
2020-11-24 15:35:56 Stanley00 joins (~stanley00@unaffiliated/stanley00)
2020-11-24 15:36:11 adm_ joins (~adm@43.229.88.197)
2020-11-24 15:36:40 × sord937 quits (~sord937@gateway/tor-sasl/sord937) (Remote host closed the connection)
2020-11-24 15:36:53 <arianvp> I got sidetracked into wondering "But WIthStatus" doesnt _have_ a ToJSON why would it overlap? but now that I know the contexts aren't considered it makes sense
2020-11-24 15:37:05 <arianvp> perhaps a note in the error message explaining that would be a nice nudge =)
2020-11-24 15:37:12 × toorevitimirp quits (~tooreviti@117.182.183.18) (Remote host closed the connection)
2020-11-24 15:37:43 sord937 joins (~sord937@gateway/tor-sasl/sord937)
2020-11-24 15:38:38 <dminuoso> Do you have a suggestion?
2020-11-24 15:40:20 <dminuoso> The crux is, GHC cant really know why it has the problem that it is.
2020-11-24 15:40:28 × Stanley00 quits (~stanley00@unaffiliated/stanley00) (Ping timeout: 260 seconds)
2020-11-24 15:40:34 <dminuoso> If you look at the full algorithm described in https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/instances.html?highlight=overlapping#overlapping-instances
2020-11-24 15:40:55 <dminuoso> (Which by the way is still incomplete, but that's another story)
2020-11-24 15:41:00 hackage cli-extras 0.1.0.1 - Miscellaneous utilities for building and working with command line interfaces https://hackage.haskell.org/package/cli-extras-0.1.0.1 (abrar)
2020-11-24 15:41:46 <dminuoso> Then the algorithm is far more involved than than just "ignore context and find the best intsance"
2020-11-24 15:44:15 ggole joins (~ggole@2001:8003:8119:7200:882e:5c1e:9189:4cff)
2020-11-24 15:44:25 <dminuoso> But admittedly, we see people stumbling over this nearly every day.
2020-11-24 15:44:40 <dminuoso> (And interestingly this behavior is not specified in the Haskell report either)
2020-11-24 15:44:41 Iceland_jack joins (~user@31.124.48.169)
2020-11-24 15:44:50 <Uniaika> hi Iceland_jack :)
2020-11-24 15:44:54 <Uniaika> how are you?
2020-11-24 15:44:57 <arianvp> I dont think the error message needs to explain exactly what's happening with 100% accuracy
2020-11-24 15:45:07 <arianvp> but it's nice (rust does this as well) when an error lists a "Common cause"
2020-11-24 15:45:28 <arianvp> "Hey; you might not realise it but the context is not considered when deciding if something overlaps"
2020-11-24 15:45:30 <Uniaika> it's very useful
2020-11-24 15:45:33 <dminuoso> I recall an issue on ghc gitlab about this
2020-11-24 15:46:05 <arianvp> It's up to the user to decide if that hint applies to their situation; but at least it gives them food for thought

All times are in UTC.