Home liberachat/#haskell: Logs Calendar

Logs: liberachat/#haskell

←Prev  Next→
Page 1 .. 699 700 701 702 703 704 705 706 707 708 709 .. 18016
1,801,552 events total
2021-06-29 11:52:02 themc47 joins (~mc47@xmonad/TheMC47)
2021-06-29 11:52:27 xff0x joins (~xff0x@2001:1a81:53b8:a100:f8a8:d5fd:e910:e3c0)
2021-06-29 11:52:36 machinedgod joins (~machinedg@135-23-192-217.cpe.pppoe.ca)
2021-06-29 11:52:36 × themc47 quits (~mc47@xmonad/TheMC47) (Client Quit)
2021-06-29 11:52:47 <gensyst> great suggestions!
2021-06-29 11:52:57 <merijn> eh
2021-06-29 11:53:01 <merijn> I have a much simpler one
2021-06-29 11:53:04 <gensyst> merijn, fyi In this https://pastebin.com/n4s0i2Qb (pardon the ridiculous example), is there a way to use "let" (or something) to avoid duplicating "my_func i" those four times in that pattern matching?
2021-06-29 11:53:09 × mc47 quits (~mc47@xmonad/TheMC47) (Read error: Connection reset by peer)
2021-06-29 11:53:46 <merijn> How about just "case my_func <$> testm of Nothing -> 2; Just i | i < 3 -> i; ..."
2021-06-29 11:54:07 <merijn> <- galaxy brain
2021-06-29 11:54:31 <merijn> You guys overcomplicating this with bunches of extensions :p
2021-06-29 11:55:15 <kuribas> merijn: that doesn't even do the same thing
2021-06-29 11:55:32 <merijn> kuribas: It does for the example paste he gave
2021-06-29 11:55:48 <merijn> How does it not do that same thing?
2021-06-29 11:55:51 <kuribas> merijn: no it doesn't
2021-06-29 11:56:09 <merijn> Enlighten me
2021-06-29 11:56:13 <kuribas> merijn: he comparse my_func i against 3, you compare i against 3...
2021-06-29 11:56:26 <merijn> kuribas: Because I fmapped my_func in the case?
2021-06-29 11:56:34 <kuribas> ah, I see...
2021-06-29 11:56:43 <merijn> Hence, why I have a galaxy brain :p
2021-06-29 11:56:56 <kuribas> merijn: that will work for this case
2021-06-29 11:57:28 <merijn> There's corner cases where (if you need the original unaltered value) it won't work, but even that is easily fixed
2021-06-29 11:57:50 <merijn> You could just change "my_fun" to return a tuple of "original and new value" and get the same logic
2021-06-29 11:58:24 <merijn> gensyst: btw, note that you don't need to repeat the "Just i" prefix for the 2nd pattern
2021-06-29 11:58:29 <kuribas> merijn: not sure that's less complicated...
2021-06-29 11:58:53 <merijn> Well, it doesn't require any extensions :p
2021-06-29 11:58:59 <Athas> Ugh, GHC has a really charming behaviour on case-insensitive file systems: if you miscapitalise the module name in an 'import', it'll find the file alright, but complain that the module header is wrong (due to differences in capitalisation).
2021-06-29 11:59:07 <kuribas> merijn: boxscape_ 's latest didn't either.
2021-06-29 11:59:32 <merijn> kuribas: I only saw the ViewPatterns one
2021-06-29 11:59:34 kspalaiologos joins (~kspalaiol@user/kspalaiologos)
2021-06-29 11:59:42 <Athas> This reminds of the Bad Old Days when I had students who programmed in SML on Windows, and who would import standard libraries by their un-capitalised names. At least GHC will complain.
2021-06-29 11:59:43 <boxscape_> https://paste.tomsmeding.com/cYPx7PJ3
2021-06-29 11:59:50 <boxscape_> merijn ^^
2021-06-29 12:00:16 <merijn> boxscape_: Right, but that's just my fmap solution, but uglier :p
2021-06-29 12:00:29 <tomsmeding> Athas: because case-insensitive file system? A few years back I started doing some haskell on mac with a case-insensitive file system and it accepted lowercase file names just fine
2021-06-29 12:01:09 <merijn> Technically macOS and windows are "case-preserving" not insensitive :p
2021-06-29 12:01:33 <Athas> tomsmeding: yes, because macOS. I typed 'import FOo.Bar', it found 'Foo/Bar.hs', then complained that this file declared 'module Foo.Bar' rather than 'module FOo.Bar'.
2021-06-29 12:01:51 <Athas> Fortunately I have already ordered a replacement machine that can run an OS without this bug.
2021-06-29 12:02:02 <Athas> But I'm surprised GHC doesn't catch this. Is it just not worth the bother to fix?
2021-06-29 12:02:15 <merijn> Athas: It sounds like it does catch it?
2021-06-29 12:02:28 <merijn> Else you wouldn't get the error, no?
2021-06-29 12:02:33 <Athas> merijn: the error is wrong.
2021-06-29 12:02:42 <merijn> Athas: That is up for debate
2021-06-29 12:02:57 <merijn> Athas: It's literally impossible to know that for GHC
2021-06-29 12:02:59 <tomsmeding> Athas: macos supports a case-sensitive file system too; case-insensitive is just the default
2021-06-29 12:03:07 <int-e> Athas: it opened FOo/Bar.hs and got a file back, how is it supposed to know that this is not the actual file name?
2021-06-29 12:03:10 <Athas> merijn: no, it is not. GHC could query the canonical file name after the lookup.
2021-06-29 12:03:16 <merijn> "You import X, a file for X exists, but lists a different module name"
2021-06-29 12:03:33 <Athas> int-e: by checking the name of the file after opening.
2021-06-29 12:03:57 <merijn> Athas: How, exactly?
2021-06-29 12:03:58 <int-e> And what if that is foo/bar.hs?
2021-06-29 12:04:11 × raehik quits (~raehik@cpc95906-rdng25-2-0-cust156.15-3.cable.virginm.net) (Quit: WeeChat 3.2)
2021-06-29 12:04:12 <Athas> merijn: fstat will tell you the canonical name, won't it?
2021-06-29 12:04:23 <Athas> int-e: then no module named FOo.Bar or Foo.Bar exists.
2021-06-29 12:04:32 <merijn> Athas: Seems unlikely, since there is no single canonical name for files
2021-06-29 12:04:41 <tomsmeding> merijn: Finder manages to display one :p
2021-06-29 12:04:44 <int-e> Athas: that'll break *other* case insensitive file systems
2021-06-29 12:04:50 <merijn> Athas: Multiple hard links can refer to the same inode
2021-06-29 12:05:07 <boxscape_> heh if you have a type signature with a variable `b4`, the first unification variable generated from that which GHC will show you in error messages is `b40`, but the next ones are `b1`, `b2`, etc.
2021-06-29 12:05:24 raehik joins (~raehik@cpc95906-rdng25-2-0-cust156.15-3.cable.virginm.net)
2021-06-29 12:05:24 <tomsmeding> boxscape_: b3, b5?
2021-06-29 12:05:29 <Athas> Ah, no, not fstat. But it is definitely possible to find the display name, even on a case insensitive file system.
2021-06-29 12:05:38 <Athas> int-e: how so?
2021-06-29 12:05:45 <merijn> Athas: You can find *a* display name, probably
2021-06-29 12:05:51 <boxscape_> tomsmeding erm let me check if it skips b4 but I suppose probably, yeah
2021-06-29 12:06:13 <int-e> Athas: because they may implement case insensitivity by picking canonical file names (all lower case; all upper case)
2021-06-29 12:06:22 <tomsmeding> merijn: there cannot be two display names referring to the same inode that differ by only case, because case-sensitive file system
2021-06-29 12:06:23 <Athas> merijn: are you telling me that given a path foo/bar.hs that resolves to a file on macOS, it is a major ordeal to find the "proper" casing of the name?
2021-06-29 12:06:48 favonia joins (~favonia@user/favonia)
2021-06-29 12:06:51 <tomsmeding> so even if there may be multiple hard links to the same inode, given a path to the thing that is correct modulo case, it should, theoretically, be possible to find the canonical version of that path :p
2021-06-29 12:06:58 × tromp quits (~textual@dhcp-077-249-230-040.chello.nl) (Quit: My iMac has gone to sleep. ZZZzzz…)
2021-06-29 12:07:03 tomsmeding has never tried to do that on macos
2021-06-29 12:07:07 <Athas> Worst case, look at the contents of the directory. That'll work unless the file system is both case-insensitive *and* permits different files in the same directory that differ only by case.
2021-06-29 12:07:16 <Athas> But I can't imagine any file system would permit that.
2021-06-29 12:07:21 <merijn> Athas: I'm saying that that file may be referred to from multiple paths none of which are canonical
2021-06-29 12:07:23 <tomsmeding> related story: a friend of mine always wrote 'head' instead of 'HEAD' with git and was surprised that didn't work on linux
2021-06-29 12:07:36 <Athas> merijn: but I already told GHC the path, so there would be no ambiguity.
2021-06-29 12:07:43 <merijn> Athas: After opening a file you no longer have a path, though, only a file descriptor
2021-06-29 12:07:45 <Athas> You are trying to solve a way more complex problem than necessary.
2021-06-29 12:08:05 dasher parts (~user@197.155.22.36) (ERC (IRC client for Emacs 27.2))
2021-06-29 12:08:09 <Athas> Ignore the file descriptor mention. That was a red herring and a pointless technical detail. My point is that GHC could solve this, and I'm surprised it doesn't.
2021-06-29 12:08:19 <tomsmeding> Athas: I think ultimately, getting the behaviour you want would require additional code in ghc that does little actual useful work
2021-06-29 12:08:33 <tomsmeding> and hence it's hard to justify putting it in
2021-06-29 12:08:35 <Athas> tomsmeding: this is the case for all code that tries to provide better error messages than ed.
2021-06-29 12:08:48 <Athas> I don't care much myself, because hopefully I have little time left on macOS.
2021-06-29 12:09:26 <merijn> Athas: I mean, on windows and linux guessing the actual path is all just "best effort guesswork" too
2021-06-29 12:09:31 tomsmeding thinks ed gives plenty useful error messages, '?'
2021-06-29 12:09:42 <tomsmeding> merijn: not if you have the path given :p
2021-06-29 12:09:46 <tomsmeding> as you have in this use-case
2021-06-29 12:09:47 <merijn> Athas: The only way on linux seems to be hacky operation on /proc
2021-06-29 12:09:56 <int-e> The error message isn't even that terrible... yes, it doesn't guess the right root cause, but as the programmer you should be able to connect the dots easily enough.
2021-06-29 12:10:01 <merijn> tomsmeding: How so?
2021-06-29 12:10:13 <merijn> tomsmeding: Linux supports case insensitive filesystems
2021-06-29 12:10:20 <merijn> It's not the default
2021-06-29 12:10:24 <merijn> but it can still happen
2021-06-29 12:10:25 derelict joins (~derelict@user/derelict)
2021-06-29 12:10:25 <tomsmeding> if you're in a particular directory and you're importing module A.B.C, then that can only be at path a/b/c.hs modulo case
2021-06-29 12:10:43 <tomsmeding> on a case sensitive file system the path is unambiguous: A/B/C.hs
2021-06-29 12:11:00 <merijn> tomsmeding: Right, but you don't know if its case sensitive on linux

All times are in UTC.