Search Haskell Channel Logs

Monday, February 20, 2017

#haskell channel featuring S11001001, monochrom, buttons840, mpiechotka, Cooler, Axman6,

buttons840 2017-02-20 17:46:35
do typeclass laws have any significance in the language itself, or is it just that the author of the typeclass is saying "the functions that use my typeclass assume these laws are true, and if you violate them, the functions may fail"
barrucadu 2017-02-20 17:46:51
The latter
Axman6 2017-02-20 17:47:22
there's no mechanism to enforce laws
Axman6 2017-02-20 17:47:46
so if you break them you go to bad code jail, but the compiler can't tell you you've broken them
buttons840 2017-02-20 17:48:27
i heard they only allow intercal and malbolge in bad code jail?
barrucadu 2017-02-20 17:49:19
If you rbeak the law, the code police will come to take you away
barrucadu 2017-02-20 17:49:22
*break
Axman6 2017-02-20 17:49:43
there are no computers in bad code jail
Axman6 2017-02-20 17:49:51
you can code on paper only
johnw 2017-02-20 17:50:17
you can code in binary, but only where space = 0 and tab = 1
barrucadu 2017-02-20 17:50:19
If you're good they'll let you use an infinite number of rocks and a flat plane for one afternoon a week.
buttons840 2017-02-20 17:50:59
an infinite number of rocks sounds like a good power source, we should be using for better things
Koterpillar 2017-02-20 17:51:13
infinite != unlimited
buttons840 2017-02-20 17:51:14
we can travel through space with that
Koterpillar 2017-02-20 17:51:53
an infinite number of rocks has infinite gravity, that seems dangerous
barrucadu 2017-02-20 17:52:10
Koterpillar: That's why nobody gets out of bad code jail.
buttons840 2017-02-20 17:53:03
so similar to breaking typeclass laws -- i've always thought that unsafePerformIO is ok as long as the surrounding function behaves like a pure function -- because if you break the purity the compiler or other code will probably not do what you want -- is this a good way to think of it?
barrucadu 2017-02-20 17:54:31
Generally you shouldn't be breaking laws or using unsafe IO, but occasionally situations do crop up where it's the right thing to do. But then the burden is on you the programmer to make sure nothing goes funky.
S11001001 2017-02-20 17:54:32
buttons840: related: with enough stuff in the language, you can push all the laws down into members, e.g. https://github.com/idris-lang/Idris-dev/blob/v0.99/libs/contrib/Interfaces/Verified.idr#L16-L20 This may be inconvenient, though.
barrucadu 2017-02-20 17:55:35
For example, the Par monad uses unsafe IO to make use of actual concurrency, but as it only lets you write deterministic computations, that's fine.
Cooler 2017-02-20 18:00:46
hey what happens with (+1) <$> [1..10] <*> [1,2,3,4] ?
Cooler 2017-02-20 18:01:12
hey what happens with (+) <$> [1..10] <*> [1,2,3,4] ?
johnw 2017-02-20 18:01:19
every combination
Cooler 2017-02-20 18:01:21
not (+1)
Cooler 2017-02-20 18:01:28
oh right
buttons840 2017-02-20 18:25:03
about catch: "Furthermore it is possible to accidentally stay inside the implicit mask by tail-calling rather than returning from the handler..." -- what does it mean to "return" in Haskell? I'm a little fuzzy because most of the time it feels like a haskell program is just one big expression being evaluated
monochrom 2017-02-20 18:27:37
But IO is where you go back to imperative programming and you actually have control flow.
monochrom 2017-02-20 18:28:49
My http://www.vex.net/~trebla/haskell/exception-tutorial.xhtml#catch has a simple example of how to wrongly stay inside the mask forever.
buttons840 2017-02-20 18:29:49
so, simplest the Control.Exception docs reommends using try instead of catch wherever possible, did I intepret that right?
buttons840 2017-02-20 18:30:11
the Control.Exception docs reommends using try instead of catch wherever possible, did I intepret that right?
Cooler 2017-02-20 18:35:04
is this over complicated? http://lpaste.net/352802
johnw 2017-02-20 18:36:28
I'm not sure your Applicative is what you mean
johnw 2017-02-20 18:37:02
don't you want: Cons f fs <*> Cons x xs = Cons (f x) (fs <*> xs)
johnw 2017-02-20 18:37:20
which is equivalent to ZipList
johnw 2017-02-20 18:37:25
but not to the applicative for []
Cooler 2017-02-20 18:37:47
johnw, what?
mpiechotka 2017-02-20 18:37:53
Hi. I have a Lens s t [a] [b]. I try to traverse over it with index. How can I do it using lenses combinators?
Cooler 2017-02-20 18:38:13
no its an exercise to write the list applicative
Cooler 2017-02-20 18:38:17
not ziplist
johnw 2017-02-20 18:38:31
Cooler: then your Nil <*> _ rule needs to change
johnw 2017-02-20 18:38:34
and _ <*> Nil
Cooler 2017-02-20 18:38:42
why?
mpiechotka 2017-02-20 18:38:59
(I try to somehow get IndexedTraversal but I fail to figure out the type zoo)
johnw 2017-02-20 18:39:33
Cooler: hmm.. maybe not
johnw 2017-02-20 18:41:29
Cooler: no, you're fine
johnw 2017-02-20 18:41:42
sorry for the confusion, my mental checker was off