bollu 2017-02-18 10:45:17
lalalala: :)
lalalala 2017-02-18 10:45:19
thanks tho!
bollu 2017-02-18 10:45:29
lalalala: just to clarify, return is not the same as the usual return in other languages
bollu 2017-02-18 10:45:37
lalalala: I hope you are aware of that? :)
tom7942 2017-02-18 10:46:14
doesn't matter; program works
lalalala 2017-02-18 10:46:23
bollu: it's do bracket specific or?
bollu 2017-02-18 10:46:23
tom7942: :P
bollu 2017-02-18 10:46:34
lalalala: return is just another function in haskell
bollu 2017-02-18 10:46:36
:t return
lambdabot 2017-02-18 10:46:37
Monad m => a -> m a
bollu 2017-02-18 10:46:41
lalalala: it's not a language inbuilt
bollu 2017-02-18 10:46:48
lalalala: yes, it's closely related to monads
monochrom 2017-02-18 10:47:00
Consider do { x <- return 5; print x }
bollu 2017-02-18 10:47:48
> do { x <- return 4; y <- return 3; return 2; print x; }
lambdabot 2017-02-18 10:48:44
lalalala 2017-02-18 10:48:44
x will return a 5 of type IO Int or?
bollu 2017-02-18 10:48:44
well fuck
monochrom 2017-02-18 10:48:44
Run it on your computer.
bollu 2017-02-18 10:48:44
I was hoping lambdabot would strip the IO
bollu 2017-02-18 10:48:44
would print the output*
monochrom 2017-02-18 10:48:44
lambdabot doesn't want to get into security trouble, that's all.
bollu 2017-02-18 10:48:44
> do { return 2; return 3 }
lalalala 2017-02-18 10:48:44
oh it :t is IO ()
lambdabot 2017-02-18 10:48:44
error:
lambdabot 2017-02-18 10:48:44
• Ambiguous type variables 'm0', 'b0' arising from a use of 'show_M67005...
lambdabot 2017-02-18 10:48:44
prevents the constraint '(Show (m0 b0))' from being solved.
lalalala 2017-02-18 10:48:44
ops...
bollu 2017-02-18 10:48:44
> do { return 2; return 3 } :: IO Int
lambdabot 2017-02-18 10:48:44
bollu 2017-02-18 10:48:44
-_-
bollu 2017-02-18 10:48:44
> do { return 2; return 3 } :: Maybe Int
lambdabot 2017-02-18 10:48:44
Just 3
bollu 2017-02-18 10:48:44
lalalala: ^ (if you know that Maybe is a monad)
lalalala 2017-02-18 10:48:53
no, i still don't get the concept of monads tbh
bollu 2017-02-18 10:48:59
lalalala: OK
tom7942 2017-02-18 10:49:10
lalalala: how about a functor?
tom7942 2017-02-18 10:49:27
> :t fmap
lambdabot 2017-02-18 10:49:30
lalalala 2017-02-18 10:49:43
sorry no
tom7942 2017-02-18 10:49:58
lalalala: how about map?
lalalala 2017-02-18 10:50:00
yeye
bollu 2017-02-18 10:50:03
lalalala: personal suggestion that people may disagree with: forget trying to understand "what a monad is". Start using haskell. You will find problems for which you will need a particular function with a particular type (usually >>= or >>). Then, just use the function. Till you get a feeling for what is happening.
monochrom 2017-02-18 10:51:00
I actually agree.
tom7942 2017-02-18 10:51:00
ok, so fmap is like map, only for generic structure.
tom7942 2017-02-18 10:51:00
map is fmap specialized to list structure
tom7942 2017-02-18 10:51:00
list is one kind of functor
tom7942 2017-02-18 10:51:07
a tree could be another kind
monochrom 2017-02-18 10:51:20
You have always used natural numbers to count money and you still don't know rings and fields and even the Peano axioms. This is normal.
lalalala 2017-02-18 10:51:52
tom7942: a functor of originally what?
bollu 2017-02-18 10:51:52
monochrom: I wonder if bourbaki had decided to setup a school, whether the opposite would have happened :P
Tuplanolla 2017-02-18 10:51:55
I'm not sure this is going to be helpful, tom7942.
tom7942 2017-02-18 10:52:07
ok
bollu 2017-02-18 10:52:15
tom7942: but please do try
tom7942 2017-02-18 10:52:42
lalalala: oh, a functor of whatever the type inside the list is
elperdut 2017-02-18 10:52:43
Tuplanolla, I am anxious to see an explanation. I have sort of an intuition about this now, but the more I hear/read about it the better.
lalalala 2017-02-18 10:52:55
hm okey
monochrom 2017-02-18 10:52:59
bollu: I can imagine that. Because there was a time I wanted that too. (Later saw how wrong it was.) And I also observe that many math enthusiasists tend to think like that.
bollu 2017-02-18 10:53:01
elperdut: for Functor? or Monad?
elperdut 2017-02-18 10:53:08
functor
tom7942 2017-02-18 10:53:10
lalalala: this is what I meant about lifting over structure
bollu 2017-02-18 10:53:16
monochrom: oh no, I don't think that will work
bollu 2017-02-18 10:53:24
monochrom: like, abstract to concrete is the way we learn in most cases
Tuplanolla 2017-02-18 10:53:27
For sure, but our original goal was performing `IO`, elperdut.
bollu 2017-02-18 10:53:31
monochrom: but it would be.. interesting
tom7942 2017-02-18 10:53:31
you have a list of values, you want to do something to them
tom7942 2017-02-18 10:53:39
so you map a function onto the list
elperdut 2017-02-18 10:53:47
this is what gave me (what i think) is my aha moment - https://blog.jle.im/entry/inside-my-world-ode-to-functor-and-monad.html
tom7942 2017-02-18 10:53:49
the function you map knows nothing about the list
monochrom 2017-02-18 10:55:00
"Wouldn't it be nice if kindergarten begins with category theory, primary school does universal algebra, secondary school does fields and rings, university undergrad does complex numbers... and finally when you go for a PhD you will finally see how to multiply natural numbers"
elperdut 2017-02-18 10:55:00
you sort of inject the code for "how to handle the structure", that's why the function doesn't need to know it. right?
bollu 2017-02-18 10:55:00
lol
tom7942 2017-02-18 10:55:00
yeah the functor is only interesting because it's a superclass of monad
tom7942 2017-02-18 10:55:00
so we're rewinding a few steps
elperdut 2017-02-18 10:55:00
ok good. i'll be quiet.
tom7942 2017-02-18 10:55:03
no, speak up please
tom7942 2017-02-18 10:55:24
elperdut: so the functor is the thing that knows how to handle the structure
bollu 2017-02-18 10:55:25
monochrom: do you know a natural class of Profunctor examples?
tom7942 2017-02-18 10:55:37
so your list functor knows how to process each element in the list structure
monochrom 2017-02-18 10:55:38
No. I haven't studied Profunctors.
bollu 2017-02-18 10:55:45
monochrom: OK
bollu 2017-02-18 10:55:58
monochrom: do you know lens' internals by any chance?
tom7942 2017-02-18 10:56:00
the tree functor does the same for tree strutures
monochrom 2017-02-18 10:56:04
Neither.
bollu 2017-02-18 10:56:09
monochrom: hm, OK :)
Cale 2017-02-18 10:56:33
bollu: What kind of thing are you looking for?
elperdut 2017-02-18 10:56:34
check out the small paragraph in the "Can I have a lift?" section of the article I posted by Justin Le
Cale 2017-02-18 10:56:34
bollu: What's a "natural class"?
bollu 2017-02-18 10:56:34
Cale: in the Profunctor case, some natural set of examples. Something akin to Sn or dihedral in groups
Cale 2017-02-18 10:56:38
ah
elperdut 2017-02-18 10:56:40
btw, do you guys think Justin Le is ever in this channel? he's freakin' awesome
bollu 2017-02-18 10:56:49
Cale: is there such a thing?
tom7942 2017-02-18 10:56:56
lift isn't a precise term, but we use it anyways
bollu 2017-02-18 10:57:10
tom7942: one can make it precise, though
monochrom 2017-02-18 10:57:12
would that be jle` ?
Cale 2017-02-18 10:57:22
Well, Hom functors are the most obvious ones.
tom7942 2017-02-18 10:57:26
sure, in haskell :)
bollu 2017-02-18 10:57:58
Cale: right :)
bollu 2017-02-18 10:58:16
Cale: can I have 2 more examples?
lalalala 2017-02-18 10:58:19
oh I got another question
Cale 2017-02-18 10:58:19
and Hom functors which have been composed with some other things in various ways
bollu 2017-02-18 10:58:19
Cale: such as?
lalalala 2017-02-18 10:58:25
I wanted to use a web framework to get input from a html form, is that possible to do?
bollu 2017-02-18 10:58:42
lalalala: yes, it is
Cale 2017-02-18 10:58:50
I mean like Hom(F(-), G(-)) for some appropriately typed functors F and G
bollu 2017-02-18 10:59:11
Cale: hm
lalalala 2017-02-18 10:59:15
bollu: can you recommend any specific web framework?
bollu 2017-02-18 10:59:18
Cale: what's a concrete example?
bollu 2017-02-18 10:59:29
lalalala: I have played around with Yesod and Snap. I like Snap as it is easy to start with
bollu 2017-02-18 11:00:23
lalalala: but I don't know what the space is like, currently :) take what I say with a grain of salt
mniip 2017-02-18 11:00:34
1487455000 [00:56:40] btw, do you guys think Justin Le is ever in this channel? he's freakin' awesome
mniip 2017-02-18 11:00:36
his nick is jle`
elperdut 2017-02-18 11:00:48
cool, thanks mniip
lalalala 2017-02-18 11:00:55
bollu: thanks
bollu 2017-02-18 11:01:15
Cale: of the Hom(F(-), G(-))?
lalalala 2017-02-18 11:01:20
bollu: can i use a apache or nginx host or are they based on something else?
tom7942 2017-02-18 11:01:42
lalalala: scotty?
tom7942 2017-02-18 11:02:16
apache is C
Cale 2017-02-18 11:02:23
Oh, here's another: suppose we just take some arbitrary sets A and B, and consider them as discrete categories. Then relations R: A -> B can be seen as profunctors P: A -/-> B where if R(a,b) then P(a,b) = {*} (some one-element set) and otherwise P(a,b) = {}
lalalala 2017-02-18 11:02:42
tom7942: wat
hpc 2017-02-18 11:02:48
lalalala: you're writing your own webserver, with those libraries compiled in
hpc 2017-02-18 11:02:52
it's a different model from cgi
hpc 2017-02-18 11:03:03
or mod_foo
Cale 2017-02-18 11:03:04
and then composition of profunctors corresponds to composition of relations
lalalala 2017-02-18 11:03:15
hpc: okey, but I mean if I want to put it on a host, I'd have to run a VPS or something then, since most hosts are based on other things?
tom7942 2017-02-18 11:03:19
lalalala: http://hackage.haskell.org/package/scotty
kr_ 2017-02-18 11:03:37
lalala: most haskell web frameworks provide an integrated server and/or a wai interface (which is like wsgi for python)
bollu 2017-02-18 11:03:39
Cale: where is the co/contra variance?
Cale 2017-02-18 11:03:51
bollu: I dunno, just pick basically any pair of functors which would go there.
kr_ 2017-02-18 11:04:02
lalalala: you then either reverse proxy, or use a wai web server
Cale 2017-02-18 11:04:05
and stick ^op on things to make it work out
tom7942 2017-02-18 11:04:13
bollu and Cale are having a higher order conversation here
lalalala 2017-02-18 11:04:56
thanks for the info
bollu 2017-02-18 11:06:58
Cale: what are the arrows in your sets-as-categories A and B?
Cale 2017-02-18 11:07:03
lalalala: Basically any of the Haskell web servers will be able to do that. Scotty is one of the more lightweight ones. Snap will also do. I would be surprised if happstack-server didn't also do it.
Cale 2017-02-18 11:07:15
bollu: Just the identities
lalalala 2017-02-18 11:07:15
Cale: alright
bollu 2017-02-18 11:07:35
Cale: oh
AWizzArd 2017-02-18 11:10:29
In the dependency section of my .cabal file I listed , list-extras but also tried list-extracs >= 0.4.1.4 but „stack list-dependencies" only shows me „list-extras ".
AWizzArd 2017-02-18 11:10:38
How can I add it, so I can make use of argmax?
Cale 2017-02-18 11:12:54
AWizzArd: What's the problem you're having?
AWizzArd 2017-02-18 11:14:30
Cale: I am using Intero (Emacs). I want to call argmax, to find the triple (a,b,Int) where the third element is the maximum of a list of such triples.
AWizzArd 2017-02-18 11:14:58
It seems that argmax is good for that. I've added it as a dependency, the same way as I did it before with other libs.
AWizzArd 2017-02-18 11:15:54
Now however when I restart Intero, it tells me that there was a problem. And as mentioned above `stack list-dependencies` does say version , while all other deps are listed with a concrete version number.
bollu 2017-02-18 11:17:27
Cale: P :: A^op x B -> Set right?
bollu 2017-02-18 11:17:32
Cale: in your example?
bollu 2017-02-18 11:17:37
Cale: I am unfamiliar with the P: A -/-> B notation
Cale 2017-02-18 11:19:01
bollu: yes
Cale 2017-02-18 11:19:36
AWizzArd: You could also just use maximumBy (comparing (\(x,y,z) -> z))
lalalala 2017-02-18 11:19:48
can I somehow avoid the duplicates of r0 and r1 in this function? https://gist.github.com/freddedotme/64fc391ffaa2e7fb11a3f02f93ddfa88
Cale 2017-02-18 11:20:13
AWizzArd: I'm not sure, I've never tried intero.
Rembane 2017-02-18 11:20:29
lalalala: By using MonadRandom.
dolio 2017-02-18 11:20:29
I think it's B^op × A if you want to get super technical.
bollu 2017-02-18 11:20:39
dolio: really?
lyxia 2017-02-18 11:20:46
lalalala: check the conditions after getting r0 and r1 instead of before in the guards
Cale 2017-02-18 11:20:48
Oh, yeah, I wasn't paying very close attention :)
Cale 2017-02-18 11:20:51
haha
AWizzArd 2017-02-18 11:20:52
Cale: it's not related to Intero. Stack can't download this version it seems. Or cabal.
bollu 2017-02-18 11:20:56
dolio: isn't it contra in the first argument and then co in the second?
Rembane 2017-02-18 11:20:59
lalalala: https://hackage.haskell.org/package/MonadRandom-0.5.1/docs/Control-Monad-Random-Lazy.html
Cale 2017-02-18 11:21:16
AWizzArd: maybe you need an additional resolver in stack? I also don't use Stack very much.
dolio 2017-02-18 11:21:21
bollu: No, not the way the category theorists do it.
bollu 2017-02-18 11:21:27
dolio: I see
lalalala 2017-02-18 11:21:52
Rembane: that's the only way?
lalalala 2017-02-18 11:21:58
lyxia: hm what?
Tuplanolla 2017-02-18 11:22:30
:t let mapReaderTIO f m = ask >>= (runReaderT m >>> f >>> liftIO) in mapReaderTIO -- Does this function seem suspicious to anyone?
Tuplanolla 2017-02-18 11:22:30
:t let mapReaderT f m = ask >>= (runReaderT m >>> f >>> lift) in mapReaderT -- It's a specialized version of this one.
lyxia 2017-02-18 11:22:35
lalalala: genTeams p@(x0 : x1 : xs) = do { r1 <- ... ; r2 <- ... ; if length p == 3 then return ... else do { rest <- ... ; return ... } }
lambdabot 2017-02-18 11:22:36
forall k (m :: * -> *) a b (m1 :: k -> *) (a1 :: k). (MonadIO m, MonadReader a m) => (m1 a1 -> IO b) -> ReaderT a m1 a1 -> m b
lambdabot 2017-02-18 11:22:36
forall k a b (m :: k -> *) (a1 :: k) (t :: (* -> *) -> * -> *) (m1 :: * -> *). (MonadTrans t, MonadReader a (t m1), Monad m1) => (m a1 -> m1 b) -> ReaderT a m a1 -> t m1 b
Cale 2017-02-18 11:22:57
bollu: You could probably get by with either convention so long as you're consistent about it, but C -/-> D meaning D^op x C -> Set is probably the most obvious one.
Rembane 2017-02-18 11:23:00
lalalala: No, lyxia's way is better. My was just a general advice on how to make working with randomness less painful in Haskell. :)
bollu 2017-02-18 11:23:10
Cale: I see
lalalala 2017-02-18 11:23:20
can you fellas give an example of how, Rembane lyxia ?
lyxia 2017-02-18 11:23:39
lalalala: I just did.
dolio 2017-02-18 11:23:45
bollu: The reason being (among others) that when you turn a functor F : A -> B into a profunctor Hom(-, F=) : A -/-> B, you can see that it's B^op × A -> Set.
lalalala 2017-02-18 11:23:58
lyxia: oh i didn't see that, my bad.
bollu 2017-02-18 11:24:03
dolio: what is Hom(-, F=)?
lyxia 2017-02-18 11:24:06
lalalala: np.
Cale 2017-02-18 11:24:22
It's the bifunctor which sends (X,Y) to Hom(X,FY)
Cale 2017-02-18 11:24:32
Or profunctor, rather :)
bollu 2017-02-18 11:24:32
is the "=" standard notation?
bollu 2017-02-18 11:24:36
:)
Cale 2017-02-18 11:24:44
it's just a double dash, indicating a second argument
bollu 2017-02-18 11:24:47
ahh
bollu 2017-02-18 11:24:48
OK
dolio 2017-02-18 11:25:04
And that lifting preserves the variance.
AWizzArd 2017-02-18 11:25:21
Cale: thx for the maximumBy suggestion. Works too.
Cale 2017-02-18 11:25:23
A lot of the time, people will write another long dash and just expect you to discern that it means a different argument from the first dash.
dolio 2017-02-18 11:25:23
If F is a covariant functor, Hom(-,F=) is a covariant profunctor.
dolio 2017-02-18 11:25:29
Covariant in its A stuff.
dolio 2017-02-18 11:26:16
The other way of turning F into a profunctor, Hom(F-, =) makes it contravariant in the A stuff.
bollu 2017-02-18 11:26:33
right
dolio 2017-02-18 11:26:36
So it'd be flipping the variance.
AWizzArd 2017-02-18 11:27:58
Is there a Haskell code pasting website?
Tuplanolla 2017-02-18 11:28:03
@paste
lambdabot 2017-02-18 11:28:03
Haskell pastebin: http://lpaste.net/
bollu 2017-02-18 11:28:04
lpaste.net
miscyb 2017-02-18 11:28:19
hi i'm trying to build a package on hackage that requires gi-gtk, and hackage is complaining that it doesn't have some stuff in pkg-config
miscyb 2017-02-18 11:28:26
what's the proper way to upload this?
miscyb 2017-02-18 11:28:32
https://hackage.haskell.org/package/reactive-banana-gi-gtk
ezyang 2017-02-18 11:29:17
miscyb: The haddock docs? You can build and upload them yourself
AWizzArd 2017-02-18 11:29:25
Tuplanolla: thx
ezyang 2017-02-18 11:29:53
What do people think is the best performing trie implementation in Haksell?
AWizzArd 2017-02-18 11:29:54
Can this be written in a better/more haskellish way? maximumBy (\(_,_,p1) (_,_,p2) -> compare p1 p2) myListWithTriples
miscyb 2017-02-18 11:29:56
ezyang: is there a stack command i can use for that?
ezyang 2017-02-18 11:30:40
miscyb: Dunno; I guess not see https://github.com/commercialhaskell/stack/issues/737
Tuplanolla 2017-02-18 11:30:41
I'd write `maximumOn (view _3)`, AWizzArd.
AWizzArd 2017-02-18 11:32:22
:t view => var not in scope
lambdabot 2017-02-18 11:32:22
error: parse error on input '=>'
c_wraith 2017-02-18 11:32:22
AWizzArd: Tuplanolla's example uses lens
AWizzArd 2017-02-18 11:32:38
c_wraith: okay, didn't study those yet.
Tuplanolla 2017-02-18 11:33:04
I have become a lens addict.
c_wraith 2017-02-18 11:35:12
lens is an amazing sweet spot of concise and principled. The only downside is that learning it means picking up a rather large collection of new ideas.
bollu 2017-02-18 11:35:33
does MakeLenses generate prisms as well?
lalalala 2017-02-18 11:36:29
im using Atom atm, any "real" IDE that is better to use?
dolio 2017-02-18 11:36:44
There's makePrisms for making prisms.
bollu 2017-02-18 11:38:08
Tuplanolla: do you lens your entire codebase? or only parts?
bollu 2017-02-18 11:38:37
Tuplanolla: as in, do you generate lenses for every data type?
AWizzArd 2017-02-18 11:41:20
lalalala: I like Intero, for Emacs.
Tuplanolla 2017-02-18 11:42:02
Usually all or nothing, bollu.
bollu 2017-02-18 11:42:02
Tuplanolla: OK, ty
chopsuey 2017-02-18 11:43:09
More Linux channels plz
lalalala 2017-02-18 11:44:22
AWizzArd: gonna check thx