Newest at the top
2025-01-30 20:16:57 +0100 | <tomsmeding> | that "one" there is significant: it means that if a data type is an instance of Functor/Applicative/Monad, it is in its _last_ type parameter |
2025-01-30 20:16:53 +0100 | <[exa]> | euouae: it's quite useful to start with the standard ones, for example a good workalike for your MyMonad would be a tuple type ( instance Functor ((,) a) ) |
2025-01-30 20:16:34 +0100 | <tomsmeding> | that means that it should be a thing that takes one more type argument, and then produces an actual type |
2025-01-30 20:16:28 +0100 | MyNetAz | (~MyNetAz@user/MyNetAz) (Remote host closed the connection) |
2025-01-30 20:16:28 +0100 | alexherbo2 | (~alexherbo@2a02-8440-3504-afc6-21c9-80c8-175a-acbd.rev.sfr.net) alexherbo2 |
2025-01-30 20:16:23 +0100 | <euouae> | oh, instance Functor (MyMonad a) where works |
2025-01-30 20:16:21 +0100 | <tomsmeding> | 'Monad' (and 'Functor', etc.) requires its argument to be of kind Type -> Type (traditionally written * -> *) |
2025-01-30 20:16:02 +0100 | <euouae> | what are the right instance definitions for Functor, etc? I can't use 'MyMonad' because it is not the right kind |
2025-01-30 20:15:35 +0100 | <[exa]> | yap that should work |
2025-01-30 20:15:23 +0100 | <[exa]> | (e.g. `fmap length` normally has type Functor f => f [a] -> f Int. If you used MyMonad instead of `f`, it wouldn't have a space to store the information about "what's inside" |
2025-01-30 20:15:07 +0100 | <euouae> | well let's revise to `data MyMonad a b = C a b` |
2025-01-30 20:14:24 +0100 | merijn | (~merijn@host-vr.cgnat-g.v4.dfn.nl) (Ping timeout: 260 seconds) |
2025-01-30 20:14:02 +0100 | <[exa]> | (so they need the variable there) |
2025-01-30 20:13:53 +0100 | <[exa]> | that's the data constructor, that's ok. You need a type-level parameter though, because `fmap` and other functions are supposed to mess with that type |
2025-01-30 20:13:31 +0100 | <euouae> | Ah, so you need it to be a * -> * |
2025-01-30 20:13:23 +0100 | <euouae> | Doesn't its constructor have two arguments |
2025-01-30 20:13:08 +0100 | <[exa]> | euouae: but MyMonad has no arguments? |
2025-01-30 20:13:04 +0100 | <euouae> | something like `instance Functor (MyMonad Int) where` to begin with doesn't seem to work |
2025-01-30 20:12:42 +0100 | <euouae> | Now if I have a `data MyMonad = C Int Int`, how can I make it monadic in the second argument? How can I make it monadic in the first argument? |
2025-01-30 20:11:42 +0100 | Pozyomka | (~pyon@user/pyon) (Ping timeout: 276 seconds) |
2025-01-30 20:10:54 +0100 | Pozyomka_ | (~pyon@user/pyon) pyon |
2025-01-30 20:09:54 +0100 | merijn | (~merijn@host-vr.cgnat-g.v4.dfn.nl) merijn |
2025-01-30 20:09:08 +0100 | alfiee | (~alfiee@user/alfiee) (Ping timeout: 245 seconds) |
2025-01-30 20:05:10 +0100 | zlqrvx | (~zlqrvx@user/zlqrvx) zlqrvx |
2025-01-30 20:04:58 +0100 | alfiee | (~alfiee@user/alfiee) alfiee |
2025-01-30 20:04:10 +0100 | <lambdabot> | Num a => a |
2025-01-30 20:04:09 +0100 | <mauke> | :t 1 + 2 * 3 |
2025-01-30 20:02:54 +0100 | <euouae> | expr + type yeah |
2025-01-30 20:02:45 +0100 | <geekosaur> | prob ably defaults to showing the type if it can't show the value |
2025-01-30 20:02:29 +0100 | <euouae> | For w/e reason my repl shows it like it does |
2025-01-30 20:02:18 +0100 | <euouae> | I see, ok. It's just a style thing, it's not related to evaluation |
2025-01-30 20:01:56 +0100 | <geekosaur> | which I would expect |
2025-01-30 20:01:51 +0100 | <geekosaur> | fwiw I tried that here and I got a "No instance for `Show (MyMonad Int)` |
2025-01-30 20:00:42 +0100 | zlqrvx | (~zlqrvx@user/zlqrvx) (Ping timeout: 252 seconds) |
2025-01-30 19:59:52 +0100 | <euouae> | mauke: Interactive-Haskell in Emacs |
2025-01-30 19:59:31 +0100 | <euouae> | ncf, oh yeah I get what you mean, thank you |
2025-01-30 19:59:24 +0100 | <mauke> | euouae: what repl? |
2025-01-30 19:59:06 +0100 | <ncf> | <euouae> Hello functions of the type Functor f => f a -> f b, what are they called? |
2025-01-30 19:58:54 +0100 | <euouae> | It's what happens when I hit enter in the repl geekosaur -- ncf not sure what you're talking about |
2025-01-30 19:58:45 +0100 | <ncf> | (assuming f, a, b are universally quantified) |
2025-01-30 19:58:33 +0100 | merijn | (~merijn@host-vr.cgnat-g.v4.dfn.nl) (Ping timeout: 246 seconds) |
2025-01-30 19:58:32 +0100 | <ncf> | euouae: they're not called anything particular since there aren't any. |
2025-01-30 19:56:33 +0100 | <geekosaur> | that doesn't look like the result of evaluation, only of typechecking? |
2025-01-30 19:51:51 +0100 | merijn | (~merijn@host-vr.cgnat-g.v4.dfn.nl) merijn |
2025-01-30 19:50:29 +0100 | <euouae> | But why is it not C1 2? I've found that deriving Show will make it say C1 2. I've also found that deriving Eq will make it == C1 2. But is it just stylistic or is there something deeper here with regards to evaluation? |
2025-01-30 19:49:47 +0100 | <euouae> | Hello, I have this small code to define my own monad with <https://paste.tomsmeding.com/KAANvlR5>. When I try `C1 (1 :: Int) >>= (\x -> C1 $ x + 1)` I get that the result of the evaluation is `C1 (1 :: Int) >>= (\x -> C1 $ x + 1) :: MyMonad Int`. |
2025-01-30 19:49:41 +0100 | SlackCoder | (~SlackCode@remote.nationalgallery.org.ky) (Client Quit) |
2025-01-30 19:48:41 +0100 | euouae | (~euouae@user/euouae) euouae |
2025-01-30 19:48:00 +0100 | SlackCoder | (~SlackCode@remote.nationalgallery.org.ky) SlackCoder |
2025-01-30 19:44:59 +0100 | jespada | (~jespada@2800:a4:220c:6700:19eb:694f:b602:3bcb) jespada |