Home freenode/#haskell: Logs Calendar

Logs: freenode/#haskell

←Prev  Next→ 502,152 events total
2021-05-07 17:58:56 <monochrom> I don't know what "read doc comments at compile time" mean.
2021-05-07 17:59:09 tomsmeding neither, which is why I'm asking :)
2021-05-07 17:59:27 <chisui> Ah, so something like `module A{ module B ) where { import B(b) }` exports only `b` from `B`
2021-05-07 17:59:31 <tomsmeding> (for haskell doc comments, see "haddock")
2021-05-07 17:59:45 wroathe joins (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net)
2021-05-07 17:59:46 nicholasbulka joins (~nicholasb@c-73-21-82-200.hsd1.ga.comcast.net)
2021-05-07 18:00:01 × royal_screwup213 quits (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9) (Quit: Connection closed)
2021-05-07 18:00:04 <monochrom> And if you change to "import qualified B(b)" you export nothing.
2021-05-07 18:00:06 <tomsmeding> chisui: indeed, but more funnily, `module A(module B) where { import qualified B }` exports nothing
2021-05-07 18:00:10 <tomsmeding> that
2021-05-07 18:00:15 × nurupo quits (~nurupo.ga@unaffiliated/nurupo) (Quit: nurupo.ga)
2021-05-07 18:00:22 royal_screwup213 joins (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9)
2021-05-07 18:00:30 nurupo joins (~nurupo.ga@unaffiliated/nurupo)
2021-05-07 18:00:57 <monochrom> and "import B as C(b)" it is now called C not B, you have to say "module C", bearing in mind that "C" is not a module.
2021-05-07 18:01:06 × sphi quits (a0ca25b5@160.202.37.181) (Client Quit)
2021-05-07 18:01:12 <monochrom> at least not in most people's mind.
2021-05-07 18:01:33 <monochrom> and Mr. Speaker doesn't speak
2021-05-07 18:01:44 <monochrom> and in the Commonwealth, wealth is not common.
2021-05-07 18:01:47 <chisui> tomsmeding ... yeah, of course. That's how namespaces work. Am I missing something?
2021-05-07 18:02:07 howdoi joins (uid224@gateway/web/irccloud.com/x-hzckqjwmuxbtspgy)
2021-05-07 18:02:27 nineonine joins (~nineonine@2604:3d08:7783:f200:5c3d:ae41:1644:7ac)
2021-05-07 18:02:31 <sszark> Essentially i just want to print doc strings for the user. This way you'd only need to update the documentation. Instead of storing them as both strings and doc comments.
2021-05-07 18:02:33 <chisui> ... Oh, of course
2021-05-07 18:02:38 <tomsmeding> chisui: previously I was under the mistaken assumption that exporting 'module M' everything available under the qualified 'M.' -- which is apparently not true :)
2021-05-07 18:02:39 <sszark> I'll have a look at Haddock and see how they do it. Thanks
2021-05-07 18:02:50 × CrazyPython quits (~crazypyth@98.122.164.118) (Read error: Connection reset by peer)
2021-05-07 18:02:51 <monochrom> Well, I would be happier if the syntax were "module A(namespace B)" instead of "module A(module B)".
2021-05-07 18:03:18 <tomsmeding> sszark: oh you want to print a doc comment at runtime, like in python where you can do print(__doc__)?
2021-05-07 18:03:21 jeanclaude[m] joins (jeanclaude@gateway/shell/matrix.org/x-mmihezdzzruufkof)
2021-05-07 18:03:24 <tomsmeding> no you can't do that in haskell
2021-05-07 18:03:32 × motersen quits (~motersen@gateway/tor-sasl/motersen) (Remote host closed the connection)
2021-05-07 18:03:39 geekosaur wonders about annotations
2021-05-07 18:03:48 motersen joins (~motersen@gateway/tor-sasl/motersen)
2021-05-07 18:03:52 <sszark> I'm not familar with Python, But essentially yes.
2021-05-07 18:04:08 <tomsmeding> can you do that in rust?
2021-05-07 18:04:10 <chisui> CCP?
2021-05-07 18:04:14 × nicholasbulka quits (~nicholasb@c-73-21-82-200.hsd1.ga.comcast.net) (Ping timeout: 246 seconds)
2021-05-07 18:04:27 <tomsmeding> *CPP but yes, but please no
2021-05-07 18:04:56 × wroathe quits (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) (Ping timeout: 265 seconds)
2021-05-07 18:04:58 × xcmw quits (~textual@dyn-72-33-2-152.uwnet.wisc.edu) (Quit: My MacBook has gone to sleep. ZZZzzz…)
2021-05-07 18:05:13 <chisui> Yeah, DON'T USE CCP unless you REALLY know what you are doing.
2021-05-07 18:05:25 × royal_screwup213 quits (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9) (Ping timeout: 265 seconds)
2021-05-07 18:05:38 <tomsmeding> (it's "C PreProcessor")
2021-05-07 18:05:50 <sszark> yeah tomsmeding, libraries like structopt implements it. It's pretty clever.
2021-05-07 18:06:10 OscarZ joins (~oscarz@95.175.104.236)
2021-05-07 18:06:31 <monochrom> Oh, command line arguments.
2021-05-07 18:06:32 tromp joins (~tromp@dhcp-077-249-230-040.chello.nl)
2021-05-07 18:07:16 <tomsmeding> fancy
2021-05-07 18:07:26 <monochrom> Don't put in "doc comments" at all. Use a library such as optparse-applicative or options.
2021-05-07 18:07:42 <monochrom> This is known as "XY problem".
2021-05-07 18:08:37 <chisui> You could use Symbols and `KnownSymbol` do generate some stuff at compile time
2021-05-07 18:09:07 <sszark> I wouldn't say so. I was just wondering if it was possible. It would streamline the program i'm currently writing. The arg parsing library i mentioned was just an example.
2021-05-07 18:09:30 <tomsmeding> sszark: what monochrom is saying is: reconsider if you really need that text in a doc comment, and maybe just put it in a string
2021-05-07 18:09:51 <monochrom> KnownSymbol would be https://hackage.haskell.org/package/commander-cli-0.10.1.2/docs/Options-Commander.html
2021-05-07 18:11:02 <chisui> monochrom Uh, cool. I didn't know about that library.
2021-05-07 18:11:04 <thblt> Hey #haskell, I've implemented the classic GADT example of the calc expression language that with Ints *and* Bools and GADT constructors that prevent adding one to the other. But I also have an Eq constructor that compares Bools xor Ints alike, and Haskell don't want to typecheck my eval if I don't add an explicit (Eq a) constraint that I don't think I *need*. Code is here: https://paste.thb.lt/1620410796.hs_src_.html
2021-05-07 18:11:25 royal_screwup213 joins (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9)
2021-05-07 18:11:30 <geekosaur> https://gitlab.haskell.org/ghc/ghc/-/wikis/annotations
2021-05-07 18:11:56 sphi joins (~sphi@160.202.37.181)
2021-05-07 18:12:18 <thblt> My (probably naive) reasoning goes like this: since Calc is closed, it's impossible to construct a Calc a with an `a` that isn't Eq, and I'd expect the typechecker to know that.
2021-05-07 18:12:34 <tomsmeding> thblt: `undefined :: Calc String`
2021-05-07 18:12:50 <tomsmeding> that's not just a facetious answer, it's really the reason
2021-05-07 18:12:57 <thblt> tomsmeding: but can you *create* such a value?
2021-05-07 18:13:01 <tomsmeding> I just did :p
2021-05-07 18:13:13 <tomsmeding> you're not pattern matching on 'a' or 'b' so you don't know yet if it's undefined or not
2021-05-07 18:13:19 <chisui> thblt you need the constraint because you don't have the constraint on the function `eval`
2021-05-07 18:13:34 <tomsmeding> once you pattern match, the type is known, of course
2021-05-07 18:14:06 × elliott_ quits (~elliott_@pool-108-18-30-46.washdc.fios.verizon.net) (Ping timeout: 240 seconds)
2021-05-07 18:14:09 × nut quits (~nut@roc37-h01-176-170-197-243.dsl.sta.abo.bbox.fr) (Ping timeout: 252 seconds)
2021-05-07 18:14:13 <tomsmeding> I believe the standard trick here is to have a separate data type, say 'data Type a where TInt :: Type Int ; TBool :: Type Bool', and including a 'Type a' within every arm of Calc
2021-05-07 18:15:06 <tomsmeding> then make a function 'typeOf :: Calc a -> Type a', and make a function 'eqValues :: Type a -> a -> a -> Bool' that pattern-matches on the Type and _then_ compares
2021-05-07 18:15:09 <thblt> chisui: I don't understand in which case it could not be satisfied by the very definition of the type.
2021-05-07 18:15:17 waleee-cl joins (uid373333@gateway/web/irccloud.com/x-fwnywpfxxvlrvudf)
2021-05-07 18:15:20 <chisui> what about `eval :: Eq a -> Calc a -> a`?
2021-05-07 18:15:21 <tomsmeding> because only after the pattern match on Type do you know what types you have in hand, and thus what Eq dictionary you should use
2021-05-07 18:15:52 × royal_screwup213 quits (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9) (Ping timeout: 240 seconds)
2021-05-07 18:16:06 <tomsmeding> thblt: another way to think about it: how is GHC supposed to figure out which (==) it should use -- the one from Int or the one from Bool?
2021-05-07 18:16:09 <sszark> I'll drop it, But the benefit of what was thinking. Would allow for the program itself and documentation to share the same declarations. Putting it in as strings wouldn't generate anything in the docs. So you would need to identical summaries.
2021-05-07 18:16:14 <tomsmeding> it will have to pattern match on 'a' and 'b' to figure that out
2021-05-07 18:16:30 <sszark> two*
2021-05-07 18:16:41 <tomsmeding> sszark: true, but unfortunately that's not possible in haskell at the moment
2021-05-07 18:16:43 × frozenErebus quits (~frozenEre@37.231.244.249) (Ping timeout: 252 seconds)
2021-05-07 18:16:53 <sszark> That's good to know. thanks!
2021-05-07 18:17:31 <chisui> Ohhhhhh, It could be a naming conflict for `Eq`. Try naming the constructor `EQ` or something like that
2021-05-07 18:17:49 <tomsmeding> chisui: no that's not the problem :p
2021-05-07 18:17:56 × mrchampion quits (~mrchampio@38.18.109.23) (Remote host closed the connection)
2021-05-07 18:17:56 <monochrom> My perspective is that I don't want the user-facing explanation and the programmer-facing explanation to be in sync.
2021-05-07 18:18:17 <monochrom> Except for toy programs. (roast!)
2021-05-07 18:18:28 × merijn quits (~merijn@83-160-49-249.ip.xs4all.nl) (Ping timeout: 268 seconds)
2021-05-07 18:18:43 <tomsmeding> at some point deep in the ghc compilation pipeline, type classes become _values_. Using (==) on type 'a' means that you must have a _value_ (namely, a dictionary) of type 'Eq a' to get it from
2021-05-07 18:19:02 <thblt> tomsmeding: but the *current* code compiles with `test = eval (Eq (CInt 3) undefined)`. `undefined` inhabits every type, afaik.
2021-05-07 18:19:09 <monochrom> The user-facing explanation contains syntactic details that disappear in the internal, programmer-facing representation, for example.
2021-05-07 18:19:28 <chisui> Urgh, I though it was `Eq :: Eq a -> a -> Calc a`. Don't listen to me tomsmeding is the guy.
2021-05-07 18:19:32 <tomsmeding> if ghc knows what types you're comparing, it knows where to get the dictionary from at compile time; if you have an 'Eq a' constraint, then at runtime there will be a real dictionary passed around containing the right definition of (==)
2021-05-07 18:19:33 <monochrom> The programmer-facing representation has invariants that make no sense to the user.
2021-05-07 18:20:21 <chisui> `Eq :: Eq a => a -> a -> Calc a` I should go
2021-05-07 18:20:46 × robotmay quits (~beepboop@2001:8b0:7af0:2580:df9:a82d:b905:b9d2) (Remote host closed the connection)
2021-05-07 18:20:48 <monochrom> My https://github.com/treblacy/random-read is an example of the user-syntax-detail case.
2021-05-07 18:21:22 <tomsmeding> thblt: so the point is that if the type is not known, and there's no Eq constraint available, then ghc has nowhere to pull the (==) from :p
2021-05-07 18:21:28 <thblt> Ha, right, I can do `fail = eval (Eq (undefined :: Calc Truc) (undefined :: Calc Truc))`

All times are in UTC.