2024/05/01

Newest at the top

2024-05-01 21:54:06 +0200 <mauke> 's' can still be arbitrary
2024-05-01 21:53:41 +0200 <mauke> newSTRef just links up the STRef with its surrounding context (that is, it forces the two 's' parameters to be the same)
2024-05-01 21:52:13 +0200 <monochrom> s/conflicts/confirms/ . The erroneous code is precisely a victim of a rigid s.
2024-05-01 21:50:30 +0200 <monochrom> Here is another elementary answer. goo can take that parameter, but don't call runST. goo :: ST s (STRef s [Int]) -> ST s [Int]. Have someone else write "runST (goo x)".
2024-05-01 21:50:12 +0200 <Guest67> it.  But it turns out that their suggestion works, and I can apply goo to x
2024-05-01 21:50:11 +0200 <Guest67> Thanks.  That makes sense in a vacuum, but it kind of conflicts with my understand of why newSTRef [1..10] returns something of type ST s (STRef s [Int]) to begin with.  I thought the whole point of doing that is that it forces the type variable s to become "rigid", so the variable x is no longer a polymorphic value that works with all choices of
2024-05-01 21:49:58 +0200 <shapr> hackage codebase is kinda rough
2024-05-01 21:46:55 +0200noumenon(~noumenon@113.51-175-156.customer.lyse.net)
2024-05-01 21:44:31 +0200 <mauke> ^ monochrom's code basically says: "you don't get to choose an s; you must give me a polymorphic value that works with all possible choices of s"
2024-05-01 21:44:29 +0200AlexNoo_(~AlexNoo@94.233.240.47) (Client Quit)
2024-05-01 21:44:29 +0200AlexNoo_(~AlexNoo@94.233.240.47)
2024-05-01 21:43:42 +0200 <monochrom> I don't have time to further explain the advanced answer if you don't understand it.
2024-05-01 21:43:22 +0200 <monochrom> If you want an advanced answer, if you really want goo to take that parameter, then "goo :: (forall s. ST s (STRef s [Int])) -> [Int]"
2024-05-01 21:43:20 +0200 <mauke> and that's not valid as an argument to runST
2024-05-01 21:43:00 +0200 <mauke> that is, there could be some specific type T and someone could create a value of type ST T (STRef T [Int]) and pass it to goo
2024-05-01 21:42:41 +0200 <monochrom> If you want an elementary answer, goo should not take that parameter.
2024-05-01 21:42:06 +0200 <mauke> the way goo is declared, the caller of goo gets to choose an 's'
2024-05-01 21:41:36 +0200 <mauke> it just passes through whatever s it gets
2024-05-01 21:41:22 +0200 <mauke> readSTRef has no special requirements on s
2024-05-01 21:41:11 +0200 <mauke> depends
2024-05-01 21:41:07 +0200 <lambdabot> STRef s a -> ST s a
2024-05-01 21:41:06 +0200 <mauke> :t readSTRef
2024-05-01 21:40:57 +0200 <Guest67> Does readSTRef ref not return a value that's fully polymorphic in s?
2024-05-01 21:40:46 +0200 <mauke> but goo does not
2024-05-01 21:40:37 +0200 <mauke> runST requires its argument to be fully polymorphic in s
2024-05-01 21:40:15 +0200 <lambdabot> (forall s. ST s a) -> a
2024-05-01 21:40:14 +0200 <mauke> :t runST
2024-05-01 21:39:58 +0200 <mauke> goo's type looks sus
2024-05-01 21:38:40 +0200 <Guest67> In foo, that's not supposed to be a smiley face, it's supposed to be "(0 : )"
2024-05-01 21:38:16 +0200 <Guest67>     readSTRef ref
2024-05-01 21:38:16 +0200 <Guest67>     foo ref
2024-05-01 21:38:15 +0200 <Guest67>     ref <- x — type error here
2024-05-01 21:38:15 +0200 <Guest67> goo x = runST $ do
2024-05-01 21:38:14 +0200 <Guest67> goo :: ST s (STRef s [Int]) -> [Int]
2024-05-01 21:38:14 +0200 <Guest67> foo ref = modifySTRef ref (0 :)
2024-05-01 21:38:13 +0200 <Guest67> foo :: STRef s [Int] -> ST s ()
2024-05-01 21:38:13 +0200 <Guest67> x = newSTRef $ [1..10]
2024-05-01 21:38:12 +0200 <Guest67> x :: ST s (STRef s [Int])
2024-05-01 21:38:12 +0200 <Guest67> Could anyone help me understand why this code doesn’t work/what the correct way of achieving this sort of functionality is? The type error lies with the parameter x in goo, when I left-arrow bind it to ref.
2024-05-01 21:35:41 +0200Guest67(~Guest67@129.170.197.127)
2024-05-01 21:34:02 +0200Batzy(~quassel@user/batzy)
2024-05-01 21:14:44 +0200malte(~malte@mal.tc)
2024-05-01 21:14:12 +0200tessd(~test@evw199.neoplus.adsl.tpnet.pl)
2024-05-01 21:13:34 +0200malte(~malte@mal.tc) (Remote host closed the connection)
2024-05-01 21:11:00 +0200madeleine-sydney(~madeleine@c-76-155-235-153.hsd1.co.comcast.net)
2024-05-01 21:09:46 +0200michalz(~michalz@185.246.207.200)
2024-05-01 21:09:15 +0200emmanuelux(~emmanuelu@user/emmanuelux)
2024-05-01 21:07:11 +0200michalz(~michalz@185.246.207.218) (Client Quit)
2024-05-01 21:05:43 +0200michalz(~michalz@185.246.207.218)
2024-05-01 21:02:40 +0200michalz(~michalz@185.246.207.218) (Client Quit)