2025/04/16

Newest at the top

2025-04-16 15:39:40 +0200 <ski> MkState f <*> MkState g = ..f..g..
2025-04-16 15:39:31 +0200 <ski> also could be written as
2025-04-16 15:39:24 +0200 <ski> (<*>) (MkState f) (MkState g) = ..f..g..
2025-04-16 15:38:35 +0200 <ski> to the first line, you can uncomment one of the type signatures, for each method of each instance
2025-04-16 15:38:17 +0200 <ski> {-# LANGUAGE InstanceSigs #-}
2025-04-16 15:38:08 +0200 <ski> if you add
2025-04-16 15:37:47 +0200ystael(~ystael@user/ystael) ystael
2025-04-16 15:36:36 +0200 <bwe> [exa]: updated. includes Monad definition now, however I don't use the s1 yet, I should, right?
2025-04-16 15:35:55 +0200 <ski> -- <*> :: (s0 -> (a -> b,s1)) -> (s0 -> (a,s1)) -> (s0 -> (b,s1)) -- well, actually not quite this, either. can you see why ?
2025-04-16 15:35:11 +0200 <ski> should be
2025-04-16 15:35:08 +0200 <ski> -- <*> :: MkState (s0 -> (a -> b, s1)) -> MkState (s0 -> (a, s1)) -> MkState (s0 -> (b, s1))
2025-04-16 15:35:06 +0200 <ski> similarly
2025-04-16 15:35:00 +0200jacopovalanzano(~jacopoval@cpc151911-cove17-2-0-cust105.3-1.cable.virginm.net)
2025-04-16 15:34:28 +0200 <ski> -- fmap :: (a -> b) -> (s -> (a,s)) -> (s -> (b,s))
2025-04-16 15:34:18 +0200 <ski> should be
2025-04-16 15:34:17 +0200 <ski> -- fmap :: (a -> b) -> State (s -> (a, s)) -> State (s -> (b, s))
2025-04-16 15:33:57 +0200merijn(~merijn@host-vr.cgnat-g.v4.dfn.nl) merijn
2025-04-16 15:32:11 +0200 <[exa]> bwe: for the monad instance the only thing you might need to do is to unpack the `f` from State, and repack the result
2025-04-16 15:31:51 +0200 <[exa]> bwe: looks all OK to me
2025-04-16 15:28:38 +0200L29Ah(~L29Ah@wikipedia/L29Ah) L29Ah
2025-04-16 15:27:36 +0200 <bwe> Functor and Applicative: https://github.com/benjaminweb/state-monad/blob/main/src/MyLib.hs
2025-04-16 15:27:15 +0200acidjnk(~acidjnk@p200300d6e71c4f5865559714f8604ffa.dip0.t-ipconnect.de) (Ping timeout: 260 seconds)
2025-04-16 15:27:11 +0200L29Ah(~L29Ah@wikipedia/L29Ah) ()
2025-04-16 15:23:51 +0200haritz(~hrtz@user/haritz) haritz
2025-04-16 15:23:51 +0200haritz(~hrtz@2a01:4b00:bc2e:7000:d5af:a266:ca31:5ef8) (Changing host)
2025-04-16 15:23:51 +0200haritz(~hrtz@2a01:4b00:bc2e:7000:d5af:a266:ca31:5ef8)
2025-04-16 15:22:35 +0200gorignak(~gorignak@user/gorignak) (Quit: quit)
2025-04-16 15:21:21 +0200merijn(~merijn@host-vr.cgnat-g.v4.dfn.nl) (Ping timeout: 248 seconds)
2025-04-16 15:20:59 +0200haritz(~hrtz@user/haritz) (Read error: Connection reset by peer)
2025-04-16 15:19:12 +0200Googulator82(~Googulato@94-21-172-228.pool.digikabel.hu)
2025-04-16 15:18:44 +0200Googulator82(~Googulato@2a01-036d-0106-2077-315b-d519-517f-afe7.pool6.digikabel.hu) (Quit: Client closed)
2025-04-16 15:16:17 +0200merijn(~merijn@host-vr.cgnat-g.v4.dfn.nl) merijn
2025-04-16 15:15:12 +0200Cattycatties
2025-04-16 15:11:54 +0200merijn(~merijn@host-vr.cgnat-g.v4.dfn.nl) (Ping timeout: 260 seconds)
2025-04-16 15:10:06 +0200 <ski> .. or `newtype State s a = MkState {runState :: s -> (a,s)}', using record syntax notation to automagically get the projection/selector
2025-04-16 15:10:03 +0200weary-traveler(~user@user/user363627) user363627
2025-04-16 15:09:44 +0200Guest38(~Guest38@175.143.89.234) ()
2025-04-16 15:08:59 +0200Guest38(~Guest38@175.143.89.234)
2025-04-16 15:08:45 +0200skiwould use `newtype State s a = MkState (s -> (a,s))', for clarity
2025-04-16 15:07:02 +0200merijn(~merijn@host-vr.cgnat-g.v4.dfn.nl) merijn
2025-04-16 15:00:54 +0200ljdarj(~Thunderbi@user/ljdarj) ljdarj
2025-04-16 14:54:35 +0200merijn(~merijn@host-vr.cgnat-g.v4.dfn.nl) (Ping timeout: 260 seconds)
2025-04-16 14:51:07 +0200 <bwe> coming from: type State s a = (s -> (a, s))
2025-04-16 14:50:58 +0200amadaluzia(~amadaluzi@user/amadaluzia) amadaluzia
2025-04-16 14:50:41 +0200 <bwe> So, I am starting now with: newtype State s a = State (s -> (a, s))
2025-04-16 14:50:34 +0200amadaluzia(~amadaluzi@user/amadaluzia) (Ping timeout: 276 seconds)
2025-04-16 14:50:25 +0200ljdarj(~Thunderbi@user/ljdarj) (Ping timeout: 248 seconds)
2025-04-16 14:50:02 +0200bitdex(~bitdex@gateway/tor-sasl/bitdex) (Quit: = "")
2025-04-16 14:49:37 +0200merijn(~merijn@host-vr.cgnat-g.v4.dfn.nl) merijn
2025-04-16 14:49:13 +0200 <[exa]> which is annoying but that ensures that the typesystem can actually work with your stateful computation s->(s,a) specially, not just like some other function