Home freenode/#haskell: Logs Calendar

Logs: freenode/#haskell

←Prev  Next→ 502,152 events total
2020-11-21 15:21:47 <zyklotomic> > map ((/) 2) [1..10]
2020-11-21 15:21:49 <lambdabot> [2.0,1.0,0.6666666666666666,0.5,0.4,0.3333333333333333,0.2857142857142857,0....
2020-11-21 15:21:57 <zyklotomic> lol
2020-11-21 15:22:03 <zyklotomic> but (*) is ass
2020-11-21 15:22:14 <zyklotomic> *comm
2020-11-21 15:22:45 <sondr3_> be nice to (*)
2020-11-21 15:22:50 × czwartyeon quits (4d2d3763@77-45-55-99.sta.asta-net.com.pl) (Disconnected by services)
2020-11-21 15:23:20 czwartye1 is now known as czwartyeon
2020-11-21 15:23:53 × czwartyeon quits (~czwartyeo@77-45-55-99.sta.asta-net.com.pl) (Client Quit)
2020-11-21 15:24:12 czwartyeon joins (~czwartyeo@77-45-55-99.sta.asta-net.com.pl)
2020-11-21 15:24:29 hidedagger joins (~nate@unaffiliated/hidedagger)
2020-11-21 15:24:58 × hidedagger quits (~nate@unaffiliated/hidedagger) (Client Quit)
2020-11-21 15:27:17 × czwartyeon quits (~czwartyeo@77-45-55-99.sta.asta-net.com.pl) (Client Quit)
2020-11-21 15:27:35 czwartyeon joins (~czwartyeo@77-45-55-99.sta.asta-net.com.pl)
2020-11-21 15:27:42 × czwartyeon quits (~czwartyeo@77-45-55-99.sta.asta-net.com.pl) (Client Quit)
2020-11-21 15:28:20 <Feuermagier> how do I elegantly check if an entire list of bools is true if I "and" it?
2020-11-21 15:28:31 hidedagger joins (~nate@unaffiliated/hidedagger)
2020-11-21 15:28:51 czwartyeon joins (~czwartyeo@77-45-55-99.sta.asta-net.com.pl)
2020-11-21 15:28:52 <merijn> :t and
2020-11-21 15:28:53 <lambdabot> Foldable t => t Bool -> Bool
2020-11-21 15:29:09 <ski> Feuermagier : did the list come from `map' ?
2020-11-21 15:29:13 <merijn> :t getAll . foldMap All
2020-11-21 15:29:14 <lambdabot> Foldable t => t Bool -> Bool
2020-11-21 15:30:25 <ski> @type all
2020-11-21 15:30:26 <lambdabot> Foldable t => (a -> Bool) -> t a -> Bool
2020-11-21 15:30:40 × czwartyeon quits (~czwartyeo@77-45-55-99.sta.asta-net.com.pl) (Client Quit)
2020-11-21 15:30:50 <sondr3_> How do I combine parsers in Megaparsec? I have `char '<' *> takeWhile1P Nothing (== '=') <* char '>'` which discards the chars, and I can't figure out how to combine them
2020-11-21 15:30:57 czwartyeon joins (~czwartyeo@77-45-55-99.sta.asta-net.com.pl)
2020-11-21 15:30:59 carlomagno joins (~cararell@148.87.23.4)
2020-11-21 15:31:01 <Feuermagier> ski, yes. I have 3 seperate lists generated by 3 seperate functions
2020-11-21 15:31:09 <dminuoso> all p = getAll #. foldMap (All #. p)
2020-11-21 15:31:13 <ski> @src all
2020-11-21 15:31:13 <lambdabot> all p = and . map p
2020-11-21 15:31:15 Tario joins (~Tario@201.192.165.173)
2020-11-21 15:31:15 <ski> @src any
2020-11-21 15:31:15 <lambdabot> any p = or . map p
2020-11-21 15:31:22 <dminuoso> Curious that this uses foldMap
2020-11-21 15:31:41 <ski> Feuermagier : if you have `and (map p xs)', you can say `all p xs'
2020-11-21 15:31:42 <dminuoso> sondr3_: In what way do you want to combine then?
2020-11-21 15:31:49 × hidedagger quits (~nate@unaffiliated/hidedagger) (Client Quit)
2020-11-21 15:31:50 <ski> > liftA2 (^) [0,1,2,3] [0,1,2,3]
2020-11-21 15:31:52 <lambdabot> [1,0,0,0,1,1,1,1,1,2,4,8,1,3,9,27]
2020-11-21 15:31:53 <merijn> dminuoso: "getAll (coerce fold)" :p
2020-11-21 15:31:57 <merijn> eh
2020-11-21 15:32:01 <merijn> add a . there
2020-11-21 15:32:09 <sondr3_> dminuoso: so the output becomes "<===>", now it is just "==="
2020-11-21 15:32:13 <ski> > [m ^ n | m <- [0,1,2,3],n <- [0,1,2,3]]
2020-11-21 15:32:16 <lambdabot> [1,0,0,0,1,1,1,1,1,2,4,8,1,3,9,27]
2020-11-21 15:32:17 <dminuoso> ski: The "output"?
2020-11-21 15:32:20 <dminuoso> Err sondr3_.
2020-11-21 15:32:25 <zyklotomic> won't a regular fold work?
2020-11-21 15:32:27 <ski> > [[m ^ n | n <- [0,1,2,3]] | m <- [0,1,2,3]]
2020-11-21 15:32:30 <lambdabot> [[1,0,0,0],[1,1,1,1],[1,2,4,8],[1,3,9,27]]
2020-11-21 15:32:36 <merijn> :t fold
2020-11-21 15:32:37 <lambdabot> (Foldable t, Monoid m) => t m -> m
2020-11-21 15:32:40 <merijn> :t foldMap
2020-11-21 15:32:42 <lambdabot> (Foldable t, Monoid m) => (a -> m) -> t a -> m
2020-11-21 15:32:52 cr3 joins (~cr3@192-222-143-195.qc.cable.ebox.net)
2020-11-21 15:32:56 <merijn> zyklotomic: You can do it with a regular fold, sure. But monoids are cool
2020-11-21 15:33:07 <ski> > let pam = flip map in [0,1,2,3] `pam` \m -> [0,1,2,3] `pam` \n -> m ^ n
2020-11-21 15:33:09 <lambdabot> [[1,0,0,0],[1,1,1,1],[1,2,4,8],[1,3,9,27]]
2020-11-21 15:33:19 <merijn> zyklotomic: Also, monoids compose better
2020-11-21 15:33:20 <dminuoso> sondr3_: Also, your `takeWhile1P Nothing (== '=')` should just be `some (char '=')`
2020-11-21 15:33:25 <sondr3_> dminuoso: I meant what it returns x) the signature is `parser :: Parser Text`
2020-11-21 15:33:48 <dminuoso> sondr3_: Ah. So the most naive way is to use the monadic interface.
2020-11-21 15:33:59 <dminuoso> But that's not necessary
2020-11-21 15:34:59 <sondr3_> I've never done parser combinators before, so the code is surely weird :P
2020-11-21 15:35:12 <dminuoso> sondr3_: https://gist.github.com/dminuoso/6fcd4ffac6afc5a7a4ec9f39052dd986
2020-11-21 15:35:22 <dminuoso> Note that its usually awkward to return exactly what you parsed.
2020-11-21 15:36:05 <Feuermagier> ski, thx! - that works for me
2020-11-21 15:36:12 <dminuoso> I want to emphasize that you dont have to use the do/monadic interface here, you can do this with applicative too, but this is probably more readable
2020-11-21 15:36:41 <dminuoso> Oh, actually that code is off..
2020-11-21 15:36:53 <sondr3_> dminuoso: I'm all ears for suggestions and tips
2020-11-21 15:37:08 <dminuoso> takeWhile1P is right after all
2020-11-21 15:37:20 <zyklotomic> oh foldMap is essentialy Writer?
2020-11-21 15:37:33 <ski> Feuermagier : it sounded like perhaps, by "how do I zipWith, but only with one of the arguments changeing?","compine x with every argument out of [list] by function f - cycle through the list, keep x", you also had in mind possibly choosing `x' in each possible way, from a list. (hence the above lambdabot queries)
2020-11-21 15:37:48 <dminuoso> sondr3_: reload my gist
2020-11-21 15:38:19 <dminuoso> sondr3_: So I dont know what you're doing exactly, why do you need the parser to return the exact string it just parsed?
2020-11-21 15:39:03 <et09> ugh i don't get this
2020-11-21 15:39:18 <et09> xmonad --recompile, stack exec xmonad -- --recompile show it can't find XMonad, Xmonad.Util, etc.
2020-11-21 15:39:29 <sondr3_> dminuoso: I'm learning parsing?Haskell by parsing a format called HRX, and it requires "boundaries" (the <===>) to be the same width in the same document
2020-11-21 15:39:30 <et09> even after i just installed all of them with stack install
2020-11-21 15:39:52 <dminuoso> sondr3_: I see! :)
2020-11-21 15:40:55 neiluj joins (~jco@91-167-203-101.subs.proxad.net)
2020-11-21 15:40:55 × neiluj quits (~jco@91-167-203-101.subs.proxad.net) (Changing host)
2020-11-21 15:40:55 neiluj joins (~jco@unaffiliated/neiluj)
2020-11-21 15:42:26 <dminuoso> sondr3_: Perhaps you could write two combinators, firstBoundary :: Parser Int; and boundary :: Int -> Parser ()
2020-11-21 15:42:57 <dminuoso> Alternatively, you could bury the boundary length inside the state of your parser
2020-11-21 15:43:21 <dminuoso> say some `Maybe Int` that starts at Nothing, and `boundary :: Parser ()` then, if its Nothing, would determine the length, and if its `Just n` demand exactly n equals.
2020-11-21 15:44:09 <sondr3_> Yeah, I've been thinking about doing that, seems to be the easiest way in my head
2020-11-21 15:44:12 elliott__ joins (~elliott@pool-108-51-141-12.washdc.fios.verizon.net)
2020-11-21 15:44:20 son0p joins (~son0p@181.58.39.182)
2020-11-21 15:44:35 aarvar joins (~foewfoiew@50.35.43.33)
2020-11-21 15:45:04 ddellacosta joins (dd@gateway/vpn/mullvad/ddellacosta)
2020-11-21 15:45:16 wroathe joins (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net)
2020-11-21 15:45:19 × Inoperable quits (~PLAYER_1@fancydata.science) (Excess Flood)
2020-11-21 15:46:00 × kish` quits (~oracle@unaffiliated/oracle) (Remote host closed the connection)
2020-11-21 15:47:10 kish` joins (~oracle@unaffiliated/oracle)
2020-11-21 15:49:33 Inoperable joins (~PLAYER_1@fancydata.science)
2020-11-21 15:50:57 × ChaiTRex quits (~ChaiTRex@gateway/tor-sasl/chaitrex) (Remote host closed the connection)

All times are in UTC.