Logs: freenode/#haskell
| 2020-11-20 09:01:50 | <lambdabot> | Expected type: (a, a1) -> (a, a1) -> Ordering |
| 2020-11-20 09:01:58 | <dminuoso> | Martinsos: In general, if you want something extensible covering the expression problem, then tagless final or datatypes a la carte are common approaches in Haskell |
| 2020-11-20 09:02:15 | <merijn> | > sortBy (comparing snd <> comparing fst) [(1,2), (2,2), (1,1), (2,1)] |
| 2020-11-20 09:02:17 | <lambdabot> | [(1,1),(2,1),(1,2),(2,2)] |
| 2020-11-20 09:02:22 | → | DirefulSalt joins (DirefulSal@gateway/vpn/privateinternetaccess/direfulsalt) |
| 2020-11-20 09:02:28 | <koz_> | Those are _very_ nuclear hammers. |
| 2020-11-20 09:03:19 | <Martinsos> | dminuoso: hmmm thanks, I will have to investigate those! I think I was reading datatypes a la carte but concluded I don't need that complexity right now. I guess what I am wondering, when somebody asks "should I do this with data types or type classes", and information is relatively simple (like that example with shapes), what is the correct answer? Probably: do it with data types since that is the simplest / least code, and let's see |
| 2020-11-20 09:03:19 | <Martinsos> | how it evolves? |
| 2020-11-20 09:03:41 | <merijn> | kritzefitz: Note how the monoid for functions lets you monoidally combine functions, regardless of number of arguments, which is especially neat with Ordering allowing for arbitrarily complex sorting criteria |
| 2020-11-20 09:04:24 | <dminuoso> | Martinsos: So Im in a similar spot, I've solved the expression problem in this particular project with "have a code generator" and if people want to extend my data type, they have to make a PR and Ill rerun the code generator. :p |
| 2020-11-20 09:04:24 | → | Chi1thangoo joins (~Chi1thang@87.112.60.168) |
| 2020-11-20 09:04:51 | <dminuoso> | For this particular project. |
| 2020-11-20 09:04:52 | <kritzefitz> | merijn, indeed, that is a very nice Monoid. I wasn't aware it existed. |
| 2020-11-20 09:05:02 | <dminuoso> | There is no correct answer really |
| 2020-11-20 09:05:13 | <dminuoso> | But roughly I'd avoid typeclasses if you are not sure they will help you |
| 2020-11-20 09:05:32 | <dminuoso> | Often, the expression problem is not as bad as it seems |
| 2020-11-20 09:06:00 | → | Feuermagier joins (~Feuermagi@213.178.26.41) |
| 2020-11-20 09:06:22 | → | comerijn joins (~merijn@83-160-49-249.ip.xs4all.nl) |
| 2020-11-20 09:07:13 | × | Boomerang quits (~Boomerang@xd520f68c.cust.hiper.dk) (Remote host closed the connection) |
| 2020-11-20 09:07:33 | → | Boomerang joins (~Boomerang@xd520f68c.cust.hiper.dk) |
| 2020-11-20 09:07:57 | <Martinsos> | dminuoso: thanks! I think that sounds like a good rule, avoid typeclass if not needed, and in most cases the problem will not actually be problematic. Cool, thank you |
| 2020-11-20 09:08:12 | <koz_> | Yeah - the reality is that All The Extensibility All The Time isn't helpful, and in some cases, it'll even slow you down. |
| 2020-11-20 09:08:17 | → | ph88 joins (~ph88@2a02:8109:9e00:7e5c:f073:c081:c2ef:433b) |
| 2020-11-20 09:08:19 | <koz_> | Over-generalizing early can be pretty bad. |
| 2020-11-20 09:08:32 | <hololeap> | is Show1 derivable in GHC 8.8.4? |
| 2020-11-20 09:08:38 | × | merijn quits (~merijn@83-160-49-249.ip.xs4all.nl) (Ping timeout: 256 seconds) |
| 2020-11-20 09:08:52 | <koz_> | hololeap: I don't think *1 is derivable for any * in any version? |
| 2020-11-20 09:08:56 | <[exa]> | kritzefitz: btw, my favorite example with function semigroup is `rotList = drop <> take` (even with multiple parameters) |
| 2020-11-20 09:09:09 | → | acidjnk_new2 joins (~acidjnk@p200300d0c719ff35956387e811e01df5.dip0.t-ipconnect.de) |
| 2020-11-20 09:09:15 | <dminuoso> | [exa]: That example was pretty cool :) |
| 2020-11-20 09:09:34 | <koz_> | kritzefitz: For a recent Real Job For Real Money example from me - I used Monoid to implement 'find exactly one' with error handling. |
| 2020-11-20 09:09:42 | <hololeap> | koz_, ok i ask because it is listed here: https://github.com/haskell-compat/deriving-compat |
| 2020-11-20 09:09:47 | comerijn | is now known as merijn |
| 2020-11-20 09:09:52 | × | BarleyMo quits (2a02d45a@42-2-212-090.static.netvigator.com) (Remote host closed the connection) |
| 2020-11-20 09:09:57 | <hololeap> | "Provides Template Haskell functions that mimic deriving extensions that were introduced or modified in recent versions of GHC." |
| 2020-11-20 09:10:08 | → | supercoven joins (~Supercove@dsl-hkibng31-54fae2-36.dhcp.inet.fi) |
| 2020-11-20 09:10:13 | <koz_> | The Monoid in question is something like 'data FindExactlyOne a = NoneFound | OneFound a | TooManyFound'. |
| 2020-11-20 09:10:20 | × | Kaeipi quits (~Kaiepi@nwcsnbsc03w-47-55-225-82.dhcp-dynamic.fibreop.nb.bellaliant.net) (Remote host closed the connection) |
| 2020-11-20 09:10:26 | → | Merfont joins (~Kaiepi@nwcsnbsc03w-47-55-225-82.dhcp-dynamic.fibreop.nb.bellaliant.net) |
| 2020-11-20 09:10:38 | <koz_> | (the instances of Semigroup and Monoid are left as an exercise to the reader) |
| 2020-11-20 09:11:03 | × | jpds quits (~jpds@gateway/tor-sasl/jpds) (Ping timeout: 240 seconds) |
| 2020-11-20 09:12:01 | × | DirefulSalt quits (DirefulSal@gateway/vpn/privateinternetaccess/direfulsalt) (Remote host closed the connection) |
| 2020-11-20 09:12:17 | <merijn> | the more you use Semigroup/Monoid/foldMap, the more use you see for them :) |
| 2020-11-20 09:12:25 | → | cfricke joins (~cfricke@unaffiliated/cfricke) |
| 2020-11-20 09:12:29 | → | DirefulSalt joins (DirefulSal@gateway/vpn/privateinternetaccess/direfulsalt) |
| 2020-11-20 09:12:40 | <koz_> | Realistically, it's {M,m}onoids all the way down? |
| 2020-11-20 09:12:40 | <merijn> | koz_: Did you see the glorious addition of foldMap' ? (*finally*) |
| 2020-11-20 09:12:46 | <koz_> | merijn: Where? |
| 2020-11-20 09:12:46 | <kritzefitz> | koz_, I think I remember having a similar problem. Now I realize that, semantically I also implemented a Monoid but didn't really use the typeclass for that. So I guess those are the kinds of opportunities I should look out for. |
| 2020-11-20 09:12:52 | <merijn> | koz_: In base :) |
| 2020-11-20 09:12:57 | <koz_> | kritzefitz: It gets easier with practice. |
| 2020-11-20 09:13:05 | <koz_> | merijn: No I did not. Indeed, *finally*. |
| 2020-11-20 09:13:06 | <mikevdg> | opqdonut: I've just read through some parts of your MOOC. If I earn 5 ECTS, what can I use them for? |
| 2020-11-20 09:13:07 | <merijn> | koz_: GHC 8.8 or 8.10 added it? |
| 2020-11-20 09:13:28 | <koz_> | hololeap: I wasn't aware *1 could be derived automagically at all. |
| 2020-11-20 09:14:16 | <hololeap> | well, deriving Show1 with that GHC version not working for me |
| 2020-11-20 09:14:19 | <mikevdg> | opqdonut: and is there a fancy certificate at the end? :-) |
| 2020-11-20 09:14:39 | <koz_> | hololeap: I don't even know how it would work with any version. I'm pretty sure that's not stock derivable at least. |
| 2020-11-20 09:14:40 | → | jess joins (jess@freenode/staff/jess) |
| 2020-11-20 09:17:01 | → | benjamingr__ joins (uid23465@gateway/web/irccloud.com/x-fmpqsizgoykkkpyq) |
| 2020-11-20 09:17:53 | <idnar> | :t foldMap' |
| 2020-11-20 09:17:54 | <lambdabot> | (Foldable t, Monoid m) => (a -> m) -> t a -> m |
| 2020-11-20 09:18:03 | <idnar> | :t foldMap |
| 2020-11-20 09:18:04 | <lambdabot> | (Foldable t, Monoid m) => (a -> m) -> t a -> m |
| 2020-11-20 09:18:12 | <idnar> | wut |
| 2020-11-20 09:18:17 | <koz_> | idnar: The type sig won't tell you the difference. |
| 2020-11-20 09:18:23 | <merijn> | idnar: foldMap' is strict |
| 2020-11-20 09:18:59 | <idnar> | ohhh right, I was thinking foldMap_ |
| 2020-11-20 09:19:10 | <dminuoso> | Also, foldMap' by default associates differently internaly |
| 2020-11-20 09:19:14 | <dminuoso> | By default |
| 2020-11-20 09:19:25 | × | cole-h quits (~cole-h@c-73-48-197-220.hsd1.ca.comcast.net) (Ping timeout: 264 seconds) |
| 2020-11-20 09:19:27 | × | falafel_ quits (~falafel@2601:547:1303:b30:7811:313f:d0f3:f9f4) (Ping timeout: 260 seconds) |
| 2020-11-20 09:19:30 | <merijn> | koz_: Now I just need a strict tuple to go with that :p |
| 2020-11-20 09:20:26 | <kritzefitz> | Strict tuples would be so great. |
| 2020-11-20 09:20:42 | <koz_> | merijn: So like, 'data StrictTuple a b = StrictTuple !a !b'? |
| 2020-11-20 09:21:27 | → | cloudster joins (~cloudster@124.123.105.47) |
| 2020-11-20 09:22:09 | <kritzefitz> | I guess you could use it to break the internals of lots of types, but it seems like it could be nice, if you could provide strictness as part of type parameters. |
| 2020-11-20 09:23:01 | <kritzefitz> | e.g. `[!Int]` would be a list, where the elements would be evaluated with the spine. |
| 2020-11-20 09:24:33 | × | cloudster quits (~cloudster@124.123.105.47) (Remote host closed the connection) |
| 2020-11-20 09:24:42 | × | Merfont quits (~Kaiepi@nwcsnbsc03w-47-55-225-82.dhcp-dynamic.fibreop.nb.bellaliant.net) (Remote host closed the connection) |
| 2020-11-20 09:25:01 | → | Merfont joins (~Kaiepi@nwcsnbsc03w-47-55-225-82.dhcp-dynamic.fibreop.nb.bellaliant.net) |
| 2020-11-20 09:25:20 | × | christo quits (~chris@81.96.113.213) (Remote host closed the connection) |
| 2020-11-20 09:26:47 | → | cloudster joins (~cloudster@124.123.105.47) |
| 2020-11-20 09:27:24 | × | pavonia quits (~user@unaffiliated/siracusa) (Quit: Bye!) |
| 2020-11-20 09:27:26 | × | mikevdg quits (73bd5248@115-189-82-72.mobile.spark.co.nz) (Remote host closed the connection) |
| 2020-11-20 09:28:03 | × | Chi1thangoo quits (~Chi1thang@87.112.60.168) (Ping timeout: 256 seconds) |
| 2020-11-20 09:29:04 | → | thc202 joins (~thc202@unaffiliated/thc202) |
| 2020-11-20 09:29:58 | <dminuoso> | kritzefitz: Indeed it would be cool, we could then write strictness polymorphic code akin to levity polymorphism. |
| 2020-11-20 09:30:19 | → | christo joins (~chris@81.96.113.213) |
| 2020-11-20 09:30:25 | <merijn> | dminuoso: I've already floated that idea a bunch of times :p |
| 2020-11-20 09:30:34 | × | cloudster quits (~cloudster@124.123.105.47) (Remote host closed the connection) |
| 2020-11-20 09:30:48 | <dminuoso> | Any plans after your M.Sc? :> |
| 2020-11-20 09:30:55 | <dminuoso> | Seems like the perfect PhD thesis. |
| 2020-11-20 09:30:57 | × | star_cloud quits (~star_clou@ec2-34-220-44-120.us-west-2.compute.amazonaws.com) (Remote host closed the connection) |
| 2020-11-20 09:31:08 | <merijn> | dminuoso: My M.Sc. was finished literal *years* ago |
| 2020-11-20 09:31:11 | <dminuoso> | Oh |
| 2020-11-20 09:31:14 | <dminuoso> | Hold on |
| 2020-11-20 09:31:33 | <merijn> | It's my PhD thesis I'm procrastinating on :p |
| 2020-11-20 09:32:03 | <dminuoso> | Well, what about a second PhD then! |
| 2020-11-20 09:32:08 | <merijn> | hah |
All times are in UTC.