Logs: liberachat/#haskell
| 2026-04-21 14:48:00 | → | confusedalex joins (~confuseda@user/confusedalex) |
| 2026-04-21 14:50:45 | → | machinedgod joins (~machinedg@d172-219-48-230.abhsia.telus.net) |
| 2026-04-21 15:03:12 | × | craunts795335385 quits (~craunts@152.32.99.2) (Ping timeout: 265 seconds) |
| 2026-04-21 15:05:09 | → | craunts795335385 joins (~craunts@152.32.100.66) |
| 2026-04-21 15:08:17 | <gentauro> | dminuoso: so does `head` ;) |
| 2026-04-21 15:08:21 | <gentauro> | % :t head |
| 2026-04-21 15:08:21 | <yahb2> | <interactive>:1:1: warning: [GHC-63394] [-Wx-partial] ; In the use of ‘head’ ; (imported from Prelude, but defined in GHC.Internal.List): ; "This is a partial function, it throws an err... |
| 2026-04-21 15:08:26 | <gentauro> | > :t head |
| 2026-04-21 15:08:27 | <lambdabot> | <hint>:1:1: error: parse error on input `:' |
| 2026-04-21 15:08:31 | <gentauro> | :| |
| 2026-04-21 15:08:42 | <gentauro> | % :i List.head |
| 2026-04-21 15:08:43 | <yahb2> | <interactive>:1:1: error: [GHC-76037] Not in scope: ‘List.head’ |
| 2026-04-21 15:08:46 | <gentauro> | :( |
| 2026-04-21 15:09:22 | gentauro | -> https://hackage-content.haskell.org/package/base-4.22.0.0/docs/Prelude.html#v:head |
| 2026-04-21 15:09:37 | gentauro | >>> head [] *** Exception: Prelude.head: empty list |
| 2026-04-21 15:15:49 | → | havochunter joins (~havochunt@2a02-a467-ef2-0-f6c3-1c29-6870-3369.fixed6.kpn.net) |
| 2026-04-21 15:16:20 | → | tromp joins (~textual@2001:1c00:340e:2700:463:2385:89e0:6cf) |
| 2026-04-21 15:17:28 | → | danz66376 joins (~danza@user/danza) |
| 2026-04-21 15:19:12 | × | danza quits (~danza@user/danza) (Ping timeout: 244 seconds) |
| 2026-04-21 15:34:41 | <dutchie> | hmm, is there no nice Alternative instance to let me do `f <|> g $ x` where `f, g :: Foo -> Maybe Bar` |
| 2026-04-21 15:36:07 | <dutchie> | or should I do some `asum . fmap ($ x)` thing |
| 2026-04-21 15:36:42 | <merijn> | What are you trying to do? |
| 2026-04-21 15:37:15 | <merijn> | Get the first "Just"? |
| 2026-04-21 15:37:37 | <dutchie> | yeah. i've also got an `h :: Foo -> Bar` that I want to run as a last resort too |
| 2026-04-21 15:37:42 | → | jmcantrell_ joins (~weechat@user/jmcantrell) |
| 2026-04-21 15:37:47 | jmcantrell_ | is now known as jmcantrell |
| 2026-04-21 15:38:05 | <merijn> | dutchie: You can always make use of our friend, the best monoid instance ever |
| 2026-04-21 15:38:19 | <dutchie> | `fromMaybe (h x) (f x <|> g x)` feels ugly |
| 2026-04-21 15:38:41 | <dutchie> | merijn: the Monoid a => Monoid (x -> a) one? |
| 2026-04-21 15:38:47 | <merijn> | Is it just two alternatives or more |
| 2026-04-21 15:38:50 | <merijn> | dutchie: Yeah |
| 2026-04-21 15:38:56 | <dutchie> | just two and then the "pure" one |
| 2026-04-21 15:39:20 | <merijn> | tbh, then I don't think the monoid solution will improve much over just the <|> alternative |
| 2026-04-21 15:39:22 | <dutchie> | I thought that I'd need that instance but couldn't work out how to invoke it |
| 2026-04-21 15:39:59 | <merijn> | getFirst $ mconcat [First . f, First . g] x |
| 2026-04-21 15:40:02 | <dutchie> | i don't much like repeating the x |
| 2026-04-21 15:41:09 | <dutchie> | that is a lot noisier than the fromMaybe thing above, especially when you throw the last pure function in |
| 2026-04-21 15:41:32 | <merijn> | Yes, hence why I don't think it works for just two |
| 2026-04-21 15:41:46 | <merijn> | If you have like, 5+ methods it could be worth it |
| 2026-04-21 15:43:03 | <dutchie> | for some reason I thought there was some sort of Alternative a => Alternative (b -> a) instance but that doesn't even make sense |
| 2026-04-21 15:43:11 | <dutchie> | which is I suppose why First exists |
| 2026-04-21 15:45:19 | <merijn> | There's Alt |
| 2026-04-21 15:45:36 | <merijn> | But that's just generalised First |
| 2026-04-21 15:47:01 | → | karenw joins (~karenw@user/karenw) |
| 2026-04-21 15:47:39 | × | puke quits (~puke@user/puke) (Remote host closed the connection) |
| 2026-04-21 15:48:04 | → | puke joins (~puke@user/puke) |
| 2026-04-21 16:01:02 | × | craunts795335385 quits (~craunts@152.32.100.66) (Quit: The Lounge - https://thelounge.chat) |
| 2026-04-21 16:01:42 | × | kupi quits (uid212005@id-212005.hampstead.irccloud.com) (Quit: Connection closed for inactivity) |
| 2026-04-21 16:18:42 | × | gf31 quits (~gf3@user/gf3) (Ping timeout: 256 seconds) |
| 2026-04-21 16:24:38 | → | Googulator72 joins (~Googulato@84-236-65-56.pool.digikabel.hu) |
| 2026-04-21 16:28:32 | × | Googulator quits (~Googulato@84-236-65-56.pool.digikabel.hu) (Ping timeout: 245 seconds) |
| 2026-04-21 16:33:57 | × | Googulator72 quits (~Googulato@84-236-65-56.pool.digikabel.hu) (Ping timeout: 245 seconds) |
| 2026-04-21 16:38:06 | → | peterbecich joins (~Thunderbi@71.84.33.135) |
| 2026-04-21 16:39:08 | × | puke quits (~puke@user/puke) (Ping timeout: 250 seconds) |
| 2026-04-21 16:39:39 | → | CiaoSen joins (~Jura@p549cbfb1.dip0.t-ipconnect.de) |
| 2026-04-21 16:48:35 | × | merijn quits (~merijn@77.242.116.146) (Ping timeout: 244 seconds) |
| 2026-04-21 16:49:05 | × | danz66376 quits (~danza@user/danza) (Remote host closed the connection) |
| 2026-04-21 16:49:38 | → | Googulator joins (~Googulato@84-236-65-56.pool.digikabel.hu) |
| 2026-04-21 16:49:45 | × | tromp quits (~textual@2001:1c00:340e:2700:463:2385:89e0:6cf) (Quit: My iMac has gone to sleep. ZZZzzz…) |
| 2026-04-21 16:52:00 | → | tnt1 joins (~Thunderbi@user/tnt1) |
| 2026-04-21 16:58:47 | × | arandombit quits (~arandombi@user/arandombit) (Remote host closed the connection) |
| 2026-04-21 17:00:28 | → | tzh joins (~tzh@c-76-115-131-146.hsd1.or.comcast.net) |
| 2026-04-21 17:02:29 | × | notzmv quits (~umar@user/notzmv) (Read error: Connection reset by peer) |
| 2026-04-21 17:07:26 | → | arandombit joins (~arandombi@user/arandombit) |
| 2026-04-21 17:08:06 | → | tromp joins (~textual@2001:1c00:340e:2700:463:2385:89e0:6cf) |
| 2026-04-21 17:23:06 | × | CiaoSen quits (~Jura@p549cbfb1.dip0.t-ipconnect.de) (Ping timeout: 255 seconds) |
| 2026-04-21 17:26:43 | × | hc quits (~hc@mail.hce.li) (Ping timeout: 264 seconds) |
| 2026-04-21 17:34:49 | × | tromp quits (~textual@2001:1c00:340e:2700:463:2385:89e0:6cf) (Quit: My iMac has gone to sleep. ZZZzzz…) |
| 2026-04-21 17:35:06 | → | weary-traveler joins (~user@user/user363627) |
| 2026-04-21 17:38:38 | × | lisbeths quits (uid135845@id-135845.lymington.irccloud.com) (Quit: Connection closed for inactivity) |
| 2026-04-21 17:38:42 | × | arandombit quits (~arandombi@user/arandombit) (Ping timeout: 244 seconds) |
| 2026-04-21 17:40:35 | → | misterfish joins (~misterfis@84.53.85.146) |
| 2026-04-21 17:45:54 | × | jmcantrell quits (~weechat@user/jmcantrell) (Ping timeout: 248 seconds) |
| 2026-04-21 17:50:07 | × | peterbecich quits (~Thunderbi@71.84.33.135) (Ping timeout: 264 seconds) |
| 2026-04-21 17:52:02 | × | misterfish quits (~misterfis@84.53.85.146) (Ping timeout: 244 seconds) |
| 2026-04-21 18:08:35 | → | ft joins (~ft@p508db287.dip0.t-ipconnect.de) |
| 2026-04-21 18:08:49 | × | elarks quits (~elarks@user/yerrii) (Quit: WeeChat 4.7.1) |
| 2026-04-21 18:09:14 | → | peterbecich joins (~Thunderbi@71.84.33.135) |
| 2026-04-21 18:15:48 | × | tnt1 quits (~Thunderbi@user/tnt1) (Read error: Connection reset by peer) |
| 2026-04-21 18:16:40 | → | tnt1 joins (~Thunderbi@user/tnt1) |
| 2026-04-21 18:25:33 | × | michalz quits (~michalz@185.246.207.201) (Remote host closed the connection) |
| 2026-04-21 18:32:52 | × | peterbecich quits (~Thunderbi@71.84.33.135) (Ping timeout: 276 seconds) |
| 2026-04-21 18:41:07 | × | Googulator quits (~Googulato@84-236-65-56.pool.digikabel.hu) (Quit: Client closed) |
| 2026-04-21 18:41:23 | → | Googulator joins (~Googulato@84-236-65-56.pool.digikabel.hu) |
| 2026-04-21 18:48:58 | × | polykernel quits (~polykerne@user/polykernel) (Ping timeout: 244 seconds) |
| 2026-04-21 18:50:23 | × | chele quits (~chele@user/chele) (Remote host closed the connection) |
| 2026-04-21 18:51:47 | × | Googulator quits (~Googulato@84-236-65-56.pool.digikabel.hu) (Quit: Client closed) |
| 2026-04-21 18:52:00 | → | Googulator joins (~Googulato@84-236-65-56.pool.digikabel.hu) |
| 2026-04-21 18:52:53 | <Leary> | :t let (|>) = flip fromMaybe; (<<|>>) = liftA2 (<|>); (|>>) = liftA2 (|>) in \f g h x -> (f <<|>> g |>> h) x |
| 2026-04-21 18:52:54 | <lambdabot> | (t1 -> Maybe t2) -> (t1 -> Maybe t2) -> (t1 -> t2) -> t1 -> t2 |
| 2026-04-21 18:53:06 | <Leary> | dutchie: The instance you're thinking of does exist, but under `ReaderT`. |
| 2026-04-21 18:57:19 | <dutchie> | ah right of course |
| 2026-04-21 18:57:19 | → | polykernel joins (~polykerne@user/polykernel) |
| 2026-04-21 18:57:41 | <dutchie> | I have now further complicated matters by realising that f and g are actually in my effect monad |
| 2026-04-21 18:58:05 | <dutchie> | so `f, g :: Foo -> m (Maybe Bar)` |
| 2026-04-21 18:58:45 | <dutchie> | `fromMaybe (h x) . asum =<< sequence [f x, g x]` spreads the xs around enough that it's not offending me too much |
| 2026-04-21 18:59:57 | <dutchie> | I often end up writing `maybe action pure` and feeling like I'm missing something there as well |
| 2026-04-21 19:00:20 | × | karenw quits (~karenw@user/karenw) (Ping timeout: 244 seconds) |
| 2026-04-21 19:06:24 | <dutchie> | hmm, is sequence running all the actions even when there is a Just though |
| 2026-04-21 19:08:05 | → | kupi joins (uid212005@id-212005.hampstead.irccloud.com) |
All times are in UTC.