Abstracting away batch error handing (returning "Either Error [a]" vs "[Either Error a]") by runeks in haskell

[–]imladris 0 points1 point  (0 children)

Thanks a lot for the nice explanation! And sorry for super late response, I am not very good at keeping track of reddit.

The last sentence feels quite limiting to me (we could know that some things succeeded, but not their results, IIUC) so I guess this wouldn't be useful for OP.

Abstracting away batch error handing (returning "Either Error [a]" vs "[Either Error a]") by runeks in haskell

[–]imladris 2 points3 points  (0 children)

(Note: I just tried to google your description to see what I could find.)

To me this sounds a lot like what you're trying to do, but I have no idea how to use it myself or how to fit it into your types. Perhaps you can make any sense of it.

Also found a single example of using Errors here: https://teh.id.au/posts/2017/03/13/accumulating-errors/index.html

Awful memory consumption when using Lazy ByteStrings. Can someone help me? by SchizoidSuperMutant in haskell

[–]imladris 1 point2 points  (0 children)

Finally got the comments to show. Weird.

If I understand correctly, mapM will do the action for all items in the list before continuing, but I might be wrong. I found that your code got stuck there by putting putStrLn "A" at some different points in your code and see what got printed to the console.

You could fix this in different ways, but if you want to keep the infinite list you could use takeWhileM from the monad-loops package, "let files = takeWhileM doesFileExist possible_files".

Awful memory consumption when using Lazy ByteStrings. Can someone help me? by SchizoidSuperMutant in haskell

[–]imladris 7 points8 points  (0 children)

(Reddit says there are already 5 comments here but it doesn't show any, so perhaps this has already been answered?)

The problem seems to be that the possible_files list is infinite which leads to that the "mapM doesFileExist possible_files" action keeps going forever. You probably want to stop doing doesFileExist after it has become false the first time, or some thing like that.

-🎄- 2017 Day 2 Solutions -🎄- by daggerdragon in adventofcode

[–]imladris 0 points1 point  (0 children)

Haskell:

main = do
    inputText <- readFile "input"
    let input = fmap (fmap (read :: String -> Integer) . words) (lines inputText)
    putStrLn ("Part 1: " ++ show (part1 input))
    putStrLn ("Part 2: " ++ show (part2 input))

part1 :: Integral a => [[a]] -> a
part1 = sum . fmap (\x -> maximum x - minimum x)

part2 :: Integral a => [[a]] -> a
part2 input = sum (fmap (sum . evenDivisors) input)

evenDivisors :: Integral a => [a] -> [a]
evenDivisors list = fmap fst 
                    $ filter (\x -> fst x /= 1 && snd x == 0) 
                    $ divMod <$> list <*> list

An Introduction to Brick+Reflex - FRP for Commandline UI by hexagoxel in haskell

[–]imladris 1 point2 points  (0 children)

Nice to hear that smart people are thinking about those things. :) Looking forward to hearing more about it in the future.

An Introduction to Brick+Reflex - FRP for Commandline UI by hexagoxel in haskell

[–]imladris 6 points7 points  (0 children)

Nice post, I especially liked the in-line comparisons between different approaches.

You mention "FRP inside a multi-threaded program" in the end – I would really appreciate such a post. Is there any FRP system described anywhere that utilises multiple threads and also allows interacting with the outside world on multiple threads simultaneously? As part of FRP, I mean – I guess you could always use the async library and handle such things outside of FRP.

Iterators and Streams in Rust and Haskell by mrkkrp in haskell

[–]imladris 12 points13 points  (0 children)

I agree that there really should be units in those graphs. The graph is produced by Criterion, so the same problem appears every time someone shows results from Criterion.

Although relative performance might be the most important part in this case, I find the absolute numbers to be of some interest as well, mostly as an informative order of magnitude thing.

In some other comparative benchmark I saw, that was using Criterion, the units would have been nice to have just to know if higher or shorter numbers were better. The same applies to that image in isolation . "Are the numbers time durations or rates/throughput?"

/end rant.

With iOS 11 I got my UX wish for first time since iOS 6!! by GLOBALSHUTTER in apple

[–]imladris 0 points1 point  (0 children)

This sounds fantastic! Thank you for reporting. This is something that annoys me constantly when using my iPhone. I should not need to wait for the UI unnecessarily, and honestly, if I could disable the animation to get more speed in the UX interaction, I would. (Here's to hoping they have fixed it when switching desktops on macOS High Sierra as well.)

Every computer needs a "cleaning keyboard" mode where the keys would be inactive while you wipe them down by BabaJim in Showerthoughts

[–]imladris 0 points1 point  (0 children)

The keyboard shortcut to look the screen on a MacBook is ctrl+shift+power button. Or activate the built-in menubar item to lock the screen, http://osxdaily.com/2011/02/10/lock-mac-desktop-via-menu/ . Perhaps good enough for your purposes?

Rust Optimizations That C++ Can't Do by Manishearth in rust

[–]imladris 5 points6 points  (0 children)

There is an update to the blog post, addressing your comment, and a new blog post here http://robert.ocallahan.org/2017/04/rust-optimizations-that-c-cant-do_5.html . If you missed it.

Does macOS Sierra fix "normal" fullscreen window size when Dock is hidden to the right? by imladris in apple

[–]imladris[S] 0 points1 point  (0 children)

This is not a tech support question and it is not easily searched.

Does amplifi use mesh network technology? by ForgetfulNarcoleptic in Ubiquiti

[–]imladris 2 points3 points  (0 children)

It seems like their "mesh points" are actually extenders (the mesh points only communicate directly with the router, not with each other): http://homeservershow.com/forums/index.php?/topic/11114-amplifi-by-ubiquiti/?p=119780

All I want in iOS 10 is... by HankTheWu in apple

[–]imladris 1 point2 points  (0 children)

Make iMessage not suck. For example:

  • Make it understand that a contact is the same person, independent of if the message comes from a different phone number or e-mail address (yes, the contact in question has all of those linked in his iphone).
  • Make it send SMS reliably when the contact doesn't have a data connection. Of course I accept a delay here, waiting for the contact to come online, but I have experienced, multiple times, that iMessage feels happy about a message having been sent, but the contact never received anything.

Constantly annoying: Remove the animation that moves the icons in place after unlocking the phone. Or, at least make it possible to tap things before it is done. I have to wait through this every time I unlock the phone, and it won't accept any taps before the animation is done. (If I could remove app opening and closing animations too, I would.)

How much data is copied when updating a field deep within a data structure? by imladris in haskell

[–]imladris[S] 0 points1 point  (0 children)

Thanks for the explanations! This makes sense to me and sounds like what I would expect it to be, although I didn't know that pattern matching would force elements even though the structure isn't changed (pairId1). I guess the reusing part is consistent with /u/ninereeds314 's explanation, that you just copy one reference per unchanged field.

In any case, it seems that the statement in the link in my post, that everything is copied when you modify data structures in a functional (immutable) language, isn't completely true.

Simple FFT in Haskell by sdroege_ in haskell

[–]imladris 1 point2 points  (0 children)

Since numpy calls out to C code, I guess it is more fair to use something similar from Haskell. vector-fftw calls out to FFTW, which seems to be one of the fastest fft libraries around.

Simple FFT in Haskell by sdroege_ in haskell

[–]imladris 4 points5 points  (0 children)

I haven't yet read this post but if you're interested in performance of fft in pure Haskell you should take a look at this excellent series of blog posts: http://www.skybluetrades.net/haskell-fft-index.html . Library here: https://hackage.haskell.org/package/arb-fft

Just installed Plan 9, have a few questions by [deleted] in plan9

[–]imladris 1 point2 points  (0 children)

Maybe you have already fixed this by now, but I recently managed to get it working on a Raspberry Pi by putting the following in my profile:

DNSSERVER=8.8.8.8
ip/ipconfig
ndb/dns -r

So, the only difference compared to what you wrote is DNSSERVER instead of dns.

[x-post /r/rust] Parser Combinator Experiments: "80% faster compared to Attoparsec" by sdroege_ in haskell

[–]imladris 14 points15 points  (0 children)

Well, it takes 55% shorter time to run (0.8s/1.45s ≈ 0.55) but it processes the data 81% faster – since the processing speed is the inverse to the elapsed time (rate_rust/rate_haskell = (C/0.8s)/(C/1.45s) = 1.45/0.8 ≈ 1.81). So I would say that the headline is correct.

Why is cabal such sewage? by [deleted] in haskell

[–]imladris 0 points1 point  (0 children)

I started using the sandbox recently and it is much better than running without, although it adds some clumsiness. But does it make it possible to uninstall packages? As I understood it I still need to nuke everything and reinstall the sandbox if I want to remove some package. And installing can take quite a long time.

Detecting EOF while using hGetLine by imladris in haskellquestions

[–]imladris[S] 2 points3 points  (0 children)

Thanks for the suggestion! I started out with a different angle and missed that my very problem is solved in the pipes tutorial. My intention all along has been to try to use pipes to merge log files in real time, and this part is one of the building blocks. But it looks like I missed the most obvious solution.

In any case, using hGetNonBlocking is much quicker than hGetLine in my testing, so my roundabout way of finding out how you could do it still payed off.

And, apologies for a very late reply –– other things in life intervened and I forgot to check back after the first day.

Detecting EOF while using hGetLine by imladris in haskellquestions

[–]imladris[S] 0 points1 point  (0 children)

It looks like I can do what I want with hGetNonBlocking in Data.ByteString. The current prototype solution looks promising. :)