Logs: freenode/#haskell
| 2020-11-20 08:46:48 | <guest1120> | lex, happy, parsec, they're same? |
| 2020-11-20 08:47:09 | <tdammers> | mif suggests Monoid m => Bool -> m -> m -> m, or maybe even Monoid m => Bool -> m -> m -> m -> m |
| 2020-11-20 08:47:16 | <merijn> | tdammers: Yeah, but that leads to confusion with monad's and whenM, etc. |
| 2020-11-20 08:47:37 | <tdammers> | it's very similar to when from Control.Monad though, isn't it |
| 2020-11-20 08:48:04 | <merijn> | yeah |
| 2020-11-20 08:48:12 | → | Yumasi joins (~guillaume@2a01cb09b06b29eabd8cf63c98e88a0f.ipv6.abo.wanadoo.fr) |
| 2020-11-20 08:48:15 | <tdammers> | in fact, if Monad could have the Monoid instance it deserves, it would be the exact same thing |
| 2020-11-20 08:48:46 | → | wroathe joins (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) |
| 2020-11-20 08:49:15 | → | hyiltiz joins (~quassel@82.118.227.47) |
| 2020-11-20 08:49:15 | × | hyiltiz quits (~quassel@82.118.227.47) (Changing host) |
| 2020-11-20 08:49:15 | → | hyiltiz joins (~quassel@unaffiliated/hyiltiz) |
| 2020-11-20 08:49:32 | <dminuoso> | guest1120: Presumably by lex you meant alex? |
| 2020-11-20 08:49:46 | <dminuoso> | guest1120: At any rate, they are all parsing/lexing libraries but with different ergonomics and properties. |
| 2020-11-20 08:50:03 | <guest1120> | dminuoso: which one is easier? |
| 2020-11-20 08:50:22 | <dminuoso> | "easier" is hard to answer in general |
| 2020-11-20 08:50:23 | <merijn> | kritzefitz: Some example uses: https://github.com/haskell/cabal/blob/master/Cabal/src/Distribution/Simple/Program/GHC.hs#L203-L209 also note that from/to in the surrounding code https://github.com/haskell/cabal/blob/master/Cabal/src/Distribution/Simple/Program/GHC.hs#L174-L199 are just slightly specialised versions of that function |
| 2020-11-20 08:50:48 | <guest1120> | I'm learing parsec by write yourself a scheme with 48 hours |
| 2020-11-20 08:50:52 | <merijn> | kritzefitz: It's great for selectively including bits and pieces in complex compound structures |
| 2020-11-20 08:50:58 | <guest1120> | but some codes are old |
| 2020-11-20 08:50:59 | <dminuoso> | But `megaparsec` is a safe default for a parsing library |
| 2020-11-20 08:51:22 | × | plutoniix quits (~q@node-ufe.pool-125-24.dynamic.totinternet.net) (Quit: Leaving) |
| 2020-11-20 08:51:26 | <dminuoso> | That is, if you want a tl;dr for "which parsing library should I use", you generally cant go wrong with megaparsec. |
| 2020-11-20 08:51:44 | <tdammers> | also megaparsec > parsec in 99.9% of cases these days |
| 2020-11-20 08:52:08 | <guest1120> | but parsec comes with ghc? |
| 2020-11-20 08:52:20 | <tdammers> | does it? I don't think it does |
| 2020-11-20 08:52:28 | <koz_> | tdammers: Isn't parsec a boot library? |
| 2020-11-20 08:52:41 | <tdammers> | I thought it wasn't, but maybe it is by now |
| 2020-11-20 08:52:53 | <guest1120> | Text.Parsec? |
| 2020-11-20 08:53:03 | <kritzefitz> | merijn, It does seem useful. But I just realised thta I rarely use a lot of Monoids and now I'm wondering if I'm missing out. |
| 2020-11-20 08:53:18 | <koz_> | kritzefitz: You definitely are. |
| 2020-11-20 08:53:28 | × | wroathe quits (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) (Ping timeout: 260 seconds) |
| 2020-11-20 08:53:35 | <koz_> | You can get a remarkable range of behaviour out of foldMap by varying up your Monoids. |
| 2020-11-20 08:54:08 | <dminuoso> | guest1120: The boot libraries should not be a relevant factor for what you should use. |
| 2020-11-20 08:54:24 | <merijn> | kritzefitz: You are :p |
| 2020-11-20 08:54:29 | <dminuoso> | The fact that GHC comes with them is not for your convenience. |
| 2020-11-20 08:54:45 | <merijn> | kritzefitz: Note that the entire surrounding 150-200 lines of code I just linked is basically all composing a bunch of monoids together :p |
| 2020-11-20 08:55:07 | <mikevdg> | Haskell: A new way to break your brain every day. `mempty :: Sum Int` --> Sum {getSum = 0} |
| 2020-11-20 08:55:45 | × | hnOsmium0001 quits (uid453710@gateway/web/irccloud.com/x-itluyvgbrrzsqlpm) (Quit: Connection closed for inactivity) |
| 2020-11-20 08:56:10 | → | cloudster joins (~cloudster@124.123.105.47) |
| 2020-11-20 08:56:15 | <merijn> | mikevdg: Don't forget Dual |
| 2020-11-20 08:56:18 | <guest1120> | ok |
| 2020-11-20 08:56:28 | <mikevdg> | merijn: Dual? |
| 2020-11-20 08:56:28 | <dminuoso> | Mmm, why exactly does GHC ship with these boot packages at all? Is ghc linked dynamically? |
| 2020-11-20 08:56:40 | <mikevdg> | :t Dual |
| 2020-11-20 08:56:41 | <lambdabot> | a -> Dual a |
| 2020-11-20 08:56:47 | <koz_> | dminuoso: I think they're needed to build GHC itself? |
| 2020-11-20 08:57:02 | <mikevdg> | Is there a thing in, e.g. ghci, to also get a bit of documentation on a type? |
| 2020-11-20 08:57:04 | <koz_> | There's also Down. |
| 2020-11-20 08:57:09 | <merijn> | mikevdg: "newtype Dual a = Dual a" where "mempty = Dual mempty" and "mappend (Dual x) (Dual y) = Dual (mappend y x)" |
| 2020-11-20 08:57:09 | <koz_> | @hoogle Dual |
| 2020-11-20 08:57:10 | <lambdabot> | Data.Monoid newtype Dual a |
| 2020-11-20 08:57:10 | <lambdabot> | Data.Monoid Dual :: a -> Dual a |
| 2020-11-20 08:57:10 | <lambdabot> | Data.Semigroup newtype Dual a |
| 2020-11-20 08:57:10 | <kritzefitz> | The first thing that comes to minds, when I think about monoids, is that WriterT uses Monoids for the written things. So if I want to collect elements into a list it degrades (:) to (++) and that bother me. But I guess I'm just thinking about this the wrong way. |
| 2020-11-20 08:57:13 | <mikevdg> | Or do I have to go to Hoogle? |
| 2020-11-20 08:57:28 | <merijn> | > [1,2,3] <> [4,5,6] |
| 2020-11-20 08:57:30 | <lambdabot> | [1,2,3,4,5,6] |
| 2020-11-20 08:57:34 | <merijn> | > Dual [1,2,3] <> Dual [4,5,6] |
| 2020-11-20 08:57:37 | <lambdabot> | Dual {getDual = [4,5,6,1,2,3]} |
| 2020-11-20 08:57:41 | <koz_> | :D |
| 2020-11-20 08:57:56 | <koz_> | Another cool Monoid: Ordering. |
| 2020-11-20 08:58:00 | <merijn> | kritzefitz: There's more monoids than lists, though |
| 2020-11-20 08:58:11 | <merijn> | koz_: You're forgetting the *best* Monoid |
| 2020-11-20 08:58:15 | <koz_> | Lists are actually a very uninteresting monoid. |
| 2020-11-20 08:58:18 | <dminuoso> | koz_: Oh mmm. I was somehow under the impression that a GHC installation somehow came with these packages |
| 2020-11-20 08:58:22 | <koz_> | merijn: (Monoid b) => a -> b? |
| 2020-11-20 08:58:29 | <merijn> | koz_: Of course |
| 2020-11-20 08:58:56 | <koz_> | newtype MonoidInjection a b :P |
| 2020-11-20 08:59:02 | × | cloudster quits (~cloudster@124.123.105.47) (Remote host closed the connection) |
| 2020-11-20 08:59:12 | <guest1120> | why there're <> and ++ two ways to do the same thing? |
| 2020-11-20 08:59:24 | <merijn> | :t (++) |
| 2020-11-20 08:59:25 | <dminuoso> | guest1120: (<>) is more general than ++ |
| 2020-11-20 08:59:25 | <lambdabot> | [a] -> [a] -> [a] |
| 2020-11-20 08:59:27 | <kritzefitz> | merijn, sure there are. But I guess I'm missing the familiarity with Monoids to recognize when their properties would actually be useful to me. |
| 2020-11-20 08:59:29 | <merijn> | :t (<>) |
| 2020-11-20 08:59:29 | <koz_> | guest1120: (++) is list-only, while <> will work for any Semigroup. |
| 2020-11-20 08:59:30 | <lambdabot> | Semigroup a => a -> a -> a |
| 2020-11-20 08:59:40 | <Martinsos> | dminuoso: So specifically for that example with shapes, which one do you think is a better approach? Data types or type classes? And why? |
| 2020-11-20 09:00:00 | <merijn> | kritzefitz: Note that the monoid that koz_ mentioned "instance Monoid m => Monoid (r -> m)" applies recursively :) |
| 2020-11-20 09:00:05 | × | micahsovereign[m quits (micahsover@gateway/shell/matrix.org/x-pdyvnptozmxbustx) (Quit: Idle for 30+ days) |
| 2020-11-20 09:00:08 | × | hnOsmium0001[m] quits (hnosmium00@gateway/shell/matrix.org/x-uzbrsqhjgvjvnext) (Quit: Idle for 30+ days) |
| 2020-11-20 09:00:09 | <merijn> | :t comparing fst |
| 2020-11-20 09:00:10 | <lambdabot> | Ord a => (a, b) -> (a, b) -> Ordering |
| 2020-11-20 09:00:20 | <merijn> | :t comparing snd <> comparing fst |
| 2020-11-20 09:00:22 | <lambdabot> | (Ord a1, Ord a2) => (a2, a1) -> (a2, a1) -> Ordering |
| 2020-11-20 09:00:27 | <dminuoso> | Martinsos: It's hard to say with that little information. |
| 2020-11-20 09:00:34 | <koz_> | It's quite context-specific. |
| 2020-11-20 09:01:06 | <merijn> | > sortBy (comparing fst) [(1,2), (2,2), (1,1), (2,1)] |
| 2020-11-20 09:01:08 | <lambdabot> | [(1,2),(1,1),(2,2),(2,1)] |
| 2020-11-20 09:01:19 | <Martinsos> | dminuoso: you mean to say it depends on which extension is important for us, what we might need in the future? |
| 2020-11-20 09:01:30 | × | DirefulSalt quits (DirefulSal@gateway/vpn/privateinternetaccess/direfulsalt) (Remote host closed the connection) |
| 2020-11-20 09:01:40 | × | cfricke quits (~cfricke@unaffiliated/cfricke) (Quit: WeeChat 2.9) |
| 2020-11-20 09:01:47 | <merijn> | > sortBy (comparing snd) [(1,2), (2,2), (1,1), (2,1)] |
| 2020-11-20 09:01:47 | <merijn> | > sortBy (comparing <> comparing snd) [(1,2), (2,2), (1,1), (2,1)] |
| 2020-11-20 09:01:47 | <merijn> | eh, whoops |
| 2020-11-20 09:01:47 | <merijn> | > sortBy (comparing fst <> comparing snd) [(1,2), (2,2), (1,1), (2,1)] |
| 2020-11-20 09:01:50 | <lambdabot> | [(1,1),(1,2),(2,1),(2,2)] |
| 2020-11-20 09:01:50 | <lambdabot> | [(1,1),(2,1),(1,2),(2,2)] |
| 2020-11-20 09:01:50 | <lambdabot> | error: |
| 2020-11-20 09:01:50 | <lambdabot> | • Couldn't match type ‘(a, a1) -> Ordering’ with ‘Ordering’ |
All times are in UTC.