Newest at the top
2025-04-16 15:49:50 +0200 | <bwe> | ski: how are the type signatures now? |
2025-04-16 15:49:35 +0200 | <bwe> | [exa]: >>= is now defined, incorporating s1 |
2025-04-16 15:48:57 +0200 | <ski> | MkState :: (s -> (a,s)) -> State s a |
2025-04-16 15:48:45 +0200 | <ski> | which you can abbreviate as |
2025-04-16 15:48:32 +0200 | <ski> | in symbols, if `x :: s -> (a,s)', then `MkState x :: State s a' |
2025-04-16 15:48:06 +0200 | <ski> | what this (BNF-inspired) notation *actually* means, is that if `x' has type `s -> (a,s)', then `MkState x' has type `State s a' |
2025-04-16 15:47:20 +0200 | dutchie | (~dutchie@user/dutchie) dutchie |
2025-04-16 15:47:19 +0200 | <ski> | this notation does not mean that the type `State s a' is equal to the "type" `MkState (s -> (a, s))' (this is not a type) |
2025-04-16 15:47:02 +0200 | dutchie | (~dutchie@user/dutchie) (Remote host closed the connection) |
2025-04-16 15:46:42 +0200 | <ski> | here is what's confusing |
2025-04-16 15:46:34 +0200 | <ski> | newtype State s a = MkState (s -> (a, s)) |
2025-04-16 15:46:33 +0200 | <ski> | presumably the notation |
2025-04-16 15:46:15 +0200 | <ski> | `MkState' is value-level (a data constructor), it's not type-level. so it makes no sense to mention it in the type signature |
2025-04-16 15:45:36 +0200 | <ski> | this makes no sense |
2025-04-16 15:45:32 +0200 | <ski> | -- (>>=) :: Monad m => MkState (s -> (a, s)) -> (a -> MkState (s -> (b, s))) -> MkState (s -> (b, s)) |
2025-04-16 15:45:29 +0200 | <ski> | ah, you updated it |
2025-04-16 15:44:49 +0200 | <ski> | the definition of `(>>=)' isn't quite correct, but i guess you knew that |
2025-04-16 15:42:07 +0200 | euleritian | (~euleritia@dynamic-176-002-178-231.176.2.pool.telefonica.de) |
2025-04-16 15:41:56 +0200 | <ski> | `fmap :: (a -> b) -> (s -> (a,s)) -> (s -> (b,s))' also, strictly speaking, isn't correct. but it's the type signature you'd get, if you were able to use `type State s a = (s -> (a,s))' |
2025-04-16 15:41:55 +0200 | euleritian | (~euleritia@ip5f5ad695.dynamic.kabel-deutschland.de) (Ping timeout: 276 seconds) |
2025-04-16 15:41:21 +0200 | <ski> | `State (s -> (a, s))' makes no sense, here |
2025-04-16 15:40:58 +0200 | merijn | (~merijn@host-vr.cgnat-g.v4.dfn.nl) (Ping timeout: 252 seconds) |
2025-04-16 15:40:35 +0200 | <bwe> | ski: puh, I don't get why the type signatures should be (s -> (a, s)) for Functor, wh? |
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 +0200 | ystael | (~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 +0200 | jacopovalanzano | (~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 +0200 | merijn | (~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 +0200 | L29Ah | (~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 +0200 | acidjnk | (~acidjnk@p200300d6e71c4f5865559714f8604ffa.dip0.t-ipconnect.de) (Ping timeout: 260 seconds) |
2025-04-16 15:27:11 +0200 | L29Ah | (~L29Ah@wikipedia/L29Ah) () |
2025-04-16 15:23:51 +0200 | haritz | (~hrtz@user/haritz) haritz |
2025-04-16 15:23:51 +0200 | haritz | (~hrtz@2a01:4b00:bc2e:7000:d5af:a266:ca31:5ef8) (Changing host) |
2025-04-16 15:23:51 +0200 | haritz | (~hrtz@2a01:4b00:bc2e:7000:d5af:a266:ca31:5ef8) |
2025-04-16 15:22:35 +0200 | gorignak | (~gorignak@user/gorignak) (Quit: quit) |