Newest at the top
2024-05-09 20:53:35 +0200 | <EvanR> | fmapping both wouldn't make sense |
2024-05-09 20:53:25 +0200 | <lambdabot> | ("foo",False) |
2024-05-09 20:53:24 +0200 | <EvanR> | > fmap even ("foo", 99) |
2024-05-09 20:53:17 +0200 | <EvanR> | dammit |
2024-05-09 20:53:11 +0200 | <lambdabot> | from the context: Num a |
2024-05-09 20:53:11 +0200 | <lambdabot> | • Could not deduce (Integral [Char]) arising from a use of ‘even’ |
2024-05-09 20:53:11 +0200 | <lambdabot> | error: |
2024-05-09 20:53:09 +0200 | <EvanR> | > fmap even (99, "foo") |
2024-05-09 20:52:24 +0200 | <justsomeguy> | Alright, I was misreading the result of (fmap (+10) (Left 1)), and that was confusing because I thought I could fmap both constructors. But it wasn't. |
2024-05-09 20:52:24 +0200 | ocra8 | (ocra8@user/ocra8) |
2024-05-09 20:51:56 +0200 | <kaol> | Putting them inside a 2-tuple won't have anything to do with Bifunctor either. |
2024-05-09 20:51:47 +0200 | <ski> | no `Bifunctor' there ^ |
2024-05-09 20:51:40 +0200 | <lambdabot> | Functor f => (a -> b) -> f a -> f b |
2024-05-09 20:51:39 +0200 | <ski> | @type fmap |
2024-05-09 20:51:18 +0200 | <ski> | justsomeguy : `fmap' means `Functor', not `Bifunctor' |
2024-05-09 20:50:59 +0200 | <ncf> | you're not using the Bifunctor instance there, just Functor (Either a) |
2024-05-09 20:50:58 +0200 | <ski> | (i didn't fix your code, i just added the correct type signature, for clarity) |
2024-05-09 20:50:36 +0200 | titiband` | (~titiband`@user/titibandit) |
2024-05-09 20:50:21 +0200 | <ski> | justsomeguy : <https://termbin.com/nxth> |
2024-05-09 20:50:14 +0200 | <justsomeguy> | OK. Why does (fmap (+10) (Left 1), fmap (+10) (Right 3)) work? Because it has an instance of Bifunctor? |
2024-05-09 20:49:57 +0200 | titiband` | (~titiband`@user/titibandit) (Remote host closed the connection) |
2024-05-09 20:49:29 +0200 | euleritian | (~euleritia@dynamic-176-002-128-182.176.2.pool.telefonica.de) |
2024-05-09 20:48:55 +0200 | <ncf> | you obviously cannot apply a function a -> b to a field that doesn't have type a |
2024-05-09 20:48:34 +0200 | <ncf> | there's only one possible instance |
2024-05-09 20:47:39 +0200 | <justsomeguy> | Oh... the instance in base for Functor (Either a) only works on one constructor, too. |
2024-05-09 20:47:02 +0200 | julie_pilgrim | (~julie_pil@user/julie-pilgrim/x-1240752) (Remote host closed the connection) |
2024-05-09 20:46:06 +0200 | titiband` | (~titiband`@user/titibandit) |
2024-05-09 20:44:49 +0200 | euleritian | (~euleritia@dynamic-176-002-128-182.176.2.pool.telefonica.de) (Ping timeout: 272 seconds) |
2024-05-09 20:44:35 +0200 | <EvanR> | imagine if you had a type system for every goal |
2024-05-09 20:44:16 +0200 | <EvanR> | justsomeguy, what you call "not working" I call working great. I.e. the type system stopped you from doing the objectively wrong thing |
2024-05-09 20:41:55 +0200 | <ski> | (if you enable `InstanceSigs' as suggested above, you can write that type signature for `fmap' directly into that `instance' declaration for `Functor') |
2024-05-09 20:41:01 +0200 | <ski> | long story short, you're not correctly implementing the expected type signature |
2024-05-09 20:40:42 +0200 | <ski> | (but then your actual code for `fmap' doesn't currently implement that correctly, hence the type error) |
2024-05-09 20:40:34 +0200 | <justsomeguy> | I'm not gonna lie, this is going over my head |
2024-05-09 20:39:58 +0200 | <ski> | in general, `fmap :: (a -> c) -> (f a -> f c)'. you have `Functor (BahEither b)' meaning that `f = `BahEither b', so you get `fmap :: (a -> c) -> (BahEither b a -> BahEither b c)' |
2024-05-09 20:38:11 +0200 | <dolio> | It has to do that because the type of the Left changes. |
2024-05-09 20:38:06 +0200 | <ski> | you have `BahEither b a', where `PLeft' takes an `a', and `PRight' takes a `b' .. so the opposite way around |
2024-05-09 20:38:02 +0200 | <dolio> | Do you mean it has cases for both Left and Right? |
2024-05-09 20:37:57 +0200 | <lambdabot> | Right 2 |
2024-05-09 20:37:56 +0200 | <int-e> | > fmap succ (Right 1) |
2024-05-09 20:37:47 +0200 | <lambdabot> | Left 1 |
2024-05-09 20:37:46 +0200 | <int-e> | > fmap succ (Left 1) |
2024-05-09 20:37:30 +0200 | <ski> | because `Either a b', where `Left' takes an `a' and `Right' takes a `b' |
2024-05-09 20:37:02 +0200 | <justsomeguy> | I notice that fmap works on Left and Right on the Either type. |
2024-05-09 20:36:52 +0200 | <ncf> | are you looking for Bifunctor |
2024-05-09 20:36:35 +0200 | <justsomeguy> | Is it possible to write fmap for both data constructors (PLeft a and PRight b)? |
2024-05-09 20:34:41 +0200 | <ski> | {-# LANGUAGE InstanceSigs #-} |
2024-05-09 20:32:18 +0200 | <int-e> | But you've implemented fmap :: (b -> c) -> BahEither b a -> BahEither c a |
2024-05-09 20:31:33 +0200 | <int-e> | the type you'd need here is fmap :: (a -> c) -> BahEither b a -> BahEither b c |
2024-05-09 20:30:36 +0200 | <ncf> | you're mapping the wrong component |