Newest at the top
2024-05-03 16:31:38 +0200 | stiell | (~stiell@gateway/tor-sasl/stiell) |
2024-05-03 16:31:33 +0200 | onion | (~yin@user/zero) (Ping timeout: 256 seconds) |
2024-05-03 16:31:03 +0200 | <gaff> | so when `p` fails, for example, the monadic style can short circuit computation where as the applicative style may not. |
2024-05-03 16:30:26 +0200 | stiell | (~stiell@gateway/tor-sasl/stiell) (Ping timeout: 260 seconds) |
2024-05-03 16:30:09 +0200 | <gaff> | kuribas: exactly |
2024-05-03 16:29:47 +0200 | Sgeo | (~Sgeo@user/sgeo) |
2024-05-03 16:29:45 +0200 | <kuribas> | gaff: note that 'x' could be lazy, but it most be "produced" by effect "p", before the lambda can be evaulated, which is not true in the applicated. |
2024-05-03 16:27:49 +0200 | <gaff> | EvanR: I mean from the standpoint of evaluation/laziness. |
2024-05-03 16:27:33 +0200 | <EvanR> | your code might be an example where they end up doing the same thing, but definitely different in general |
2024-05-03 16:27:21 +0200 | stiell_ | (~stiell@gateway/tor-sasl/stiell) |
2024-05-03 16:27:05 +0200 | <EvanR> | if the general question is, is there any difference between do notation and applicative style, yes they end up going through two different type classes |
2024-05-03 16:27:02 +0200 | <kuribas> | gaff: not necessarily. It could be a lazy monad. |
2024-05-03 16:26:30 +0200 | <gaff> | kuribas: I know |
2024-05-03 16:26:10 +0200 | <gaff> | wha I found was that the binding in the `do` block forces an evaluation while in the applicative style it may/does not. I am not sure I am right, though. |
2024-05-03 16:25:12 +0200 | <kuribas> | gaff: the do desugars to: p >>= \x -> many p >>= \xs -> return (x:xs) |
2024-05-03 16:24:50 +0200 | stiell_ | (~stiell@gateway/tor-sasl/stiell) (Ping timeout: 260 seconds) |
2024-05-03 16:24:31 +0200 | <EvanR> | different implementations |
2024-05-03 16:24:30 +0200 | <kuribas> | gaff: For a lawful instance the should be the same, but it isn't garanteed. |
2024-05-03 16:24:25 +0200 | <EvanR> | oh you're right. But yeah |
2024-05-03 16:24:23 +0200 | <gaff> | well, `some` in that example has the same type in both styles. |
2024-05-03 16:23:53 +0200 | <EvanR> | they don't have the same type by default |
2024-05-03 16:23:53 +0200 | <lambdabot> | Num p => p |
2024-05-03 16:23:52 +0200 | <kuribas> | :t 4 |
2024-05-03 16:23:51 +0200 | <lambdabot> | Num p => p |
2024-05-03 16:23:50 +0200 | <kuribas> | :t 3 |
2024-05-03 16:23:42 +0200 | <kuribas> | gaff: Some type doesn't mean the same expression. |
2024-05-03 16:23:25 +0200 | <lambdabot> | Monad m => a -> m a |
2024-05-03 16:23:25 +0200 | <EvanR> | :t return |
2024-05-03 16:23:08 +0200 | tv | (~tv@user/tv) |
2024-05-03 16:22:58 +0200 | <gaff> | EvanR: I am not sure what you mena there, Both expressions have the same type. |
2024-05-03 16:22:15 +0200 | <EvanR> | otherwise, one expands to Monad the other Applicative class |
2024-05-03 16:21:50 +0200 | <EvanR> | not if you enable ApplicativeDo |
2024-05-03 16:21:43 +0200 | agent314_ | (~quassel@104.193.135.218) (Ping timeout: 268 seconds) |
2024-05-03 16:21:37 +0200 | agent314 | (~quassel@185.102.218.105.adsl.inet-telecom.org) |
2024-05-03 16:21:35 +0200 | stiell | (~stiell@gateway/tor-sasl/stiell) |
2024-05-03 16:20:10 +0200 | stiell | (~stiell@gateway/tor-sasl/stiell) (Ping timeout: 260 seconds) |
2024-05-03 16:19:23 +0200 | onion | (~yin@user/zero) |
2024-05-03 16:19:14 +0200 | <gaff> | Is there any difference between writing code in the applicative vs monadic style? For example, `some p = do { x <- p; xs <- many p; return (x:xs) }` VS `some p = (:) <$> p <*> many p`? |
2024-05-03 16:17:43 +0200 | onion | (~yin@user/zero) (Ping timeout: 255 seconds) |
2024-05-03 16:17:20 +0200 | <kuribas> | "forall a. " means "for any type a" |
2024-05-03 16:17:05 +0200 | waleee | (~waleee@h-176-10-144-38.NA.cust.bahnhof.se) (Quit: WeeChat 4.1.2) |
2024-05-03 16:16:54 +0200 | <kuribas> | That's what (f :: forall a. a -> a) means |
2024-05-03 16:16:38 +0200 | gaff | (~gaff@49.207.227.255) |
2024-05-03 16:16:25 +0200 | stiell_ | (~stiell@gateway/tor-sasl/stiell) |
2024-05-03 16:16:21 +0200 | <kuribas> | First argument of "id'" should be a function that works on any type. |
2024-05-03 16:16:19 +0200 | machinedgod | (~machinedg@d173-183-246-216.abhsia.telus.net) |
2024-05-03 16:15:30 +0200 | stiell_ | (~stiell@gateway/tor-sasl/stiell) (Ping timeout: 260 seconds) |
2024-05-03 16:15:19 +0200 | <kuribas> | You say succ would work with any type, but it doesn't. |
2024-05-03 16:11:35 +0200 | stiell | (~stiell@gateway/tor-sasl/stiell) |
2024-05-03 16:11:26 +0200 | danse-nr3 | (~danse-nr3@151.43.124.243) (Ping timeout: 255 seconds) |