Logs: liberachat/#haskell
| 2021-08-02 06:18:51 | <euouae> | you can throw away the result of an IO action right? |
| 2021-08-02 06:18:51 | <yahb> | dminuoso: String -> IO () |
| 2021-08-02 06:18:57 | <dminuoso> | Yes. |
| 2021-08-02 06:19:23 | <euouae> | So there's always a projection `M a -> M t` |
| 2021-08-02 06:19:30 | <euouae> | Sorry, `M a -> M ()` |
| 2021-08-02 06:19:36 | <dminuoso> | Correct |
| 2021-08-02 06:19:40 | <Maxdamantus> | You can't have an `IO` action that emits no value, so the value `()` is used as a placeholder. |
| 2021-08-02 06:19:45 | <dminuoso> | % :t () <$ putStrLn "foo" -- euouae |
| 2021-08-02 06:19:45 | <yahb> | dminuoso: IO () |
| 2021-08-02 06:19:55 | <dminuoso> | This combinator is also, very confusingly, named `void` in base |
| 2021-08-02 06:19:58 | <dminuoso> | % :t void |
| 2021-08-02 06:19:58 | <yahb> | dminuoso: Functor f => f a -> f () |
| 2021-08-02 06:20:02 | <euouae> | Which means that function taking `M ()` may as well take `M a`, it's just a hint that they do nothing with `a` |
| 2021-08-02 06:20:08 | <dminuoso> | euouae: Precisely. |
| 2021-08-02 06:20:14 | <dminuoso> | You're spot on. |
| 2021-08-02 06:20:21 | <euouae> | However, they can't take `M a`, right? |
| 2021-08-02 06:20:30 | <dminuoso> | Also correct. |
| 2021-08-02 06:20:36 | <dminuoso> | Which is why `void` exists. |
| 2021-08-02 06:20:37 | <euouae> | Alright, thank you for clarifying everything :) |
| 2021-08-02 06:20:57 | <dminuoso> | It's for massaging values like IO actions into the right type, for when some other function demands say `IO ()` |
| 2021-08-02 06:21:10 | <dminuoso> | But you can also just write `() <$ foo` if you like |
| 2021-08-02 06:21:51 | <euouae> | But what does `() <$ putStrLn "Hello"` print |
| 2021-08-02 06:22:02 | <dminuoso> | Oh, well to be fair that's a silly thing to do |
| 2021-08-02 06:22:10 | <dminuoso> | % :T () <$ getLine |
| 2021-08-02 06:22:10 | <yahb> | dminuoso: unknown command ':T'; use :? for help. |
| 2021-08-02 06:22:12 | <dminuoso> | % :t () <$ getLine |
| 2021-08-02 06:22:12 | <yahb> | dminuoso: IO () |
| 2021-08-02 06:22:14 | <dminuoso> | This is a etter example |
| 2021-08-02 06:22:19 | → | Lord_of_Life_ joins (~Lord@user/lord-of-life/x-2819915) |
| 2021-08-02 06:22:45 | <euouae> | I see |
| 2021-08-02 06:22:47 | <dminuoso> | euouae: It sitll prints "Hello". The example is poor because putStrLn at the end already produces IO (). |
| 2021-08-02 06:23:04 | <dminuoso> | But with getLine, you still get the effect of consuing a string on stdin, but it throws away the result |
| 2021-08-02 06:23:20 | <euouae> | Right the type information is different than the side ffects |
| 2021-08-02 06:23:31 | <dminuoso> | Right. |
| 2021-08-02 06:23:32 | × | Lord_of_Life quits (~Lord@user/lord-of-life/x-2819915) (Ping timeout: 256 seconds) |
| 2021-08-02 06:23:33 | <euouae> | in some sense at least. of course IO is always there |
| 2021-08-02 06:23:34 | Lord_of_Life_ | is now known as Lord_of_Life |
| 2021-08-02 06:25:43 | <dminuoso> | euouae: Right, this is the beauty of this parametrized IO type. We separate the side-effect (IO) from the result of carrying out that side-effect. |
| 2021-08-02 06:26:04 | <dminuoso> | Now, of course we cant know what exact side-effects actually happen inside IO. And this is where the idea of effect systems begins. |
| 2021-08-02 06:26:13 | <dibblego> | IO is unrelated to side-effects |
| 2021-08-02 06:27:06 | × | gambpang quits (~ian@207.181.230.156) (Ping timeout: 272 seconds) |
| 2021-08-02 06:27:22 | → | gambpang joins (~ian@207.181.230.156) |
| 2021-08-02 06:28:31 | → | Obo joins (~roberto@70.pool90-171-81.dynamic.orange.es) |
| 2021-08-02 06:34:13 | × | guest86 quits (~guest86@2001:8004:1420:14ac:b1cc:c092:84b0:86f6) (Ping timeout: 246 seconds) |
| 2021-08-02 06:36:15 | <aegon> | Axman6: if your still around i found it out. This is the wierdest syntax yet fromJust (fromList x) is the way to get it from a list that has been built up by a function |
| 2021-08-02 06:36:33 | <aegon> | is the fromJust part of IsList stuff or is that something specific that the Hasktorch implementation did :? |
| 2021-08-02 06:38:10 | <Axman6> | :t fromJust |
| 2021-08-02 06:38:11 | <lambdabot> | Maybe a -> a |
| 2021-08-02 06:38:38 | <euouae> | dminuoso: Is this related? http://okmij.org/ftp/Haskell/extensible/exteff.pdf |
| 2021-08-02 06:38:41 | <Axman6> | I guess there's a IsList instnce for Maybe? that code looks quite confusing though |
| 2021-08-02 06:39:41 | <dminuoso> | euouae: Yes, this is one example. |
| 2021-08-02 06:42:05 | <euouae> | dminuoso: Ok I don't see it myself, but I trust that it's being researched :P I'll probably be learning the basics of cabal and the rest of the tools for now :) |
| 2021-08-02 06:42:12 | × | phma_ quits (phma@2001:5b0:211b:e2d8:c072:cd43:475:d917) (Read error: Connection reset by peer) |
| 2021-08-02 06:42:54 | → | gehmehgeh joins (~user@user/gehmehgeh) |
| 2021-08-02 06:43:08 | <dminuoso> | euouae: Yeah. Much in the effect systems is ongoing research and experimentation, and in Haskell in particular it's mostly limited to custom effects (in the sense of how do we compose various monadic effects together in an extensible and declarative way). |
| 2021-08-02 06:43:08 | → | phma_ joins (phma@2001:5b0:210d:4948:1e1a:34b5:d23e:1981) |
| 2021-08-02 06:47:47 | → | merijn joins (~merijn@83-160-49-249.ip.xs4all.nl) |
| 2021-08-02 06:55:08 | → | _ht joins (~quassel@82-169-194-8.biz.kpn.net) |
| 2021-08-02 06:57:07 | → | acidjnk_new joins (~acidjnk@p200300d0c72b9504b8b6f59e7f78d4aa.dip0.t-ipconnect.de) |
| 2021-08-02 07:01:27 | <sergio812> | I’m having trouble with QuickCheck’s “collect” when testing IO code... |
| 2021-08-02 07:01:37 | <sergio812> | I can easily modify a basic property like “prop_pure list = myImpl list === refImpl list” to add case distribution like so “prop_pure list = collect (length list) $ myImpl list === refImpl list”, and all works fine. |
| 2021-08-02 07:02:03 | <sergio812> | Now, how should I do to add case distribution to IO code like “prop_io list = monadicIO $ do { res <- run $ myImplIO list; assert $ res == refImpl list }”? |
| 2021-08-02 07:02:19 | <sergio812> | I tried tucking in “collect (length l) $” before “run” or “assert” and GHC complained about expecting type “PropertyM IO Int” or “PropertyM IO a0”, while actual type is “Property”. |
| 2021-08-02 07:02:20 | → | lortabac joins (~lortabac@2a01:e0a:541:b8f0:4a3f:fe34:92c5:875c) |
| 2021-08-02 07:02:33 | <sergio812> | I tried tucking in “collect (length l) $” after “run” or “assert” and GHC complained about expecting type “IO Int” or “Bool”, while actual type is “Property”. |
| 2021-08-02 07:02:42 | <sergio812> | Can I use “collect” for IO code? If so, how? If not, how can I add case distribution? |
| 2021-08-02 07:04:56 | → | dhouthoo joins (~dhouthoo@178-117-36-167.access.telenet.be) |
| 2021-08-02 07:10:29 | → | fendor joins (~fendor@77.119.222.253.wireless.dyn.drei.com) |
| 2021-08-02 07:11:12 | <c_wraith> | sergio812: Why are you trying to do it inside the do block? |
| 2021-08-02 07:11:23 | <c_wraith> | sergio812: it would work just fine if you did it outside |
| 2021-08-02 07:12:15 | <nshepperd> | sergio812: i think you're meant to use 'monitor' in io tests |
| 2021-08-02 07:12:38 | <nshepperd> | sergio812: https://hackage.haskell.org/package/QuickCheck-2.14.2/docs/Test-QuickCheck-Monadic.html#v:monitor |
| 2021-08-02 07:13:40 | <sergio812> | c_wraith: you mean, tuck in "collect (length list) $" before "monadicIO"? |
| 2021-08-02 07:14:09 | <c_wraith> | oh, if it is a scoping error, then yes. monitor is what you want |
| 2021-08-02 07:14:36 | × | takuan quits (~takuan@178-116-218-225.access.telenet.be) (Ping timeout: 272 seconds) |
| 2021-08-02 07:14:52 | <sergio812> | c_wraith: you're probably right that I can make do with putting it outside on this example |
| 2021-08-02 07:16:40 | × | tzh quits (~tzh@c-24-21-73-154.hsd1.or.comcast.net) (Quit: zzz) |
| 2021-08-02 07:16:41 | <sergio812> | nshepperd: thank you for pointing me to "monitor"! |
| 2021-08-02 07:17:13 | × | azeem quits (~azeem@dynamic-adsl-94-34-48-122.clienti.tiscali.it) (Remote host closed the connection) |
| 2021-08-02 07:17:26 | → | azeem joins (~azeem@dynamic-adsl-94-34-48-122.clienti.tiscali.it) |
| 2021-08-02 07:20:10 | × | geekosaur quits (~geekosaur@xmonad/geekosaur) (Ping timeout: 240 seconds) |
| 2021-08-02 07:21:52 | × | merijn quits (~merijn@83-160-49-249.ip.xs4all.nl) (Ping timeout: 258 seconds) |
| 2021-08-02 07:21:52 | × | jonathanx quits (~jonathan@h-178-174-176-109.A357.priv.bahnhof.se) (Read error: Connection reset by peer) |
| 2021-08-02 07:22:03 | → | jonathanx joins (~jonathan@h-178-174-176-109.A357.priv.bahnhof.se) |
| 2021-08-02 07:22:58 | → | mastarija joins (~mastarija@31.217.8.174) |
| 2021-08-02 07:24:06 | × | shriekingnoise quits (~shrieking@186.137.144.80) (Quit: Quit) |
| 2021-08-02 07:24:06 | × | favonia quits (~favonia@user/favonia) (Ping timeout: 272 seconds) |
| 2021-08-02 07:24:21 | <mastarija> | Do we have something like the "Alternative" type class, but that is related to "Semigroup" instead of "Monoid". I'd really like an instance of the Alternative, but without that annoying "empty" |
| 2021-08-02 07:24:48 | <dminuoso> | mastarija: Check out semigroupoids |
| 2021-08-02 07:24:51 | → | cfricke joins (~cfricke@user/cfricke) |
| 2021-08-02 07:25:05 | <mastarija> | dminuoso, nothing in base, huh? |
| 2021-08-02 07:25:08 | <dminuoso> | Right |
| 2021-08-02 07:25:17 | <dminuoso> | https://hackage.haskell.org/package/semigroupoids-5.3.5/docs/Data-Functor-Alt.html |
| 2021-08-02 07:25:29 | <dminuoso> | mastarija: ^- this is one of the reasons quite a few packages depend on semigroupoids. :) |
| 2021-08-02 07:25:36 | <mastarija> | :D |
| 2021-08-02 07:25:48 | <mastarija> | I guess mine will too |
| 2021-08-02 07:29:55 | → | jay-invariant joins (~jay@c-24-4-6-169.hsd1.ca.comcast.net) |
| 2021-08-02 07:30:06 | <dibblego> | Either is a good example instance |
| 2021-08-02 07:31:03 | <mastarija> | Would it be fine, if I write in my library, you are free to use the "empty", but if you do, you might loose the data you've been accumulating? |
| 2021-08-02 07:31:22 | <dibblego> | as long as it is lawful, sure |
All times are in UTC.