Search Haskell Channel Logs

Sunday, March 5, 2017

#haskell channel featuring mbw, athan, barrucadu, dmwit, MarcelineVQ, ertes,

mbw 2017-03-05 13:58:38
How would you think of this in terms of covariant/contravariant? I only know these terms in the context of functors (and coordinate transformations, but that's another thing...). I know that these terms are used in OOP these days as well, but don't know how practically relevant it is.
Tuplanolla 2017-03-05 13:58:40
You can still think of it as implication if you word it "given `Functor`, I can produce `Applicative`", mbw.
athan 2017-03-05 13:59:02
Is there a GHC flag that shows call stacks when exceptions aren't caught?
monochrom 2017-03-05 13:59:20
contravariant on assumptions (such as type class constraints), covariant on return types.
athan 2017-03-05 13:59:21
I've been wrestling with `callStack` and `currentCallStack` to no avail;
mbw 2017-03-05 14:00:00
Could you elaborate on another (or the same) example, please?
mbw 2017-03-05 14:02:47
Regarding contra-/covariance.
monochrom 2017-03-05 14:02:57
I create a Java class "public abstract class M { public Object f(String x); }". You have written your class "public class W { public String f(Object x) ... }". Can you make W a subclass of M?
lyxia 2017-03-05 14:03:35
athan: the runtime option -xc https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/runtime_control.html#rts-flag--xc
monochrom 2017-03-05 14:03:40
This is the OOP kind of covariance and contravariance. Covariant in return type, contravariant in parameter type.
mbw 2017-03-05 14:04:46
Ok, I have never really programmed in Java. So just so that we're on the same page, all types are subtypes of Object in Java, right?
monochrom 2017-03-05 14:04:54
Yes.
mbw 2017-03-05 14:04:54
(C++ background)
mbw 2017-03-05 14:04:56
ok
mbw 2017-03-05 14:06:23
I would think, W can be instantiated as M. W::f() requires an Object, which a String is. It returns a String, which is an Object, which a caller of M::f() requires. Right?
monochrom 2017-03-05 14:06:31
Yes.
mbw 2017-03-05 14:06:44
I don't know what the "::" equivalent in Java is, though :)
Koterpillar 2017-03-05 14:07:05
dot
Koterpillar 2017-03-05 14:07:14
everything is dots
mbw 2017-03-05 14:07:23
Just like in Haskell.
mbw 2017-03-05 14:07:25
:/
monochrom 2017-03-05 14:08:05
Therefore you conclude that, as you go from a superclass method to a subclass method, return type can be subclassed (covariant), parameter type can be superclassed (contravariant).
Koterpillar 2017-03-05 14:08:45
https://i.stack.imgur.com/KjDLw.png
mbw 2017-03-05 14:09:10
Is that terminology rigorous, in the category theory sense? Or is it something like "Functor" used to describe function objects?
monochrom 2017-03-05 14:10:26
rigorous.
dmwit 2017-03-05 14:11:05
I object. Terminology cannot be rigorous.
mbw 2017-03-05 14:12:06
Well, rigorous is probably not the right term to use. There's no "dips" on words. But still, the concept of a Functor in Haskell is not quite the same as in OOP languages, for instance.
mbw 2017-03-05 14:12:22
So, maybe ambiguity is the issue, don't know.
dmwit 2017-03-05 14:12:48
I agree with everything you said there. But I still don't know what your question was. =P
barrucadu 2017-03-05 14:12:51
I don't think there's a general OOP usage of "functor", AFAIK the C++ usage is C++ specific
barrucadu 2017-03-05 14:13:07
Maybe C# also uses the term, I don't know
mbw 2017-03-05 14:13:44
Me only having done OOP in C++ should probably confirm your suspicion then.
barrucadu 2017-03-05 14:14:30
Unfortunately, "functor" means a different things in every language which uses it.
monochrom 2017-03-05 14:14:50
Fortunately there has only been 3.
mbw 2017-03-05 14:14:55
Oh, there are more uses of the word?
monochrom 2017-03-05 14:14:59
err, s/has/have/
dmwit 2017-03-05 14:15:17
I suspect monochrom's third is the way ML uses it.
monochrom 2017-03-05 14:15:18
Damn English. Why bother with singular vs plural, therefore countable vs uncountable
monochrom 2017-03-05 14:15:25
Yeah.
monochrom 2017-03-05 14:15:48
And why bother classifying hair as uncountable.
mbw 2017-03-05 14:16:26
If it's becoming less every day, it has to be countable.
barrucadu 2017-03-05 14:16:39
"hair" is a silly word which refers to two different, but very related, things
barrucadu 2017-03-05 14:16:46
Like many English words I suppose
dmwit 2017-03-05 14:17:07
Let's ditch it and use something sensible. Lojban, perhaps
barrucadu 2017-03-05 14:17:27
An individual hair, in which case it is a count noun; and a large collection of hairs, in which case is it not.
barrucadu 2017-03-05 14:17:30
Silly
mbw 2017-03-05 14:18:03
Am I going to become smarter if I keep staring at "Lojban"?
mbw 2017-03-05 14:18:22
What is that?
barrucadu 2017-03-05 14:18:42
A constructed language which aims to be very logical
monochrom 2017-03-05 14:18:43
If you keep staring at something, you will die. (Tautologically.)
dmwit 2017-03-05 14:19:53
Are dieing and becoming smarter mutually exclusive?
dmwit 2017-03-05 14:20:05
dying
mbw 2017-03-05 14:20:10
You'll find out eventually.
dmwit 2017-03-05 14:20:12
I don't like English, too.
monochrom 2017-03-05 14:20:36
No, not mutually exclusive.
monochrom 2017-03-05 14:21:01
Just want to say something I am more sure of :)
mbw 2017-03-05 14:24:19
Man, Haskell really is a deep rabbit hole. I was looking at some HTTP library tutorials, in order to learn some basics. Then I noted that HTTP (the library) seems to work with [Char]. The nice tutorial of wreq lead me to learn lenses first. Which lead me to...
mbw 2017-03-05 14:24:44
I'm probably doing it wrong.
dmwit 2017-03-05 14:25:08
If you haven't typed `unsafe` into your compiler yet, you're probably not doing it wrong.
dmwit 2017-03-05 14:25:37
It's even possible that you're not doing it wrong even though you have typed `unsafe`.
ertes 2017-03-05 14:26:02
mbw: here is an experiment: try to read an interesting article on wikipedia without following a single link
mbw 2017-03-05 14:26:14
haha
mbw 2017-03-05 14:26:32
You got it. 5 new tabs/min.
mbw 2017-03-05 14:26:51
And I suspect firefox works with [Char] as well...
ertes 2017-03-05 14:27:41
haskell has the same effect
athan 2017-03-05 14:27:52
Y_Y I've used $(deriveJSON defaultOptions ...) with an extremely trivial data type, and it fails the `decode (encode x) == Just x` test. Wut do?
dmwit 2017-03-05 14:28:32
The solution depends on the problem.
monochrom 2017-03-05 14:28:54
I like the Y combinator.
dmwit 2017-03-05 14:29:26
mbw: "nearly 25000 (!!) allocations are made for every keystroke in the Omnibox" https://groups.google.com/a/chromium.org/forum/#!msg/chromium-dev/EUqoIz2iFU4/kPZ5ZK0K3gEJ
athan 2017-03-05 14:29:48
shoot, can I not invoke $(..) splices in GHCi?
monochrom 2017-03-05 14:29:57
haha neat
mbw 2017-03-05 14:31:12
oh man
mbw 2017-03-05 14:32:50
The reasons they give seems to imply that some people have no idea what they're doing
mbw 2017-03-05 14:32:54
*seem
athan 2017-03-05 14:33:13
http://lpaste.net/353250 where did I go wrong? :U
dmwit 2017-03-05 14:33:48
mbw: I have a much more sympathetic interpretation: chromium is a big project, with a lot of people working on it, and none of them can hold the entire project in their head at once.
ertes 2017-03-05 14:34:45
athan: probably nowhere… looks like deriveJSON doesn't handle singleton types properly… look at the JSON produced
ertes 2017-03-05 14:35:05
might be an empty object
barrucadu 2017-03-05 14:36:01
For types of the form `data Foo = Foo`, I have had the generic aeson stuff produce an empty array, rather than an object.
barrucadu 2017-03-05 14:36:15
Which was a little surprising, as I expected an empty object
mbw 2017-03-05 14:36:36
That may be. On the other hand, there are rules of thumb when to use which data structure, when to preallocate memory etc. The problems they describe seem to stem in part from people being used to program in languages with reference semantics, not value semantics. But to be fair, C++ is a beast to tame.
mbw 2017-03-05 14:38:33
On the other hand I am personally frustrated with the memory footprint of popular software these days. I actually tried to use the Atom editor, only to have to hard reset my machine twice.
mbw 2017-03-05 14:38:51
But it looked so nice...
mbw 2017-03-05 14:39:04
Getting off-topic here I guess.
MarcelineVQ 2017-03-05 14:39:28
atom editor itself? or ghc-mod with atom editor?
mbw 2017-03-05 14:40:21
It was probably in combination with haskell-specific plugins.
MarcelineVQ 2017-03-05 14:40:23
just curious because ghc-mod + stack = some amazing oom if you're not careful
mbw 2017-03-05 14:41:38
I did want to try for that reason. While my current vim setup works fine, it requires dicipline. Autocompletion with stack does not always work the way I want it to.
mbw 2017-03-05 14:42:00
With TemplateHaskell stuff, you can just forget about it (Yesod...).