EvanR 2017-01-28 08:45:41
in the future, the latest version of C will specify support for template haskell
EvanR 2017-01-28 08:46:09
this might not be a joke
monochrom 2017-01-28 08:47:51
CPP allows you to use #define and #if
ij 2017-01-28 08:48:31
I've got two irc-clients: 1.0.0.0 from «packages» and 0.4.x.x from stack itself. I tried to put "irc-client >= 1.0.0.0" in .cabal, but "stack ghci" still says it's a hidden package.
ij 2017-01-28 08:48:37
And I thus can't import it.
Lokathor 2017-01-28 08:50:35
fresh stack stakes waaaaaay too long to get going
benneh 2017-01-28 08:51:06
I've heard that using 'Writer String' is inefficient, but I don't understand why. Could anyone point me towards a good explanation of why this is a bad idea?
EvanR 2017-01-28 08:51:30
the monoid for String does ++
reactormonk 2017-01-28 08:51:38
benneh, it's String that sucks - a) linked list b) UTF-32
EvanR 2017-01-28 08:51:58
repeatedly ++ing to the end of an accumulator is really bad in haskell
glguy 2017-01-28 08:51:58
Writer String is inefficient when ++ is inefficient, which is when you have left-nested binds (>>= , >>)
Lokathor 2017-01-28 08:52:41
It seems like usually Writer is kinda a bad move >_>
MarcelineVQ 2017-01-28 08:52:41
Lokathor: at least you're first world internet, there's a fair number of people that can't even get the package list downloaded because it's a git pull and those are all-or-nothing
geekosaur 2017-01-28 08:52:43
ij, extra-deps to override the resolver https://docs.haskellstack.org/en/stable/yaml_configuration/#extra-deps ?
benneh 2017-01-28 08:53:05
But if I have something like 'do {a <- foo; b <- bar a; c <- baz b; quux d}', doesn't that get desugared in a right-associative manner?
boccato 2017-01-28 08:53:14
Is there a standalone warp server?
ij 2017-01-28 08:53:22
geekosaur, Do have them.
EvanR 2017-01-28 08:53:29
Lokathor: well, you can use a monoid type which has efficient appending
glguy 2017-01-28 08:53:53
WriterT has another inefficency issue when you use it to transform a Monad having a strict >>=
Lokathor 2017-01-28 08:54:40
i'll just keep a running state whenever i'd use writer i think
glguy 2017-01-28 08:54:52
state and writer solve quite different problems
Lokathor 2017-01-28 08:55:08
how so?
EvanR 2017-01-28 08:55:17
@undo do {tell "a"; tell "b"; tell "c"; return "d"}
lambdabot 2017-01-28 08:55:17
tell "a" >> tell "b" >> tell "c" >> return "d"
EvanR 2017-01-28 08:55:40
infixl >> 1
EvanR 2017-01-28 08:55:45
er
EvanR 2017-01-28 08:55:47
infixl 1 >>
glguy 2017-01-28 08:56:04
writer is for streaming an output, state is for carrying along/transforming a value
monochrom 2017-01-28 08:56:16
I have doubts about whether it is related to left-nesting binds.
Lokathor 2017-01-28 08:56:40
glguy, but as i understand it, the output thunk gets built up over time and the writer doesn't do it all until the end?
EvanR 2017-01-28 08:56:42
er, >> nestes to the left?
Lokathor 2017-01-28 08:56:44
or is that just some of the time?
monochrom 2017-01-28 08:56:53
OK, I think I see.
benneh 2017-01-28 08:57:01
'do {a <- foo; b <- bar a; c <- baz b; quux c}' gets desugared to 'foo >>= (\ a -> bar a >>= (\ b -> baz b >>= (\ c -> quux c)))', so everything is right-associative, and the resuulting string concatenation should also be right-associative, right?
monochrom 2017-01-28 08:57:21
But you usually use the do-notation which ends up right-nested.
glguy 2017-01-28 08:57:38
Lokathor: The output thunk only gets built up over time if you're forcing the writer to be evaluated by looking at the result rather than the monoid value
Lokathor 2017-01-28 08:58:45
glguy, i think you lost me
glguy 2017-01-28 08:59:03
If the Writer String () value's evaluation is being driven by evaluating the resulting String, then there aren't necessarily any thunks that accumulate
Lokathor 2017-01-28 08:59:04
isn't the monoid value the result?
Lokathor 2017-01-28 08:59:27
hmm
barrucadu 2017-01-28 08:59:29
ij: Could you share the stack.yaml?
glguy 2017-01-28 08:59:46
Lokathor: Here's a program that uses WriterT to stream output https://github.com/glguy/advent2016/blob/master/asmprog-final/Main.hs#L59
glguy 2017-01-28 08:59:51
No thunks are accumulated
ij 2017-01-28 08:59:59
barrucadu, http://sprunge.us/fNWi Here it is.
barrucadu 2017-01-28 09:01:34
ij: I don't think you also need the entry in extra-deps given you have the path in packages.
Lokathor 2017-01-28 09:01:36
glguy, golly am i lost
glguy 2017-01-28 09:02:30
> take 10 $ execWriter $ forever $ tell [ () ]
lambdabot 2017-01-28 09:02:32
[(),(),(),(),(),(),(),(),(),()]
geekosaur 2017-01-28 09:02:41
one or the other but not both, likely. I would expect the extra-deps one to be needed as people who put newer packages in packages instead of extra-deps find the newer one ignored in favor of the resolver (per past debuggings here)
glguy 2017-01-28 09:02:57
Lokathor: See how that 'forever $ tell [ () ]' didn't need to run forever?
Lokathor 2017-01-28 09:03:04
ah ha
glguy 2017-01-28 09:03:19
evaluation of that infinite loopy thing was driven only as far as needed to produce 10 outputs
glguy 2017-01-28 09:03:31
You can't do that with State
Lokathor 2017-01-28 09:03:36
so it's lazyness at work
glguy 2017-01-28 09:04:05
No thunks were accumulated because evaluation only proceeded when output was needed
ij 2017-01-28 09:04:15
barrucadu, https://asciinema.org/a/bc68kw1hwfk0zfy9drlkzz4kl
Lokathor 2017-01-28 09:04:54
so the one time i wanted to maybe use writer, it was for an FOV thing
Lokathor 2017-01-28 09:05:08
where you're building an output Set (Int, Int) of places that can be seen
glguy 2017-01-28 09:05:32
Now if we'd do: runWriter $ forever $ tell [ () ]
Lokathor 2017-01-28 09:05:33
but, as i recall, it ran a lot slower than unrolling it all by hand, so i went with the fast version
glguy 2017-01-28 09:05:51
We wouldn't be evaluating that [()] to drive the computation
Lokathor 2017-01-28 09:05:53
:t runWriter
lambdabot 2017-01-28 09:05:55
Writer w a -> (a, w)
Lokathor 2017-01-28 09:06:02
:t execWriter
lambdabot 2017-01-28 09:06:04
Writer w a -> w
glguy 2017-01-28 09:06:13
If we tried to inspect the 'a' there things wouldn't terminate
glguy 2017-01-28 09:06:26
and we'd accumulate thunks of [()] trying
glguy 2017-01-28 09:06:55
even if it wasn't 'forever', but just replicateM 1000
nitrix 2017-01-28 09:07:05
How do I turn a `Storable a => a` into `Storable a => Ptr a` for a foreign C library?
glguy 2017-01-28 09:07:25
we'd accumulate thunks by allowing evaluation to be driven by evaluation of the 'a'
nitrix 2017-01-28 09:07:46
isWhatImAfter :: Storable a => a -> IO (Ptr a)
Lokathor 2017-01-28 09:08:17
hmm
Lokathor 2017-01-28 09:08:34
I don't recall that most Writer documentation has explained this detail a lot
monochrom 2017-01-28 09:08:50
But see my http://lpaste.net/41790/ for how to write infinite loops correctly in State
nitrix 2017-01-28 09:08:59
So I absolutelly need malloc + poke?
Lokathor 2017-01-28 09:09:38
modify (() :)
Lokathor 2017-01-28 09:09:40
such a happy line
barrucadu 2017-01-28 09:09:57
ij: Those ambiguous type variable errors in Network.IRC.Client.Lens are interesting. Have you modified the code at all? That module shouldn't be getting built with OverloadedStrings.
glguy 2017-01-28 09:10:09
Yeah, a lazy State with left-nested recursion can produce values
barrucadu 2017-01-28 09:10:11
ij: I suspect it's failing to find the module because it's failing to compile the package
benneh 2017-01-28 09:12:46
If I've understood correctly, 'Writer String' is fine as long as your binds are right-associative, and ordinary do notation desugars into right-associative binds. It's only if you do something like 'm >>= f >>= g >>= h' where they left-associate, and inefficiecies can arise. Is that correct?
glguy 2017-01-28 09:13:12
and if evaluation of the Writer e a value is driven by evaluation of the e, not the a
benneh 2017-01-28 09:14:44
Yes, assuming that the 'written' value is the thing that you actually care about.
benneh 2017-01-28 09:14:53
Lots of the time, a = () anyway.
glguy 2017-01-28 09:17:27
Or in the case where you can produce the output without accumulating any values along the way
glguy 2017-01-28 09:17:29
> fst $ runWriter $ forever (tell [()]) >> return "X"
lambdabot 2017-01-28 09:17:31
"X"
glguy 2017-01-28 09:19:08
> let (a,xs) = runWriter $ forever (tell [()]) >> return "X" in (a, take 10 xs)
lambdabot 2017-01-28 09:19:10
("X",[(),(),(),(),(),(),(),(),(),()])
ij 2017-01-28 09:20:23
barrucadu, No, haven't done anything. It builds quickly, when I changed it to lts-7.17 to not have everything get rebuilt.
glguy 2017-01-28 09:20:23
and then how you can pull on the output is going to depend on the behavior of mappend on your particular Monoid
glguy 2017-01-28 09:20:33
some of them are strict in the second argument, some in the first
glguy 2017-01-28 09:20:45
so yeah, it depends :)
benneh 2017-01-28 09:21:42
Ok, thanks, that clears some things up for me :)
buglebudabey 2017-01-28 09:22:01
could someone help me figure out why Hakyll my page won't render LaTeX? here is the page in question: https://aneksteind.github.io/posts/2015-08-12-spqr.html and here is my configurations... http://lpaste.net/8724984057596739584 .... and my default.html....http://lpaste.net/3152207555166470144
barrucadu 2017-01-28 09:22:07
ij: Then I'm at a bit of a loss, I'm not sure why that module would be built with OverloadedStrings. You could just remove the HLint annotation and see if it works then.
MarcelineVQ 2017-01-28 09:22:27
ij: things in your pacakge section need an extra-dep: true flag if they're just a dependancy and not physically part of your project, or stack mixes stuff up wrt flags and such.
MarcelineVQ 2017-01-28 09:23:03
https://docs.haskellstack.org/en/stable/yaml_configuration/#local-dependency-packages-extra-dep
ij 2017-01-28 09:23:54
MarcelineVQ, BAM, solved!
MarcelineVQ 2017-01-28 09:23:56
also things listed in your packages section shouldn't also be listed in the extra-deps section
MarcelineVQ 2017-01-28 09:24:29
allthough I'm not sure if that's actually a problem, just good practice
byorgey 2017-01-28 09:26:28
buglebudabey: and what was the source from which that page was generated?
buglebudabey 2017-01-28 09:27:09
byorgey by guessing what you mean i'm going to say that it was generated using github pages using the html my build generated
myname_ 2017-01-28 09:27:24
Hi all!
buglebudabey 2017-01-28 09:27:31
byorgey firefox returned this error in the log: Blocked loading mixed active content "http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"
byorgey 2017-01-28 09:27:44
buglebudabey: sorry, I mean can you paste or link to the file with the page content (e.g. is it a .markdown file?)
buglebudabey 2017-01-28 09:28:09
byorgey it is a markdown file, sure i'll paste the content
byorgey 2017-01-28 09:28:12
buglebudabey: oh, interesting. I have never seen that error before
kadoban 2017-01-28 09:28:31
buglebudabey: That sounds like your page is on HTTPS and you're trying to load a script from HTTP, which is generally disallowed
byorgey 2017-01-28 09:28:34
I get that same error
buglebudabey 2017-01-28 09:29:08
kadoban do you happen to know the way around that? i'd rather keep my site https obviously
byorgey 2017-01-28 09:29:16
aha, so maybe change the URL for MathJax to use https
buglebudabey 2017-01-28 09:29:25
byorgey it's just this: http://lpaste.net/351746
kadoban 2017-01-28 09:29:37
How are you including that link? Is it automatic? Yeah it just needs to be HTTPS most likely.
byorgey 2017-01-28 09:30:25
buglebudabey: did you see kadoban's comment above? try changing the MathJax link to https://
buglebudabey 2017-01-28 09:30:36
byorgey about to try that
buglebudabey 2017-01-28 09:38:13
github isn't building the page for some reason so let me fix that then i'll report back
buglebudabey 2017-01-28 09:40:12
byorgey it works! https://aneksteind.github.io/posts/2015-08-12-spqr.html, the https change worked
buglebudabey 2017-01-28 09:40:15
thanks kadoban
kadoban 2017-01-28 09:40:41
Yay, 'welcome
bandershas 2017-01-28 09:43:17
Hey all, a newcomer here! A question: do you have any 'good' resources on typeclasses, polymorphism and instances in haskell? I finally understood monads and can use them in practice. Thanks :)
buglebudabey 2017-01-28 09:43:45
bandershas https://wiki.haskell.org/Typeclassopedia
monochrom 2017-01-28 09:44:18
SPQR?!
bandershas 2017-01-28 09:45:00
That's a rich resource, thanks :)