Search Haskell Channel Logs

Thursday, February 9, 2017

#haskell channel featuring wamaral, Sibi__, cocreature, tsahyt, Tuplanolla, monochrom, and 7 others.

zipper 2017-02-09 08:47:12
cocreature: Are there prerequisites I should care about before looking at the Writer Monad?
zipper 2017-02-09 08:47:15
It seems there are
cocreature 2017-02-09 08:47:33
zipper: just pretend that it doesn't exist and don't use it :)
monochrom 2017-02-09 08:48:14
But then they won't understand my sentence.
cocreature 2017-02-09 08:48:50
well you can take a look at it, it's simple enough
MarcelineVQ 2017-02-09 08:49:07
dohoho, iirc glguy had a neat use for it for one of his advent challenges so it may be worth asking him about it related code somewhere within https://github.com/glguy/advent2016/tree/22525949821ba209465471796803c213abd00d15/asmprog-final
zipper 2017-02-09 08:49:56
monochrom: Yeah I want to use it :)
zipper 2017-02-09 08:50:03
cocreature: I do want to use it
zipper 2017-02-09 08:50:09
For this one purpose
cocreature 2017-02-09 08:50:55
zipper: if you are familiar with State, Reader and so on, I would recommend to just look at the source. there is very little magic going on
cocreature 2017-02-09 08:51:21
zipper: https://hackage.haskell.org/package/transformers-0.5.2.0/docs/src/Control.Monad.Trans.Writer.Strict.html#WriterT
cocreature 2017-02-09 08:51:52
the interesting part are the Applicative and Monad instances
cocreature 2017-02-09 08:53:48
but apart from learning purposes I really don't recommend it. if you have a constant size monoid (e.g. Sum Int) you want it to be strict and if you have something that grows (e.g. logs represented as [Text]) you typically want to stream the results instead of accumulating all of them first
zipper 2017-02-09 08:53:51
hmmm thanks :grin:
zipper 2017-02-09 08:54:16
to stream the results?
zipper 2017-02-09 08:54:20
Like pipes?
zipper 2017-02-09 08:54:32
It would be a bytestring I think
cocreature 2017-02-09 08:55:01
zipper: yeah, http://www.haskellforall.com/2014/02/streaming-logging.html has an example that illustrates the problem with using Writer for logging and shows the pipes based solution
zipper 2017-02-09 08:56:47
cocreature: Thanks a ton :)
zipper 2017-02-09 08:56:53
Gonna have a look
tsahyt 2017-02-09 08:57:10
has anyone ever integrated an AFRP framework with GTK?
tsahyt 2017-02-09 08:57:44
hmm apparently yampasynth uses gtk, that might be worth a look
tsahyt 2017-02-09 08:58:50
ah, but it seems to not actually tie in the gtk events into yampa
MarcelineVQ 2017-02-09 08:59:38
" bitemyapp: Give us the Writer monad :P" Writer is in that book zipper, it's just later on when you're taking about transformers
mniip 2017-02-09 09:02:14
dear CT overlords I summon thee
monochrom 2017-02-09 09:02:45
You know the overlords are in ##categorytheory right?
mniip 2017-02-09 09:02:56
that's usually silent :v
monochrom 2017-02-09 09:03:00
Or is that ##category?
mniip 2017-02-09 09:03:18
the latter does not exist
mniip 2017-02-09 09:04:29
I have strong evidence that the end of hom in Grp is the Z groupoid but I can't prove the universality...
wamaral 2017-02-09 09:20:50
If you don't mind slack, there's a #categorytheory channel on the functionalprogramming slack that gets pretty good activity
mniip 2017-02-09 09:23:06
considering I'm not using slack for anything it's pretty unlikely to gain any traction in my workflow :(
sternmull 2017-02-09 09:23:51
is it possible to write a zipNWidth function? I mean something that takes a tuple (of any size) of lists and applies a function to each tuple of nth elements.
wamaral 2017-02-09 09:24:45
oh well I use the IRC bridge so it feels like another server, but I'm not a big fan either
monochrom 2017-02-09 09:26:32
mniip: slack is not for workflow. This is because slack is for competing with IRC, and IRC is not for workflow either. If anything, both are for anti-workflow :)
monochrom 2017-02-09 09:27:38
IRC was my anti-workflow when I tried to work on my PhD
nshepperd_ 2017-02-09 09:28:13
sternmull: you'll need a typeclass
Tuplanolla 2017-02-09 09:29:06
These type classes, sternmull: https://hackage.haskell.org/package/lens-4.15.1/docs/Control-Lens-Tuple.html
sternmull 2017-02-09 09:29:14
nshepperd_: Thanks for that keyword. I think with my current knowledge i would be unable to express such a function.
monochrom 2017-02-09 09:30:23
You can't express its type to begin with.
sternmull 2017-02-09 09:31:17
Tuplanolla: Hm looks useful, but this is limited to nine fields.
Tuplanolla 2017-02-09 09:31:39
You're doing something rather questionable if nine isn't enough, sternmull.
ph88 2017-02-09 09:32:49
hey guys, when i have structures like Foo (Wrap T) (Bar (Wrap T)) (Wrap (Qux T)) and i want to modify the last T what would be a good technique to use ?
sternmull 2017-02-09 09:33:02
Tuplanolla: Not necessarily. It could be useful to write code that is completely generic and does not care how long the tuple is. In C++ templates can have integers as type parameters.
monochrom 2017-02-09 09:33:04
Add your own instances if you want 10 fields.
Tuplanolla 2017-02-09 09:33:13
More lenses, ph88. Lenses for everybody.
ph88 2017-02-09 09:33:44
Tuplanolla, what specific part of lenses? i think i would something generic no ?
Tuplanolla 2017-02-09 09:34:41
You'd `makeLenses` for each and let `lastT = qux . wrap`.
cocreature 2017-02-09 09:34:44
ph88: are these types or constructors? I think you need to give us a bit more information, i.e. show us the types and the constructors used here
ph88 2017-02-09 09:35:16
those are the types !
Tuplanolla 2017-02-09 09:35:22
Then `over lastT f x` where `f` is a function and `x` is some `Foo`.
ph88 2017-02-09 09:36:01
data Wrap a = W a data T = MakeT StuffHere
Tuplanolla 2017-02-09 09:36:47
You'd have `data Wrap a = W {_wrap :: a}` etc.
Sibi__ 2017-02-09 09:36:51
Am I missing something or is the type of `e` should be `Q Exp` in this old proposal: https://mail.haskell.org/pipermail/ghc-devs/2015-September/009838.html
ph88 2017-02-09 09:37:18
Tuplanolla, wouldn't this lastT = qux . wrap only work when you have a Qux and then a Wrap ?
Tuplanolla 2017-02-09 09:37:39
Well, yes, it would become a `Traversal`, ph88.
ph88 2017-02-09 09:38:02
so hhmm then i would have to implement this function like 200 times ?
Tuplanolla 2017-02-09 09:38:11
I don't follow.
ph88 2017-02-09 09:38:37
well if one structure has (Wrap (Qux T)) you want to use lastT = qux . wrap yes ?
ph88 2017-02-09 09:39:27
next structure has maybe [(Maybe T)] so i need a lastT = last . (\Just x -> x) ?
ph88 2017-02-09 09:39:57
that would be my backup plan ^^
cocreature 2017-02-09 09:40:34
ph88: do you want to map the T to a new T or do you want to change that type parameter as well?
cocreature 2017-02-09 09:40:42
in the first case, you can use biplate
ph88 2017-02-09 09:40:57
i want to change the value of T, and not change the type
cocreature 2017-02-09 09:41:43
:t transformBi
lambdabot 2017-02-09 09:41:44
error:
lambdabot 2017-02-09 09:41:44
• Variable not in scope: transformBi
lambdabot 2017-02-09 09:41:44
• Perhaps you meant one of these:
cocreature 2017-02-09 09:42:10
ph88: take a look at transformBi here https://hackage.haskell.org/package/uniplate-1.6.12/docs/Data-Generics-Uniplate-Operations.html
ph88 2017-02-09 09:42:19
i know it
ph88 2017-02-09 09:42:38
just not sure if it's a good fit
ph88 2017-02-09 09:43:22
ok well thanks guys for thinking along
tsahyt 2017-02-09 09:44:09
is there a way to have stack add extra-deps as it recommends automatically?
MarcelineVQ 2017-02-09 09:44:44
stack solver --update-config
tsahyt 2017-02-09 09:44:56
hmm that crashes with cabal errors
tsahyt 2017-02-09 09:45:03
failed to parse output of 'ghc-pkg dump'