2024/09/30

Newest at the top

2024-09-30 17:37:18 +0200 <Inst> which i guess answers my question, for Haskell to accept this you'd have to give data constructors special types
2024-09-30 17:36:34 +0200 <ski> (not all functions returning an `Either' decides to return a `Left', alternatively a `Right', *independently* of what the argument was)
2024-09-30 17:35:29 +0200 <ski> (the latter case, as well as ncf's example, shows why you're not exhausetive, not covering all cases)
2024-09-30 17:34:47 +0200 <ski> or `f (\b -> if b then Left (not b) else Right 42)'
2024-09-30 17:34:46 +0200 <Inst> hence why it's unsafe
2024-09-30 17:34:05 +0200 <ski> Inst : now try `f (\x -> seq x (Left x))'
2024-09-30 17:33:37 +0200 <Inst> sorry for the unintentional obscenity
2024-09-30 17:33:20 +0200 <Inst> https://paste.tomsmeding.com/VypZIobC
2024-09-30 17:33:02 +0200 <ski> in Haskell, think of (unapplied) `Left' as being shorthand for `\x -> Left x'
2024-09-30 17:32:34 +0200 <ski> in OCaml, you can't even partially apply a data constructor, you must always spell it out fully applied. if you want the constructor function, you must type a lambda, like `fun x -> Some x', rather than just `Some'
2024-09-30 17:31:47 +0200 <ski> that's how an implementation would probably implement it
2024-09-30 17:31:46 +0200 <Inst> well, plain unsafe / unidiomatic
2024-09-30 17:31:26 +0200 <ski> function equality is not decidable, in general
2024-09-30 17:31:25 +0200 <Inst> there's a hacky way to do it, though
2024-09-30 17:31:00 +0200 <ski> if you only applied it to an `a', getting a `[Tree a] -> Tree a' back, the container hasn't been created yet, so you can't match to extract things from it
2024-09-30 17:30:22 +0200 <ski> think of `Node :: a -> [Tree a] -> Tree a' as a function that takes an `a', returning a new function that takes a list of trees of `a's, and *then* constructs an aggregate compound that contains/holds these two items, for later retrieval
2024-09-30 17:30:07 +0200 <Inst> is that why, since if / case compiles to case foo of True; False in core
2024-09-30 17:29:43 +0200 <Inst> iirc function equality is a complete nightmare to deal with
2024-09-30 17:29:17 +0200 <Inst> or in other words, why?
2024-09-30 17:28:58 +0200 <ski> yes
2024-09-30 17:28:39 +0200 <Inst> or in other words, haskell can only match on fully applied data constructors
2024-09-30 17:27:54 +0200 <ski> `False' is a data constructor that is not a function
2024-09-30 17:27:40 +0200 <ski> (and using `Left {}' doesn't help with this)
2024-09-30 17:27:30 +0200 <Inst> yeah I thought it was a weird exception that'd allow me to match on functions since data constructosr are functions
2024-09-30 17:27:17 +0200 <ncf> consider foo @Bool (bool (Left True) (Right False))
2024-09-30 17:27:15 +0200 <ski> yea, that too
2024-09-30 17:27:01 +0200 <ncf> your match isn't complete, if anything
2024-09-30 17:26:52 +0200 <ski> each data constructor pattern must be a data constructor fully applied to patterns corresponding to all the component arguments of the data constructor
2024-09-30 17:26:20 +0200 <Rembane> Inst: Try Left{} instead
2024-09-30 17:26:07 +0200 <ski> you can't match on functions with data constructors
2024-09-30 17:25:54 +0200 <Inst> should Haskell accept this?
2024-09-30 17:25:20 +0200 <Inst> https://paste.tomsmeding.com/ZFG0CItc
2024-09-30 17:23:54 +0200 <Inst> why doesn't Haskell accept this?
2024-09-30 17:21:30 +0200ljdarj(~Thunderbi@user/ljdarj) (Ping timeout: 246 seconds)
2024-09-30 17:21:22 +0200lortabac(~lortabac@2a01:e0a:541:b8f0:55ab:e185:7f81:54a4) (Quit: WeeChat 4.2.2)
2024-09-30 17:20:56 +0200misterfish(~misterfis@84.53.85.146) (Ping timeout: 265 seconds)
2024-09-30 17:15:55 +0200misterfish(~misterfis@84.53.85.146) misterfish
2024-09-30 17:07:15 +0200floyza(~gavin@h69-11-148-150.kndrid.broadband.dynamic.tds.net) gdown
2024-09-30 16:45:00 +0200merijn(~merijn@77.242.116.146) merijn
2024-09-30 16:40:50 +0200ljdarj1ljdarj
2024-09-30 16:40:49 +0200aforemny(~aforemny@i59F4C7BB.versanet.de) (Ping timeout: 265 seconds)
2024-09-30 16:40:49 +0200ljdarj(~Thunderbi@user/ljdarj) (Ping timeout: 265 seconds)
2024-09-30 16:40:22 +0200aforemny_(~aforemny@2001:9e8:6cd4:700:eda4:904a:ed7b:86ce) aforemny
2024-09-30 16:39:26 +0200merijn(~merijn@77.242.116.146) (Ping timeout: 255 seconds)
2024-09-30 16:38:47 +0200ljdarj1(~Thunderbi@user/ljdarj) ljdarj
2024-09-30 16:32:17 +0200codaraxis(~codaraxis@user/codaraxis) (Ping timeout: 252 seconds)
2024-09-30 16:28:49 +0200codaraxis__(~codaraxis@user/codaraxis) Codaraxis
2024-09-30 16:21:16 +0200merijn(~merijn@77.242.116.146) merijn
2024-09-30 16:20:31 +0200merijn(~merijn@77.242.116.146) (Ping timeout: 265 seconds)
2024-09-30 16:13:07 +0200Guest9426(~User@103.182.161.2) (Quit: Client closed)