Logs: freenode/#haskell
| 2020-10-09 18:10:49 | <dsal> | I tend to reach for megaparsec early, but I also don't parse for performance much. |
| 2020-10-09 18:11:00 | <geekosaur> | depends. Read itself has a decent amount of overhead |
| 2020-10-09 18:11:21 | <tomsmeding> | @hoogle ByteString -> (Double, ByteString) |
| 2020-10-09 18:11:22 | <lambdabot> | Algebra.RealRing splitFraction :: (C a, C b) => a -> (b, a) |
| 2020-10-09 18:11:22 | <lambdabot> | NumericPrelude splitFraction :: (C a, C b) => a -> (b, a) |
| 2020-10-09 18:11:22 | <lambdabot> | NumericPrelude.Numeric splitFraction :: (C a, C b) => a -> (b, a) |
| 2020-10-09 18:11:25 | × | GyroW_ quits (~GyroW@unaffiliated/gyrow) (Ping timeout: 240 seconds) |
| 2020-10-09 18:11:29 | <tomsmeding> | now if that would've existed :p |
| 2020-10-09 18:11:56 | <tomsmeding> | @hoogle ByteString -> Maybe (Double, ByteString) |
| 2020-10-09 18:11:57 | <lambdabot> | Data.ByteString.Lex.Integral readDecimal :: Integral a => ByteString -> Maybe (a, ByteString) |
| 2020-10-09 18:11:57 | <lambdabot> | Data.ByteString.Lex.Integral readHexadecimal :: Integral a => ByteString -> Maybe (a, ByteString) |
| 2020-10-09 18:11:57 | <lambdabot> | Data.ByteString.Lex.Integral readOctal :: Integral a => ByteString -> Maybe (a, ByteString) |
| 2020-10-09 18:12:05 | <tomsmeding> | there we go, let's try that |
| 2020-10-09 18:14:30 | × | ClaudiusMaximus quits (~claude@unaffiliated/claudiusmaximus) (Quit: ->) |
| 2020-10-09 18:14:58 | <ski> | @type ((listToMaybe .) . evalStateT . (>>= \ns -> do "" <- StateT lex; return ns) . many . StateT) (reads :: ReadS Double) |
| 2020-10-09 18:15:00 | <lambdabot> | String -> Maybe [Double] |
| 2020-10-09 18:17:58 | × | Ariakenom quits (~Ariakenom@193.254.193.1) (Ping timeout: 258 seconds) |
| 2020-10-09 18:19:12 | <tomsmeding> | ski: that's ~60% slower than my simple read pipeline |
| 2020-10-09 18:19:37 | <tomsmeding> | and my read pipeline additionally has the advantage of not using the list monad in an obscure manner :p |
| 2020-10-09 18:20:11 | <tomsmeding> | (on my machine) |
| 2020-10-09 18:21:16 | × | cosimone quits (~cosimone@93-47-228-249.ip115.fastwebnet.it) (Quit: cosimone) |
| 2020-10-09 18:21:51 | → | cosimone joins (~cosimone@2001:b07:ae5:db26:fe52:4567:a4e4:fc3a) |
| 2020-10-09 18:21:56 | → | ButterflyOfFire joins (~Butterfly@185.163.110.116) |
| 2020-10-09 18:22:13 | × | nyd quits (~lpy@unaffiliated/elysian) (Ping timeout: 260 seconds) |
| 2020-10-09 18:22:37 | × | GyroW quits (~GyroW@unaffiliated/gyrow) (Quit: Someone ate my pie) |
| 2020-10-09 18:22:47 | → | GyroW joins (~GyroW@d54c03e98.access.telenet.be) |
| 2020-10-09 18:22:48 | × | GyroW quits (~GyroW@d54c03e98.access.telenet.be) (Changing host) |
| 2020-10-09 18:22:48 | → | GyroW joins (~GyroW@unaffiliated/gyrow) |
| 2020-10-09 18:23:53 | <tomsmeding> | ski: though I'm curious how you came up with that monstrosity :p |
| 2020-10-09 18:24:44 | → | Guest18 joins (4f7755cb@gateway/web/cgi-irc/kiwiirc.com/ip.79.119.85.203) |
| 2020-10-09 18:24:54 | <tomsmeding> | ah the bytestring way seems _significantly_ faster |
| 2020-10-09 18:25:09 | <tomsmeding> | (as expected, in hindsight) |
| 2020-10-09 18:25:23 | <Guest18> | Hello, I have a question regarding unbalanced binary search trees in haskell |
| 2020-10-09 18:25:31 | → | ashbreeze joins (~mark@72-161-255-112.dyn.centurytel.net) |
| 2020-10-09 18:25:42 | <ski> | dwts : you could compare with <https://srfi.schemers.org/srfi-67/srfi-67.html#node_sec_4.5> |
| 2020-10-09 18:25:48 | <Athas> | Roughly, when you have a monad transformer stack, is it more efficient to have an Error/Except monad innermost, or an error monad transformer outermost? |
| 2020-10-09 18:25:54 | <Athas> | Or does it depend on the specifics? |
| 2020-10-09 18:26:08 | <ski> | tomsmeding : hm, i thought it was fairly straightforward |
| 2020-10-09 18:27:00 | → | bifunc2 joins (bifunc2@gateway/vpn/protonvpn/bifunc2) |
| 2020-10-09 18:27:01 | <ski> | "my read pipeline additionally has the advantage of not using the list monad in an obscure manner" -- is that an advantage ? ;p |
| 2020-10-09 18:27:20 | <tomsmeding> | questionably : |
| 2020-10-09 18:27:20 | <ski> | (but i don't really think it's that obscure ..) |
| 2020-10-09 18:27:21 | <tomsmeding> | * :p |
| 2020-10-09 18:27:31 | <tomsmeding> | but apart from how obscure your pipeline is or not |
| 2020-10-09 18:27:37 | × | _ashbreeze_ quits (~mark@184-157-33-36.dyn.centurytel.net) (Ping timeout: 246 seconds) |
| 2020-10-09 18:27:39 | <tomsmeding> | why did you think it would be faster than my simple read pipeline? |
| 2020-10-09 18:28:09 | <bifunc2> | If unsigned integers are serialized in big endian, order is preserved. (smaller number gets a smaller bytestring) |
| 2020-10-09 18:28:09 | <bifunc2> | Is there any such way to serialize signed integers, Doubles, and Floats? |
| 2020-10-09 18:28:30 | → | raym joins (~ray@115.187.50.175) |
| 2020-10-09 18:29:05 | tomsmeding | has no idea regarding Athas' question, pass to another willing answerer |
| 2020-10-09 18:29:40 | <Guest18> | I made a small type that is a binary search tree and some functions for it, like insert, delete, etc. All is well so far, except for the function that returns the node depth for a given value. for example, if a node has a value of '3' and is 2 levels down from the root, it should return 'Just 2'. If the value searched for isn't in the tree, it |
| 2020-10-09 18:29:40 | <Guest18> | returns nothing. I have a working example, but it isn't that good. Can anybody provide me with a better implementation or at least some advice? |
| 2020-10-09 18:29:47 | <dolio> | Innermost vs. outermost might not have the same semantics. |
| 2020-10-09 18:30:25 | → | mirrorbird joins (~psutcliff@m83-185-82-223.cust.tele2.se) |
| 2020-10-09 18:30:54 | × | geekosaur quits (82659a05@host154-005.vpn.uakron.edu) (Ping timeout: 245 seconds) |
| 2020-10-09 18:31:16 | <tomsmeding> | bifunc2: in the standard IEEE floating point format, positive doubles and floats already sort correctly |
| 2020-10-09 18:31:27 | <tomsmeding> | negative ones sort above positive ones |
| 2020-10-09 18:31:30 | <ski> | @quote Dr._Seuss |
| 2020-10-09 18:31:30 | <lambdabot> | Dr._Seuss says: `type Parser a = String -> [(a,String)]' -- "A Parser for Things / is a function from Strings / to Lists of Pairs / of Things and Strings!" -- <https://willamette.edu/~fruehr/haskell/ |
| 2020-10-09 18:31:30 | <lambdabot> | seuss.html> |
| 2020-10-09 18:31:43 | <tomsmeding> | the same holds for signed integers in 2's complement, when you write them in big endian order |
| 2020-10-09 18:31:54 | <bifunc2> | tomsmeding, wow, that's mind-blowing, thanks! |
| 2020-10-09 18:32:01 | <Guest18> | The code here: https://pastebin.pl/view/9ea923e2 |
| 2020-10-09 18:32:04 | <Cale> | Guest18: Seems like something that perhaps the Monad instance for Maybe could help to make clean |
| 2020-10-09 18:32:05 | × | Jesin quits (~Jesin@pool-72-66-101-18.washdc.fios.verizon.net) (Ping timeout: 246 seconds) |
| 2020-10-09 18:32:07 | <tomsmeding> | bifunc2: about the signed integers, or about the floats? |
| 2020-10-09 18:32:36 | <Guest18> | Cale: I don't know how to use monads yet |
| 2020-10-09 18:32:38 | <Cale> | Guest18: one sec... that's just taking a moment to load here |
| 2020-10-09 18:32:54 | <bifunc2> | tomsmeding, I'm more interested in the floats. For positive Doubles and Floats, will the "store" package preserve the order on a little endian machine? |
| 2020-10-09 18:32:57 | <tomsmeding> | for the floats, you can see that by noting that if 0 < A < B, then either A has a smaller exponent than B, or it has the same exponent and a smaller mantissa |
| 2020-10-09 18:33:11 | <tomsmeding> | ignoring the sign bit of course |
| 2020-10-09 18:33:13 | <Cale> | Guest18: does it load for you? |
| 2020-10-09 18:33:24 | <Cale> | Not sure if I'm just having an issue locally... |
| 2020-10-09 18:33:26 | <Guest18> | Cale: Slowly, but yeah |
| 2020-10-09 18:33:31 | <Guest18> | It took a while |
| 2020-10-09 18:33:53 | <tomsmeding> | bifunc2: I have no idea what the 'store' package does, but that claim about the IEEE format only holds for big-endian order |
| 2020-10-09 18:34:02 | <Cale> | Maybe try dpaste.com? |
| 2020-10-09 18:34:31 | <tomsmeding> | ski: it's unfortunate that that quote splits over lines halfway through a URL |
| 2020-10-09 18:34:46 | <Guest18> | Cale: https://dpaste.com/GX8QSKDLD |
| 2020-10-09 18:34:52 | <Cale> | thanks |
| 2020-10-09 18:35:56 | → | chaosmasttter joins (~chaosmast@p200300c4a70b4001c004325a2a510724.dip0.t-ipconnect.de) |
| 2020-10-09 18:36:00 | <bifunc2> | tomsmeding okay. https://hackage.haskell.org/package/store always uses machine endianness. so i'm out of luck there with the order on most machines nowadays. |
| 2020-10-09 18:36:01 | <bifunc2> | However I can use cereal https://hackage.haskell.org/package/cereal-0.5.8.1/docs/Data-Serialize-IEEE754.html which can encode floats in big-endian |
| 2020-10-09 18:36:03 | <Cale> | That code looks fairly reasonable to me actually |
| 2020-10-09 18:36:11 | <bifunc2> | are there any alternatives to cereal that are faster nowadays? |
| 2020-10-09 18:36:12 | <Cale> | You might want to use compare x root |
| 2020-10-09 18:36:13 | <Guest18> | Oh, yeah, I should mention that i used to do a lookup first, to ensure that if the element isn't there, i return nothign |
| 2020-10-09 18:36:46 | <Cale> | Oh, right, depthGo isn't returning Nothing, somehow |
| 2020-10-09 18:36:57 | <Guest18> | but it seemed to me that it would be too slow and maybe there is a better way, but i couldn't find it |
| 2020-10-09 18:37:02 | <Guest18> | that's why i came here |
| 2020-10-09 18:37:13 | <tomsmeding> | bifunc2: not well-versed enough in the library ecosystem to answer that question, unfortunately |
| 2020-10-09 18:37:39 | <Guest18> | for small trees, it's fine, but doing a lookup on big trees before searching for the depth once again, does add unnecesarry computation |
| 2020-10-09 18:37:39 | <Cale> | Guest18: I would guess that you want depthGo _ EmptyTree acc = Nothing |
| 2020-10-09 18:38:15 | <monochrom> | and the x==root case, = Just acc |
| 2020-10-09 18:38:19 | <Cale> | yeah |
| 2020-10-09 18:38:20 | <bifunc2> | tomsmeding, np, thanks for the other info! |
| 2020-10-09 18:38:32 | <monochrom> | So generally the whole depthGo does Maybe, too. |
| 2020-10-09 18:38:37 | <Cale> | and then take the Maybe stuff out of depth |
| 2020-10-09 18:38:39 | <Guest18> | so modify the depthGo to return Maybe b as well |
| 2020-10-09 18:38:49 | <Cale> | (it'll produce Maybe only because depthGo does) |
All times are in UTC.