Cale 2017-03-09 02:46:38
But some kind of type class might be in order -- you might not just have it give you a lens, but instead, operations that are more specific to your application.
Athas 2017-03-09 03:20:37
What's the simplest way to do a parallel map?
Athas 2017-03-09 03:20:47
(Over a list.)
c_wraith 2017-03-09 03:21:43
parallel or concurrent?
Athas 2017-03-09 03:21:47
Parallel. Pure code.
c_wraith 2017-03-09 03:22:06
list isn't a great structure for that, but sometimes it works
Athas 2017-03-09 03:22:20
Something from Control.Parallel.Strategies, maybe...
arun_t 2017-03-09 03:22:20
please let me know how haskell embrace immutability?
c_wraith 2017-03-09 03:22:29
yeah, it has combinators for lists
Athas 2017-03-09 03:22:30
These lists will typically be quite short, so it should be OK.
c_wraith 2017-03-09 03:23:07
there's parList and parListChunk
quchen 2017-03-09 03:23:18
arun_t: All variables are constant.
c_wraith 2017-03-09 03:23:23
or parMap
c_wraith 2017-03-09 03:23:30
err, *and* parMap
arun_t 2017-03-09 03:23:44
quchen: what about data structures?
merijn 2017-03-09 03:31:53
Yeah, accelerate is like most high-level GPU tools in that people who want GPU performance don't use it
c_wraith 2017-03-09 03:32:00
Athas: monad-par might be used more - it's a bit simpler conceptually than Strategies, though it requires bigger code changes to use
merijn 2017-03-09 03:32:09
And people who don't need GPU performance don't have a use for using accelerate that much :p
arun_t 2017-03-09 03:32:19
merijn: why i need IO based operation to handle the mutable state in simple program, & i don't anything about monads?
Athas 2017-03-09 03:32:35
merijn: not a lot of HPC people using Haskell; agreed!
merijn 2017-03-09 03:32:59
I would've loved using Haskell bindings for CUDA, but the existing ones aren't what I'd like
Athas 2017-03-09 03:33:24
What would you like?
arun_t 2017-03-09 03:33:28
merijn: quchen: I'm confuse about choosing b/w a lisp or haskell? to learn
merijn 2017-03-09 03:33:48
Athas: Higher level control flow descriptions and data marshalling
Athas 2017-03-09 03:34:11
arun_t: pick Haskell. I used to be a (Common) Lisp programmer for many years. It's a great language. I switched to Haskell because Lisp is at the top of its power curve. You can't really add anything without first taking something away. On the other hand, Haskell still grows.
merijn 2017-03-09 03:34:20
arun_t: I'd say pick Haskell, because it's more different. I daresay that looking at lisp after haskell will be very easy
c_wraith 2017-03-09 03:34:23
ongy: most lists in Haskell end up being either super-simple so that the overhead of parallel evaluation isn't worth it, or there are evaluation dependencies between consecutive elements so they can't usefully be evaluated in parallel
Athas 2017-03-09 03:34:25
merijn: do you get that in C++ CUDA?
merijn 2017-03-09 03:34:29
arun_t: So if you've skipped list you're not losing much
merijn 2017-03-09 03:34:51
Athas: No, but then I don't have to worry about bindings and potential overhead in the FFI fucking up my benchmarks
quchen 2017-03-09 03:34:57
arun_t: Haskell is the better functional language (with its focus on purity, encapsulating effects, equational reasoning). Lisp's strength is its macro system and that code and data share the same domain, allowing pretty interesting solutions to problems.
bodisiw 2017-03-09 03:35:13
hopefully this is an easy beginner question... i've got an Either String DynamicImage in ghci... what's needed in between to pass it to a (DynamicImage -> Image PixelRGBA8) ?
merijn 2017-03-09 03:35:30
arun_t: IO prevents the mutability leaking into other operations. As for the monad part, it's not really relevant here, since IO would work the same if monads had never been discovered :)
merijn 2017-03-09 03:35:47
bodisiw: You probably want fmap?
bodisiw 2017-03-09 03:36:00
ahh, thanks
merijn 2017-03-09 03:36:14
bodisiw: What do you expect to happen if you get a String instead of an image? That's presumably an error
bodisiw 2017-03-09 03:37:08
merijn, i believe that's correct... since i'm working on ghci, i'd like to ignore it. but really i'm just trying to understand... in a program, i _must_ handle both sides
ongy 2017-03-09 03:37:20
c_wraith: I don't see how the datatype would influence most of that. Provided the spine of the list is easy to compute and the content is the complex stuff
bodisiw 2017-03-09 03:37:29
to satisfy the semantics? like, that's the whole point of it being defined that way?
merijn 2017-03-09 03:38:00
bodisiw: Yes
sshine 2017-03-09 03:38:11
I've got a datatype Foo = Alice | Bob, and I'd like for Show Foo to only show the first letter, so deriving Show does too much. is there any neat way to derive a Show that's based off the default derive?
Cale 2017-03-09 03:38:39
sshine: I wouldn't use show for that...
merijn 2017-03-09 03:38:40
bodisiw: But you can just pattern match "case myResult of Left _ -> putStrLn "Error!"; Right img -> processImage img"
merijn 2017-03-09 03:38:56
bodisiw: I mean, 'fmap' is basically doing the same
sshine 2017-03-09 03:39:08
Cale, I have actually got a little PP type class for it, but can I still derive?
Cale 2017-03-09 03:39:10
sshine: It's usually most convenient for show to produce valid source code for reconstructing values, whenever possible
sshine 2017-03-09 03:39:16
Cale, right!
sshine 2017-03-09 03:39:28
Cale, it's just that while I'm testing, I'm chaining my PP to Show :)
arun_t 2017-03-09 03:39:29
quchen: what is equational reasoning in haskell? merijn: can you explain more about IO use case and monad use case for mutable state?
bodisiw 2017-03-09 03:39:32
nice -- i think i need to understand the sugar and unsugar way... finding it kind of tough to learn both at once
Cale 2017-03-09 03:39:50
Well, you can derive show, and then write your pretty printing function to use the first letter that show gave.
sshine 2017-03-09 03:39:58
hmm, I'll stick with that.
merijn 2017-03-09 03:40:03
bodisiw: What do you mean by sugar? fmap isn't sugar, it's just a function
bodisiw 2017-03-09 03:40:20
'case...of' ?
c_wraith 2017-03-09 03:40:45
ongy: well, compare that to a binary tree. Even if the children are hard to compute and the elements are easy, it parallelizes easily. It's just far more difficult to get data dependencies that mess up parallel evaluation. (spark floods are a different and more likely issue, though, which require some care in a different way)
merijn 2017-03-09 03:40:54
bodisiw: case of is just pattern matching, it's the exact opposite of syntactic sugar :)
bodisiw 2017-03-09 03:41:11
dang! one day i will get this all straight :-)
merijn 2017-03-09 03:41:18
bodisiw: Like, if there's anything in Haskell that is not sugar, but direct mechanical behaviour it's case-of :p
c_wraith 2017-03-09 03:41:39
in Haskell, if/then/else is syntactic suger. :)
merijn 2017-03-09 03:41:47
bodisiw: You're familiar with pattern matching while writing functions, right?
merijn 2017-03-09 03:42:23
bodisiw: The compiler just translates those into case-of expressions
bodisiw 2017-03-09 03:42:32
i've read about guards and such, but cant write them intuitively yet
Cale 2017-03-09 03:42:34
Yeah, one can imagine that at some level, the only reason that anything is ever evaluated is because it is the scrutinee of a case expression which needs to know which constructor matches.
Cale 2017-03-09 03:43:17
(and everything else that does pattern matching or causes evaluation is syntax sugar for case expressions)
bodisiw 2017-03-09 03:44:01
i love this aspect of haskell
bodisiw 2017-03-09 03:44:10
though obviously still struggling with it
Cale 2017-03-09 03:44:27
There is in reality at least one exception to that, because when you have something like seq f y where f is of function type, then you can't cause the function to similarly be evaluated using case
Athas 2017-03-09 03:45:09
A lot of people were upset in the 90s because of that!