Home freenode/#haskell: Logs Calendar

Logs: freenode/#haskell

←Prev  Next→ 502,152 events total
2021-04-22 09:16:19 <xsperry> @src ($)
2021-04-22 09:16:20 <lambdabot> f $ x = f x
2021-04-22 09:16:33 <wrunt> (not $ year `isDiv` 100) is equivalent to (not (year `isDiv` 100))
2021-04-22 09:16:36 jakalx joins (~jakalx@base.jakalx.net)
2021-04-22 09:17:07 <wrunt> er, $ is not called apply, I must be tired :)
2021-04-22 09:17:22 <merijn> I wouldn't use $ there, just use parens...
2021-04-22 09:17:24 <xsperry> it works the way it does because of it its low precedence, infixr 0 $
2021-04-22 09:17:41 × zaquest quits (~notzaques@5.128.210.178) (Remote host closed the connection)
2021-04-22 09:17:47 <merijn> Like "(not $ year `isDiv` 100)" is just "not (year `isDiv` 100)" but worse >.>
2021-04-22 09:17:59 <lovesegfault> do I need to create that leapMatch in order to pattern match? or can I do it all with only isLeapYear?
2021-04-22 09:18:08 <wrunt> lovesegfault: listen to merijn :)
2021-04-22 09:18:17 nfip^ joins (nfip@ip98-184-89-2.mc.at.cox.net)
2021-04-22 09:18:47 <lovesegfault> I like this `` infix business, makes things more readable
2021-04-22 09:18:53 zaquest joins (~notzaques@5.128.210.178)
2021-04-22 09:19:29 <xsperry> lovesegfault, you can pattern match without creating a new function, with case
2021-04-22 09:19:31 × kiweun quits (~kiweun@2607:fea8:2a62:9600:5d11:937f:5f24:4c8b) (Ping timeout: 250 seconds)
2021-04-22 09:19:46 × Gurkenglas quits (~Gurkengla@unaffiliated/gurkenglas) (Remote host closed the connection)
2021-04-22 09:19:49 <lovesegfault> xsperry: Oh, nice, /me googles how
2021-04-22 09:20:15 <merijn> > case even 3 of True -> "Yay!"; False -> "Nay!"
2021-04-22 09:20:17 <lambdabot> "Nay!"
2021-04-22 09:21:50 <lovesegfault> oh, nice!
2021-04-22 09:21:53 lovesegfault rewrites it
2021-04-22 09:22:34 <lovesegfault> updated version: https://github.com/lovesegfault/exercism/blob/main/haskell/leap/src/LeapYear.hs
2021-04-22 09:23:11 × minoru_shiraeesh quits (~shiraeesh@46.34.207.53) (Ping timeout: 240 seconds)
2021-04-22 09:23:49 <lovesegfault> Hm, what is the standard code formatting tool for haskell?
2021-04-22 09:23:59 <olligobber> :t isDiv
2021-04-22 09:24:00 <lambdabot> error: Variable not in scope: isDiv
2021-04-22 09:24:17 <merijn> lovesegfault: There is none
2021-04-22 09:24:59 × moduli-of-pyon quits (~pyon@unaffiliated/pyon) (Quit: See ya.)
2021-04-22 09:25:07 <lovesegfault> merijn: Oh, interesting, is there a leading one at least? (e.g. Black for Python)
2021-04-22 09:25:12 <merijn> No
2021-04-22 09:25:18 <lovesegfault> fascinating
2021-04-22 09:25:31 sammyh parts (~sammyh@vps-15813cea.vps.ovh.net) ()
2021-04-22 09:25:40 <merijn> and tbh, auto-formatters are a bad crutch
2021-04-22 09:26:08 <merijn> As summarised by: https://twitter.com/comerijn/status/1257804634833420292
2021-04-22 09:27:14 <lovesegfault> fair enough :)
2021-04-22 09:27:25 <maerwald> there are plenty of formatters though
2021-04-22 09:27:37 <lovesegfault> I'm playing with ormolu right now
2021-04-22 09:27:41 <maerwald> brittany, ormolu and stylish-haskell are common
2021-04-22 09:28:46 <lovesegfault> So, in Rust I tend to do these chains of Iterator ops: https://github.com/lovesegfault/exercism/blob/5a7f942130c82e60025d9a8787fb7eae8efd0c0e/rust/acronym/src/lib.rs#L2-L11
2021-04-22 09:28:52 <lovesegfault> what does this look like in Haskell?
2021-04-22 09:33:46 × nut quits (~gtk@roc37-h01-176-170-197-243.dsl.sta.abo.bbox.fr) (Ping timeout: 240 seconds)
2021-04-22 09:35:41 × Guest5350 quits (~textual@2603-7000-3040-0000-3d14-5885-3d03-0546.res6.spectrum.com) (Quit: My MacBook has gone to sleep. ZZZzzz…)
2021-04-22 09:36:01 × totte quits (~totte@chakra/totte) (Quit: ZNC - http://znc.in)
2021-04-22 09:37:02 ClaudiusMaximus joins (~claude@cpc98210-croy26-2-0-cust137.19-2.cable.virginm.net)
2021-04-22 09:37:19 Pickchea joins (~private@unaffiliated/pickchea)
2021-04-22 09:37:21 × ClaudiusMaximus quits (~claude@cpc98210-croy26-2-0-cust137.19-2.cable.virginm.net) (Changing host)
2021-04-22 09:37:21 ClaudiusMaximus joins (~claude@unaffiliated/claudiusmaximus)
2021-04-22 09:41:41 slaterr joins (~bc8134e3@199.204.85.195)
2021-04-22 09:41:43 Gurkenglas joins (~Gurkengla@unaffiliated/gurkenglas)
2021-04-22 09:42:51 Sornaensis joins (~Sornaensi@79.142.232.102.static.router4.bolignet.dk)
2021-04-22 09:44:36 fendor joins (~fendor@178.165.129.61.wireless.dyn.drei.com)
2021-04-22 09:44:40 kuribas joins (~user@ip-188-118-57-242.reverse.destiny.be)
2021-04-22 09:45:39 Guest78317 joins (~laudiacay@67.176.215.84)
2021-04-22 09:45:49 <slaterr> lovesegfault, you could use function composition: https://paste.tomsmeding.com/DxpWsvlW . alternatively, you can use (&) function to get left to right chaining
2021-04-22 09:46:02 × Sorny quits (~Sornaensi@077213200034.dynamic.telenor.dk) (Ping timeout: 268 seconds)
2021-04-22 09:46:20 <lovesegfault> @src (&)
2021-04-22 09:46:20 <lambdabot> Source not found. Sorry about this, I know it's a bit silly.
2021-04-22 09:46:28 <slaterr> @hoogle (&)
2021-04-22 09:46:28 <lambdabot> Data.Function (&) :: a -> (a -> b) -> b
2021-04-22 09:46:28 <lambdabot> Control.Lens.Lens (&) :: () => a -> (a -> b) -> b
2021-04-22 09:46:28 <lambdabot> Control.Lens.Operators (&) :: () => a -> (a -> b) -> b
2021-04-22 09:46:41 × gzj quits (~gzj@unaffiliated/gzj) (Remote host closed the connection)
2021-04-22 09:46:47 <slaterr> you want Data.Function.(&)
2021-04-22 09:47:31 <lovesegfault> Ah, nice
2021-04-22 09:48:57 <slaterr> > "oh my god" & splitWhen (\c -> isSpace c || c `elem` ['-', '_']) & concatMap (take 1) & map toUpper
2021-04-22 09:48:59 <lambdabot> "OMG"
2021-04-22 09:49:14 zva joins (~zava@ip5f5bdf0f.dynamic.kabel-deutschland.de)
2021-04-22 09:49:17 gehmehgeh joins (~ircuser1@gateway/tor-sasl/gehmehgeh)
2021-04-22 09:49:17 <lovesegfault> Super cool
2021-04-22 09:49:57 <tomsmeding> concatMap (take 1) == map head
2021-04-22 09:49:58 × Guest78317 quits (~laudiacay@67.176.215.84) (Ping timeout: 260 seconds)
2021-04-22 09:50:09 <slaterr> head will error on an empty list
2021-04-22 09:50:15 <tomsmeding> hm, unless yes that
2021-04-22 09:52:48 <lovesegfault> where does splitWhen come from? Looking here: https://hoogle.haskell.org/?hoogle=splitwhen I would imagine I just had to do `import Data.List (splitWhen)`?
2021-04-22 09:53:19 <slaterr> split package, https://hackage.haskell.org/package/split-0.2.3.4/docs/Data-List-Split.html
2021-04-22 09:53:45 DavidEichmann joins (~david@147.136.46.217.dyn.plus.net)
2021-04-22 09:55:15 <slaterr> for serious work, you want Text over String, so you'd use https://hackage.haskell.org/package/text-1.2.4.1/docs/Data-Text.html#v:splitOn. but I took this question to be more about functions chaining than about string processing
2021-04-22 09:57:17 <slaterr> or rather, Data.Text.split
2021-04-22 09:57:26 <lovesegfault> Yup
2021-04-22 10:02:43 <lovesegfault> Why doesn't this work? https://gist.github.com/4e5242468f437d571cd3a2e2968e8cc5
2021-04-22 10:03:02 <lovesegfault> (not as a solution to the acronym thing, but rather that it fails to typecheck altogether)
2021-04-22 10:03:28 × heatsink quits (~heatsink@108-201-191-115.lightspeed.sntcca.sbcglobal.net) (Remote host closed the connection)
2021-04-22 10:03:29 <lovesegfault> error: https://gist.github.com/5199c7b058be9e3666c2751a4ad31b88
2021-04-22 10:04:35 <slaterr> swap the order of concat and split
2021-04-22 10:05:00 <lovesegfault> Oh :D
2021-04-22 10:05:10 <lovesegfault> so the pipelines go backwards
2021-04-22 10:05:29 <slaterr> also it is common do something like this, import qualified Data.Text as T, then you can do T.concat
2021-04-22 10:05:34 <slaterr> yes
2021-04-22 10:05:37 <slaterr> @src (.)
2021-04-22 10:05:37 <lambdabot> (f . g) x = f (g x)
2021-04-22 10:06:37 idhugo_ joins (~idhugo@87-49-147-45-mobile.dk.customer.tdc.net)
2021-04-22 10:07:46 <xsperry> . is basically ascii equivalent of ∘ in math. https://en.wikipedia.org/wiki/Function_composition
2021-04-22 10:07:53 <lovesegfault> what's the right way to verbalize this: map :: (Char -> Char) -> Text -> Text
2021-04-22 10:08:07 <lovesegfault> i.e. how do I say that out loud
2021-04-22 10:09:04 × idhugo__ quits (~idhugo@87-49-45-4-mobile.dk.customer.tdc.net) (Ping timeout: 252 seconds)
2021-04-22 10:10:51 <slaterr> I'm not sure about the "official" version, but I'd say that map takes a function from char to char, text, and returns text.
2021-04-22 10:11:19 <slaterr> (even though, technically, it takes char to char function, and returns a function from Text to Text)
2021-04-22 10:12:07 <lovesegfault> Ah, yes, I like the second version :D
2021-04-22 10:12:27 Alleria joins (~textual@zrcout.mskcc.org)

All times are in UTC.