Logs: freenode/#haskell
| 2021-03-18 00:10:03 | <lambdabot> | • Conflicting definitions for ‘x’ |
| 2021-03-18 00:10:03 | <lambdabot> | Bound at: <interactive>:1:14 |
| 2021-03-18 00:10:28 | → | s00pcan joins (~chris@075-133-056-178.res.spectrum.com) |
| 2021-03-18 00:10:39 | <Axman6> | one feature I wish we had from Erlang |
| 2021-03-18 00:10:58 | × | royal_screwup21 quits (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9) (Ping timeout: 256 seconds) |
| 2021-03-18 00:11:33 | <monochrom> | In the case of this exercise, the error (as opposed to the feature) actually saves a lot of confusion. |
| 2021-03-18 00:11:56 | <Axman6> | > let f (Just x) = \(Just x) -> x in f (Just 1) (Just 2) |
| 2021-03-18 00:11:58 | <lambdabot> | 2 |
| 2021-03-18 00:12:22 | <Axman6> | yeah (sorry, should do confusing things in PM instead of here) |
| 2021-03-18 00:12:28 | → | cheater1 joins (~user@unaffiliated/cheater) |
| 2021-03-18 00:12:32 | <bobweb> | OK, monoid = binary associative without identity; but we are not accessing the a in Identity a... oh wait, I am accessing a, but I thought I shouldn't be... |
| 2021-03-18 00:12:49 | <Axman6> | monoid has an identity, semigroup doesn't |
| 2021-03-18 00:13:23 | <bobweb> | yeah, sorry, backwards : has identity. |
| 2021-03-18 00:13:27 | <monochrom> | Why are you not doing "instance Monoid a => Monoid (Identity a)"? |
| 2021-03-18 00:13:30 | → | aplainzetakind joins (~johndoe@captainludd.powered.by.lunarbnc.net) |
| 2021-03-18 00:13:58 | → | cr3 joins (~cr3@192-222-143-195.qc.cable.ebox.net) |
| 2021-03-18 00:14:01 | <bobweb> | monochrom: cause the compiler told me too... |
| 2021-03-18 00:14:26 | <bobweb> | but yeah, maybe i should do monoid => |
| 2021-03-18 00:14:39 | × | cheater quits (~user@unaffiliated/cheater) (Ping timeout: 244 seconds) |
| 2021-03-18 00:14:43 | cheater1 | is now known as cheater |
| 2021-03-18 00:16:08 | <Axman6> | think about it a bit first - Identity wraps a single value of a given type. we know (because you've been told) that you can make an instance of Monoid for Identity. so first problem is mempoty, how do we make something of type Identity a? Well we use Identity, and some value of type a. how do we magic up a value of type a? |
| 2021-03-18 00:16:08 | × | emmanuel_erc quits (~user@2603-7000-9600-01c9-0000-0000-0000-0874.res6.spectrum.com) (Read error: Connection reset by peer) |
| 2021-03-18 00:16:15 | × | notzmv quits (~zmv@unaffiliated/zmv) (Ping timeout: 265 seconds) |
| 2021-03-18 00:16:23 | <Axman6> | mempty* |
| 2021-03-18 00:16:29 | → | emmanuel_erc joins (~user@2603-7000-9600-01c9-0000-0000-0000-0874.res6.spectrum.com) |
| 2021-03-18 00:16:58 | <bobweb> | OK, works now! Thank you all! : https://paste.tomsmeding.com/78ZjwXlA |
| 2021-03-18 00:18:35 | <Axman6> | can you explain how it works? |
| 2021-03-18 00:19:22 | × | coot quits (~coot@37.30.58.223.nat.umts.dynamic.t-mobile.pl) (Quit: coot) |
| 2021-03-18 00:19:59 | → | howdoi joins (uid224@gateway/web/irccloud.com/x-lmfzccdglbgutamn) |
| 2021-03-18 00:22:37 | <bobweb> | Not exactly. I get that the identity for type (Identity a) will be mempty defined as (Identity mempty). OK. But it's not clear to me why the binary function (<>) on (Identity x) (Identity y) should be (Identity (x <> y))... It seems like we are adding structure when identity is just supposed to kick back whatever gets put in.?? |
| 2021-03-18 00:22:37 | × | emmanuel_erc quits (~user@2603-7000-9600-01c9-0000-0000-0000-0874.res6.spectrum.com) (Read error: Connection reset by peer) |
| 2021-03-18 00:23:05 | → | emmanuel_erc joins (~user@2603-7000-9600-01c9-0000-0000-0000-0874.res6.spectrum.com) |
| 2021-03-18 00:24:05 | <bobweb> | I know I am missing some subtlety about how the compiler sees x <> y, but I can't quite grasp it... |
| 2021-03-18 00:24:41 | <Axman6> | I think you're attributing too much meaning to Identity |
| 2021-03-18 00:25:45 | <Axman6> | it is literally just a wrapper of other types, it is the trivial Monad, and in general all instances of classes will just use whatever isntance the wrapped type has. it's got nothing to do with identity functions really |
| 2021-03-18 00:25:57 | <monochrom> | That's possible. "mempty is the identity element of the monoid" has a name clash with this "newtype Identity a" type. |
| 2021-03-18 00:26:11 | <monochrom> | name clash. Nothing more. No relation. |
| 2021-03-18 00:26:19 | <Axman6> | Eq for Identity will look like: instance Eq a => Eq (Identity a) where (==) (Identity x) (Identity y) == x == y |
| 2021-03-18 00:26:49 | <Axman6> | uh, (==) (Identity x) (Identity y) = x == y |
| 2021-03-18 00:28:26 | → | CoconutCrab joins (~Cua@unaffiliated/coconutcrab) |
| 2021-03-18 00:30:45 | → | jamm_ joins (~jamm@unaffiliated/jamm) |
| 2021-03-18 00:32:38 | <bobweb> | Yes. Name clash. I think I'm beginning to see... it's not that an identity is resulting from (Identity x) <> (Identity y), it is simply that the data constructor name is leading me to think so. OK, I think I'll be OK now, after I meditate on this a bit more. Thank you all! |
| 2021-03-18 00:35:19 | × | cole-h quits (~cole-h@c-73-48-197-220.hsd1.ca.comcast.net) (Ping timeout: 244 seconds) |
| 2021-03-18 00:35:26 | × | jamm_ quits (~jamm@unaffiliated/jamm) (Ping timeout: 264 seconds) |
| 2021-03-18 00:35:55 | × | bobweb quits (6bb893db@cpe-107-184-147-219.socal.res.rr.com) (Quit: Connection closed) |
| 2021-03-18 00:37:48 | <monochrom> | The road to hell is paved with well-intended meaningful names. |
| 2021-03-18 00:38:58 | <Axman6> | newtype Trivial a = Trivial a? |
| 2021-03-18 00:39:18 | <Axman6> | just to make you feel even more dumb when you find something isn't trivial |
| 2021-03-18 00:39:52 | × | emmanuel_erc quits (~user@2603-7000-9600-01c9-0000-0000-0000-0874.res6.spectrum.com) (Read error: Connection reset by peer) |
| 2021-03-18 00:40:07 | <monochrom> | I'm thinking along the line of "newtype VeryPhilosophicallyProfoundWrapper a = VPPW a" to drive home the irony. |
| 2021-03-18 00:40:10 | → | emmanuel_erc joins (~user@2603-7000-9600-01c9-0000-0000-0000-0874.res6.spectrum.com) |
| 2021-03-18 00:40:39 | <Axman6> | "Woah, everything is just waves man, it's like science or something" |
| 2021-03-18 00:40:57 | → | Deide1 joins (~Deide@217.155.19.23) |
| 2021-03-18 00:41:02 | × | Deide quits (~Deide@217.155.19.23) (Quit: Seeee yaaaa) |
| 2021-03-18 00:41:02 | <monochrom> | and to drive general disgust and distrust in meaningful names. |
| 2021-03-18 00:41:30 | <Axman6> | newtype Z a = Z a |
| 2021-03-18 00:42:19 | <Axman6> | pi = join @Z; pi :: Z (Z a) -> Z a -- pizza -> 'za |
| 2021-03-18 00:43:35 | <monochrom> | tauzza = 2*pizza > pizza |
| 2021-03-18 00:43:52 | <sshine_> | "trivial" and "just" are smart-ass words. |
| 2021-03-18 00:44:12 | <spidr> | > let pi = join @Z; pi :: Z (Z a) -> Z a -- pizza -> 'za |
| 2021-03-18 00:44:14 | <lambdabot> | error: |
| 2021-03-18 00:44:15 | <lambdabot> | Pattern syntax in expression context: join@Z |
| 2021-03-18 00:44:15 | <lambdabot> | Did you mean to enable TypeApplications? |
| 2021-03-18 00:44:37 | <monochrom> | by extension "nothing" is also a smart-ass word. |
| 2021-03-18 00:44:50 | <monochrom> | Therefore, "data Maybe a = Nothing | Just a" is a smart-ass type. |
| 2021-03-18 00:45:18 | <spidr> | I don't understand just |
| 2021-03-18 00:46:12 | × | dsrt^ quits (~hph@ip98-184-89-2.mc.at.cox.net) () |
| 2021-03-18 00:46:16 | <Axman6> | Maybe a is either nothing or just an a |
| 2021-03-18 00:46:46 | <spidr> | but what does just do under the hood, why is it not Mayba a = Nothing | a |
| 2021-03-18 00:46:49 | <monochrom> | Have you also heard of the unJust function? :) |
| 2021-03-18 00:47:01 | <spidr> | n-no i'm still reading the haskell book |
| 2021-03-18 00:47:01 | <monochrom> | Syntax error is why. |
| 2021-03-18 00:47:13 | <monochrom> | You always need data constructors. |
| 2021-03-18 00:47:13 | <Axman6> | because that's not valid haskell |
| 2021-03-18 00:47:17 | <spidr> | ah |
| 2021-03-18 00:47:28 | <Axman6> | this isn't typescript |
| 2021-03-18 00:47:54 | <monochrom> | Think of data constructors as reminding the computer both which type you're making and which case you're talking about. |
| 2021-03-18 00:47:55 | <sshine_> | spidr, if you don't have a data constructor to differentiate a 'Maybe a' value from an 'a' value, then they are aliases. but they can't be aliases if one has a value 'Nothing' in addition. |
| 2021-03-18 00:48:07 | <monochrom> | Even when it's trivial to me. |
| 2021-03-18 00:48:12 | <monochrom> | err, s/me/you/ |
| 2021-03-18 00:48:18 | × | Deide1 quits (~Deide@217.155.19.23) (Quit: Seeee yaaaa) |
| 2021-03-18 00:48:28 | → | Deide joins (~Deide@217.155.19.23) |
| 2021-03-18 00:48:35 | <spidr> | maybe I shouldn't dig so low |
| 2021-03-18 00:48:49 | <spidr> | I was trying to find the source of just |
| 2021-03-18 00:49:03 | <monochrom> | This is why type inference works. Your data constructor tells the computer about types. You are not saving any typing, afterall. |
| 2021-03-18 00:49:18 | × | hololeap quits (~hololeap@unaffiliated/hololeap) (Read error: Connection reset by peer) |
| 2021-03-18 00:49:22 | <sshine_> | spidr, https://hackage.haskell.org/package/base-4.14.1.0/docs/src/GHC.Maybe.html#Maybe |
| 2021-03-18 00:49:30 | <Axman6> | something of type MAybe (Maybe ()) should have three valid patterns, Nothing, Just Nothing and Just (Just ()). if we allowed Nothing | a, which of those patterns does Nothing represent? Nothng or Just Nothing? |
| 2021-03-18 00:50:05 | <monochrom> | "data Maybe a = Nothing | Just a" is already the source of Just. And Nothing. And Maybe. |
| 2021-03-18 00:50:06 | → | ep1ctetus_ joins (~epictetus@ip72-194-215-136.sb.sd.cox.net) |
| 2021-03-18 00:50:15 | <spidr> | thanks for the link sshine_ |
| 2021-03-18 00:50:29 | <Axman6> | @src Maybe |
| 2021-03-18 00:50:30 | <lambdabot> | data Maybe a = Nothing | Just a |
| 2021-03-18 00:50:30 | <sshine_> | spidr, so that data declaration *is* the source of Just. |
| 2021-03-18 00:50:33 | <spidr> | this has the source of maybe but not just, although the comment explains it |
| 2021-03-18 00:50:44 | <spidr> | ah |
| 2021-03-18 00:51:02 | <sshine_> | spidr, Just is a value/pattern constructor for the type Maybe a. |
| 2021-03-18 00:51:24 | <Axman6> | that declaration defined Maybe as a type with two constructors, one callen Nothing, one called Just. |
| 2021-03-18 00:51:25 | × | Tario quits (~Tario@201.192.165.173) (Read error: Connection reset by peer) |
| 2021-03-18 00:51:34 | <spidr> | I see |
All times are in UTC.