Logs: liberachat/#haskell
| 2021-08-11 08:34:15 | <merijn> | but don't kid yourself that this code is not *wildly* unsafe |
| 2021-08-11 08:34:18 | <kuribas> | There is no garantee of safety in IO, which is why IO exists. |
| 2021-08-11 08:34:29 | <merijn> | kuribas: IO guarantees lots of safety |
| 2021-08-11 08:34:36 | <Taneb> | kuribas: this makes there no guarantee of safety in some later not-IO |
| 2021-08-11 08:34:38 | <Cajun> | i would say as a rule of thumb avoid unsafePerformIO unless its provably pure |
| 2021-08-11 08:34:38 | <merijn> | There is no guarantee of safety in code using/doing unsafe things |
| 2021-08-11 08:34:44 | × | img quits (~img@user/img) (Quit: ZNC 1.8.2 - https://znc.in) |
| 2021-08-11 08:34:53 | <kuribas> | Taneb: yes it does. The resulting function is pure. |
| 2021-08-11 08:35:50 | <Taneb> | No it isn;t |
| 2021-08-11 08:35:56 | <kuribas> | yes it is. |
| 2021-08-11 08:35:58 | <Taneb> | It can randomly do side effects |
| 2021-08-11 08:36:01 | <Taneb> | It just pretends to be pure |
| 2021-08-11 08:36:32 | <kuribas> | Taneb: It's the IO which does the side-effects. |
| 2021-08-11 08:36:49 | <merijn> | kuribas: That resulting function is not pure |
| 2021-08-11 08:36:56 | <merijn> | kuribas: For any sensible or common definition of pure |
| 2021-08-11 08:37:04 | <Cajun> | youre *always* doing IO when you use unsafePerformIO correct? |
| 2021-08-11 08:37:13 | <Taneb> | kuribas: the IO tag is long gone when the side effects can happen |
| 2021-08-11 08:37:18 | <merijn> | Cajun: "maybe" |
| 2021-08-11 08:37:24 | <kuribas> | Taneb: true |
| 2021-08-11 08:37:30 | × | cawfee quits (~root@2406:3003:2077:2758::babe) (Ping timeout: 240 seconds) |
| 2021-08-11 08:37:38 | <merijn> | Cajun: You should consider "unsafePerformIO" to mean "I'm ok with this happening 0, 1, or more times" |
| 2021-08-11 08:37:55 | <Cajun> | does linearTypes not solve that? |
| 2021-08-11 08:38:03 | <merijn> | Cajun: Since it might end up getting completely optimised away :p |
| 2021-08-11 08:38:03 | <kuribas> | Taneb: but that can be true of any IO action. |
| 2021-08-11 08:38:03 | → | mc47 joins (~mc47@xmonad/TheMC47) |
| 2021-08-11 08:38:06 | <Cajun> | or whatever the new thing was called that means it can only be used once |
| 2021-08-11 08:38:10 | <merijn> | kuribas: No |
| 2021-08-11 08:38:21 | <merijn> | kuribas: That is true of any *code* (IO or no) that uses unsafeX |
| 2021-08-11 08:38:42 | <merijn> | kuribas: Which is why you should not use unsafeX unless you know what you're doing, since it completely invalidates all safety |
| 2021-08-11 08:38:53 | <Cajun> | ST monad uses unsafePerformIO and is entirely type safe |
| 2021-08-11 08:39:04 | <merijn> | Cajun: It does not |
| 2021-08-11 08:39:25 | <merijn> | Cajun: At least, not last time I looked at all the implementation |
| 2021-08-11 08:39:30 | <merijn> | Cajun: It would make no sense, anyway |
| 2021-08-11 08:39:57 | <merijn> | Cajun: Both ST and IO are implemented using the same ST# (i.e. primitive ST) monad inside GHC |
| 2021-08-11 08:40:12 | <Cajun> | ah yeah it doesnt, it does use unsafe functions but not that specific one |
| 2021-08-11 08:40:15 | → | pilyn joins (~pilyn@user/pilyn) |
| 2021-08-11 08:40:23 | <merijn> | Cajun: It doesn't use unsafe functions, afaik |
| 2021-08-11 08:40:31 | <merijn> | Cajun: It doesn't have to, because it's not unsafe |
| 2021-08-11 08:40:43 | × | hnOsmium0001 quits (uid453710@id-453710.stonehaven.irccloud.com) (Quit: Connection closed for inactivity) |
| 2021-08-11 08:40:45 | <merijn> | ST is perfectly fine and cromulent |
| 2021-08-11 08:40:49 | <kuribas> | merijn: we can debate this, but "memoize2 :: (Eq a, Hashable a) => (a -> IO b) -> (a -> b)" is far, far worse. |
| 2021-08-11 08:41:09 | <merijn> | kuribas: Not really |
| 2021-08-11 08:41:11 | <kuribas> | and far less predictable. |
| 2021-08-11 08:41:16 | <merijn> | kuribas: No |
| 2021-08-11 08:41:19 | <merijn> | It's really not |
| 2021-08-11 08:41:40 | <merijn> | It superficially looks less safe than your current version |
| 2021-08-11 08:41:50 | <merijn> | But practically speaking it's exactly as bad as what you have now |
| 2021-08-11 08:42:25 | <Cajun> | merijn: it does define some unsafe functions but thats for lazy deference of the monad well i know you can implement a typesafe version of the ST monad in normal haskell (not GHC nonsense :P ) using unsafePerformIO |
| 2021-08-11 08:42:55 | <Cajun> | those two sentences didnt meld together well but i hope you get the idea lol |
| 2021-08-11 08:46:04 | × | cheater quits (~Username@user/cheater) (Ping timeout: 268 seconds) |
| 2021-08-11 08:46:44 | → | Pickchea joins (~private@user/pickchea) |
| 2021-08-11 08:47:04 | → | fendor joins (~fendor@213162073240.public.t-mobile.at) |
| 2021-08-11 08:49:16 | → | img joins (~img@user/img) |
| 2021-08-11 08:50:12 | → | burnsidesLlama joins (~burnsides@client-8-91.eduroam.oxuni.org.uk) |
| 2021-08-11 08:53:39 | → | raehik joins (~raehik@cpc95906-rdng25-2-0-cust156.15-3.cable.virginm.net) |
| 2021-08-11 08:55:37 | <kuribas> | merijn: I don't disagree that it's unsafe, I disagree that IO has to be safe, or that its effects have to be momentarily. |
| 2021-08-11 08:56:20 | <kuribas> | For example, and IO action returns a value, and no side effects will happen after returning that value. |
| 2021-08-11 08:56:36 | <kuribas> | It's a good property to have, but it's not a property that IO is garanteed to have. |
| 2021-08-11 08:56:42 | <merijn> | That's 100% in the absence of threading |
| 2021-08-11 08:56:58 | → | ubert joins (~Thunderbi@91.141.49.166.wireless.dyn.drei.com) |
| 2021-08-11 08:57:17 | <kuribas> | what about interupts, timers? |
| 2021-08-11 08:57:42 | <merijn> | Can't set interrupt or timers that (visibly) affect non-IO code |
| 2021-08-11 08:57:59 | → | drd joins (~drd@93-39-151-19.ip76.fastwebnet.it) |
| 2021-08-11 08:57:59 | → | cheater joins (~Username@user/cheater) |
| 2021-08-11 08:57:59 | <merijn> | Timers, interrupts, and async exceptions are only visible within IO |
| 2021-08-11 08:58:10 | <merijn> | Pure code can't notice them |
| 2021-08-11 08:58:27 | → | chomwitt joins (~chomwitt@2a02:587:dc02:6400:12c3:7bff:fe6d:d374) |
| 2021-08-11 09:00:11 | <kuribas> | merijn: you cannot "see" the effects of the IO in my signature above. From IO, yes, but not from pure code. |
| 2021-08-11 09:01:29 | <kuribas> | hmm, well maybe you can |
| 2021-08-11 09:01:34 | <kuribas> | with lazyIO... |
| 2021-08-11 09:01:40 | <merijn> | Anyway, I'm bored of this discussion |
| 2021-08-11 09:01:46 | × | burnsidesLlama quits (~burnsides@client-8-91.eduroam.oxuni.org.uk) (Remote host closed the connection) |
| 2021-08-11 09:02:21 | → | burnsidesLlama joins (~burnsides@client-8-91.eduroam.oxuni.org.uk) |
| 2021-08-11 09:02:24 | <merijn> | I'll pre-emptively give you my "I told you so", feel free to cash it in at any later point when things blow up :p |
| 2021-08-11 09:02:26 | <kuribas> | yeah, I am not sure I'll use it anyway... |
| 2021-08-11 09:02:43 | <kuribas> | merijn: sure :)à |
| 2021-08-11 09:05:07 | → | montxero joins (~user@149.167.149.74) |
| 2021-08-11 09:06:41 | × | burnsidesLlama quits (~burnsides@client-8-91.eduroam.oxuni.org.uk) (Ping timeout: 248 seconds) |
| 2021-08-11 09:08:31 | → | cawfee joins (~root@2406:3003:2077:2758::babe) |
| 2021-08-11 09:10:44 | × | raehik quits (~raehik@cpc95906-rdng25-2-0-cust156.15-3.cable.virginm.net) (Ping timeout: 268 seconds) |
| 2021-08-11 09:11:51 | → | silasfox joins (~silasfox@62.159.27.1) |
| 2021-08-11 09:12:03 | → | raehik joins (~raehik@cpc95906-rdng25-2-0-cust156.15-3.cable.virginm.net) |
| 2021-08-11 09:13:59 | adam1 | is now known as gfunk |
| 2021-08-11 09:15:30 | gfunk | is now known as adam1 |
| 2021-08-11 09:20:44 | × | adam1 quits (~adam@2001-b011-4007-0cae-c534-472f-0009-0a8c.dynamic-ip6.hinet.net) (Quit: WeeChat 3.2) |
| 2021-08-11 09:22:31 | → | adam1 joins (~adam@2001-b011-4007-0cae-c534-472f-0009-0a8c.dynamic-ip6.hinet.net) |
| 2021-08-11 09:26:05 | × | silasfox quits (~silasfox@62.159.27.1) (Quit: Connection closed) |
| 2021-08-11 09:28:32 | → | silasfox joins (~silasfox@62.159.27.1) |
| 2021-08-11 09:30:24 | × | lortabac quits (~lortabac@2a01:e0a:541:b8f0:fe6f:ef7e:c421:8ab8) (Quit: WeeChat 2.8) |
| 2021-08-11 09:34:32 | × | silasfox quits (~silasfox@62.159.27.1) (Quit: Connection closed) |
| 2021-08-11 09:36:23 | → | burnsidesLlama joins (~burnsides@dhcp168-023.wadham.ox.ac.uk) |
| 2021-08-11 09:37:16 | → | silasfox joins (~silasfox@62.159.27.1) |
| 2021-08-11 09:40:16 | × | cods quits (~fred@82-65-232-44.subs.proxad.net) (Ping timeout: 250 seconds) |
| 2021-08-11 09:40:26 | × | montxero quits (~user@149.167.149.74) (Read error: No route to host) |
| 2021-08-11 09:40:37 | → | cods joins (~fred@82-65-232-44.subs.proxad.net) |
| 2021-08-11 09:40:57 | × | burnsidesLlama quits (~burnsides@dhcp168-023.wadham.ox.ac.uk) (Ping timeout: 268 seconds) |
| 2021-08-11 09:43:07 | × | chomwitt quits (~chomwitt@2a02:587:dc02:6400:12c3:7bff:fe6d:d374) (Ping timeout: 258 seconds) |
| 2021-08-11 09:44:13 | × | adam1 quits (~adam@2001-b011-4007-0cae-c534-472f-0009-0a8c.dynamic-ip6.hinet.net) (Quit: WeeChat 3.2) |
| 2021-08-11 09:47:03 | → | Lycurgus joins (~juan@cpe-45-46-140-49.buffalo.res.rr.com) |
| 2021-08-11 09:56:31 | <Gurkenglas> | Is there a library that wraps all the reasonable uses of unsafePerformIO, or is there folk knowledge to the effect that you could never cover exactly the reasonable usecases? |
All times are in UTC.