Newest at the top
2025-02-28 08:49:59 +0100 | j1n37 | (~j1n37@user/j1n37) (Read error: Connection reset by peer) |
2025-02-28 08:49:20 +0100 | j1n37 | (~j1n37@user/j1n37) j1n37 |
2025-02-28 08:46:59 +0100 | merijn | (~merijn@host-vr.cgnat-g.v4.dfn.nl) merijn |
2025-02-28 08:46:52 +0100 | pointlessslippe1 | (~pointless@62.106.85.17) (Read error: Connection reset by peer) |
2025-02-28 08:45:42 +0100 | j1n37 | (~j1n37@user/j1n37) (Read error: Connection reset by peer) |
2025-02-28 08:45:30 +0100 | CiaoSen | (~Jura@2a02:8071:64e1:7180:4e50:ddff:fe9b:8922) CiaoSen |
2025-02-28 08:43:18 +0100 | agumonke` | (~user@tri69-h04-89-85-120-232.dsl.sta.abo.bbox.fr) |
2025-02-28 08:41:55 +0100 | alfiee | (~alfiee@user/alfiee) (Ping timeout: 252 seconds) |
2025-02-28 08:40:47 +0100 | <kqr> | I guess what I'm after is some sort of Alternative f => f a -> f b -> f () which is what Leary suggested first. |
2025-02-28 08:40:14 +0100 | <yahb2> | \cases{ Nothing Nothing Nothing -> False; _ _ _ -> True } ; :: Maybe a1 -> Maybe a2 -> Maybe a3 -> Bool |
2025-02-28 08:40:14 +0100 | <Leary> | % :t \cases{ Nothing Nothing Nothing -> False; _ _ _ -> True } |
2025-02-28 08:38:34 +0100 | <kqr> | Ah what the heck, I'll just pop `isJust` in front of each element of the list. It is perfectly readable still. |
2025-02-28 08:38:17 +0100 | <[exa]> | :( |
2025-02-28 08:38:16 +0100 | <kqr> | Yeah, I just realised |
2025-02-28 08:38:15 +0100 | j1n37 | (~j1n37@user/j1n37) j1n37 |
2025-02-28 08:38:12 +0100 | <[exa]> | ah wait no not really because the types again |
2025-02-28 08:38:12 +0100 | <lambdabot> | Alternative f => f a -> f a -> f a |
2025-02-28 08:38:10 +0100 | <kqr> | :t (<|>) |
2025-02-28 08:38:08 +0100 | <kqr> | The <|> is not good because |
2025-02-28 08:37:53 +0100 | Square2 | (~Square4@user/square) (Ping timeout: 252 seconds) |
2025-02-28 08:37:41 +0100 | <[exa]> | the <|> is probably good there, it's going to give you the first "valid" choice if you're after it |
2025-02-28 08:37:28 +0100 | alfiee | (~alfiee@user/alfiee) alfiee |
2025-02-28 08:37:22 +0100 | <kqr> | Well actually the original code had only the first two terms, and when I added the third it became more difficult to read |
2025-02-28 08:36:57 +0100 | <kqr> | I'm just aiming for conciseness and readability here. The original code said isJust a || isJust b || isJust c but the expressions a, b, and c are in reality longer and made the logic of the whole line difficult to overview |
2025-02-28 08:36:34 +0100 | merijn | (~merijn@host-vr.cgnat-g.v4.dfn.nl) (Ping timeout: 272 seconds) |
2025-02-28 08:35:49 +0100 | <[exa]> | On the very other side of the problem, you could do existential-style polymorphic lists to contain all possible justs in there. But don't if you don't have to. |
2025-02-28 08:35:04 +0100 | <[exa]> | yes. |
2025-02-28 08:34:59 +0100 | <[exa]> | for "or" you want to di as Keart says, with something like the < |
2025-02-28 08:34:58 +0100 | <kqr> | But <|> maybe? |
2025-02-28 08:34:49 +0100 | <kqr> | Oh, true. |
2025-02-28 08:34:39 +0100 | <[exa]> | mine does "and" |
2025-02-28 08:34:34 +0100 | <lambdabot> | Maybe a1 -> Maybe a2 -> Maybe a3 -> Bool |
2025-02-28 08:34:33 +0100 | <[exa]> | you have "or" there |
2025-02-28 08:34:33 +0100 | <Leary> | :t let { x ~|~ y = void x <|> void y; infixr 2 ~|~ } in \a b c -> isJust $ a ~|~ b ~|~ c |
2025-02-28 08:34:30 +0100 | <[exa]> | ah wayit actually |
2025-02-28 08:34:24 +0100 | <kqr> | Oh. Yeah, that definitely works. I just have to wrap my head around how the heck it works! |
2025-02-28 08:33:48 +0100 | <[exa]> | (you can also do like isJust (a>>b>>c) or so, to have it inline. But you can't really put the abc into a single container. |
2025-02-28 08:33:05 +0100 | j1n37 | (~j1n37@user/j1n37) (Read error: Connection reset by peer) |
2025-02-28 08:33:05 +0100 | <[exa]> | https://play.haskell.org/saved/atW1eEnR <- kqr does this work for you? |
2025-02-28 08:31:47 +0100 | <[exa]> | kqr: putting a,b,c into the same list is gonna be an issue. if you just want simpler code, you could abuse the monads a bit |
2025-02-28 08:31:33 +0100 | merijn | (~merijn@host-vr.cgnat-g.v4.dfn.nl) merijn |
2025-02-28 08:27:47 +0100 | <kqr> | Noob Haskell question: I have this expression: `or [isJust a, isJust b, isJust c]` and I'd like to translate it into `any isJust [a, b, c]` but this does not work because none of a, b, or c are of the same type. At first I thought I would be able to do something like `any isJust (map ($> ()) [a, b, c])` but of course this runs into the same problem! What are my alternatives here? |
2025-02-28 08:27:38 +0100 | florida | (~florida@2a02:ab88:7200:6a00:762b:62ff:fe83:1a1b) (Quit: Leaving) |
2025-02-28 08:21:25 +0100 | bilegeek_ | (~bilegeek@2600:1008:b014:2c7:531b:7b59:1891:ee3a) (Ping timeout: 248 seconds) |
2025-02-28 08:20:53 +0100 | merijn | (~merijn@host-vr.cgnat-g.v4.dfn.nl) (Ping timeout: 248 seconds) |
2025-02-28 08:19:29 +0100 | bilegeek | (~bilegeek@2600:1008:b01f:5f7b:5bb4:d486:4e63:9b64) (Ping timeout: 260 seconds) |
2025-02-28 08:18:49 +0100 | bilegeek__ | (~bilegeek@2600:1008:b061:9e8:b6a7:1e21:b590:dc2) bilegeek |
2025-02-28 08:16:49 +0100 | bilegeek_ | (~bilegeek@2600:1008:b014:2c7:531b:7b59:1891:ee3a) bilegeek |
2025-02-28 08:16:12 +0100 | merijn | (~merijn@host-vr.cgnat-g.v4.dfn.nl) merijn |
2025-02-28 08:11:16 +0100 | Lord_of_Life_ | Lord_of_Life |