Search Haskell Channel Logs

Saturday, February 4, 2017

#haskell channel featuring hpc, monochrom, MarcelineVQ, hexagoxel, tfc, boojinks, and 9 others.

monochrom 2017-02-04 06:54:28
I like their leader's foresight that it was time to learn programming.
sm 2017-02-04 06:55:37
yeah! and steals a fortran manual! smart lady!
Welkin 2017-02-04 06:56:43
she should have taken the lisp one!
sm 2017-02-04 06:57:43
from the look of things, NASA was not looking for that kind of hippie nonsense at that moment :)
Welkin 2017-02-04 06:57:50
lol
Welkin 2017-02-04 06:58:20
obviously it was a joke
sm 2017-02-04 06:58:27
it seemed just getting "the IBM" running was a huge deal
Welkin 2017-02-04 06:58:27
no one likes the original lisp
hpc 2017-02-04 06:58:46
elispers might
Welkin 2017-02-04 06:59:05
no types, no deal!
Theophane 2017-02-04 07:00:09
:D
hpc 2017-02-04 07:01:23
Welkin: very few people were able to use the original lisp, because the compiler was a room full of grad students
Xnuk 2017-02-04 07:02:20
> 10^123456789
lambdabot 2017-02-04 07:02:27
mueval: ExitFailure 1
Welkin 2017-02-04 07:03:09
> take 10 $ replicate 123456789 10
lambdabot 2017-02-04 07:03:11
[10,10,10,10,10,10,10,10,10,10]
Xnuk 2017-02-04 07:03:35
Can I kill this evaluation?
Welkin 2017-02-04 07:03:44
> foldr1' (*) $ replicate 123456789 10
lambdabot 2017-02-04 07:03:47
error:
lambdabot 2017-02-04 07:03:47
• Variable not in scope:
lambdabot 2017-02-04 07:03:47
foldr1' :: (Integer -> Integer -> Integer) -> [Integer] -> t
monochrom 2017-02-04 07:03:57
@quote room.*grad.*student
lambdabot 2017-02-04 07:03:57
hpc says: the first lisp interpreter was a room full of grad students
hpc 2017-02-04 07:04:29
huh, i have mentioned this before
hpc 2017-02-04 07:05:23
lisp was never intended to be run, it was just a theoretical construct for writing lambda calculus, plus some silly things like eval
Welkin 2017-02-04 07:05:32
like coq
Welkin 2017-02-04 07:05:32
:D
hpc 2017-02-04 07:05:59
and said grad students decided if eval was made executable, you had (for the 50s) one of the highest-level languages ever written
hpc 2017-02-04 07:06:10
and they hand-compiled it
hpc 2017-02-04 07:06:33
yeah, imagine going back and showing them a DT language
hpc 2017-02-04 07:07:03
a lot of the math behind DT is quite recent
Welkin 2017-02-04 07:07:17
I feel like most software development is stuck in the stone age even still today
monochrom 2017-02-04 07:07:20
That would cause a divide among them, and they would split and argue over static types vs dynamic types.
hpc 2017-02-04 07:07:29
the calculus of constructions didn't even come about until 88
hpc 2017-02-04 07:07:44
monochrom: they didn't even have types yet
sm 2017-02-04 07:08:03
those poor savages
monochrom 2017-02-04 07:08:03
But you just showed them!
Xnuk 2017-02-04 07:08:09
I did `thread <- forkFinally (return $ 10^123456789) ({- put result to MVar -}); threadDelay 5e6; killThread thread` and this doesn't work
hpc 2017-02-04 07:08:12
actually i guess they did, fortran existed
Welkin 2017-02-04 07:08:13
advanced type systems are slowly taking over
hpc 2017-02-04 07:08:37
and i thiiiiink it was typed?
hpc 2017-02-04 07:09:34
yeah
monochrom 2017-02-04 07:09:37
> 5e6 :: Int
lambdabot 2017-02-04 07:09:40
error:
lambdabot 2017-02-04 07:09:40
• No instance for (Fractional Int) arising from the literal '5e6'
lambdabot 2017-02-04 07:09:40
• In the expression: 5e6 :: Int
monochrom 2017-02-04 07:09:46
Is that why?
hpc 2017-02-04 07:09:56
i think we've stagnated pretty heavily on the current trend of untyped interpreted languages (like python)
Welkin 2017-02-04 07:10:15
hpc: thankfully...
hpc 2017-02-04 07:10:20
and the next language to dominate is going to be the first to popularize a powerful type system
hpc 2017-02-04 07:10:28
hopefully that's haskell
Welkin 2017-02-04 07:10:35
facebook seems to be pushing ocaml hard as a backend at least
hpc 2017-02-04 07:10:38
or idris
Xnuk 2017-02-04 07:10:57
monochrom: No, I wrote like 5000000
Welkin 2017-02-04 07:11:15
they released a new dsl called "Reason" that you use to generate javascript using an ocaml backend
boojinks 2017-02-04 07:11:25
I wonder what the relationship is between the guys behind Reason and the guys on the FB Haskell teams?
hpc 2017-02-04 07:11:35
i don't think ocaml will be the one to do it
monochrom 2017-02-04 07:11:38
OK, what does "doesn't work" mean?
Welkin 2017-02-04 07:11:41
hpc: I don't either
tfc 2017-02-04 07:11:48
hm i think the languages will stay popular which make it easy to copy&paste stuff and modify it to make it fit your needs. that's python.
hpc 2017-02-04 07:12:00
rust might, if they get some more really good ideas
tfc 2017-02-04 07:12:05
put one monad into haskell code and no one from outside gets it
sm 2017-02-04 07:12:27
I think that will change a bit
boojinks 2017-02-04 07:12:28
tfc: similar happened when OOP was pushed though, no?
hpc 2017-02-04 07:12:30
it wouldn't be nearly as effective as a high-level language as haskell, but it would have the advantage of being in a mode of thought many people already use
hpc 2017-02-04 07:12:40
and it's so much better than C that i wouldn't even mind
Welkin 2017-02-04 07:12:55
facebook pretty muhc dominates the js landcscape these days
Xnuk 2017-02-04 07:13:04
monochrom: It compiles successfully, but CPU usage of the compiled program still hits 100% after 5e6 microseconds
Welkin 2017-02-04 07:13:09
and they are pushing hard to immutability, types, and pure functions
Welkin 2017-02-04 07:13:12
for*
hpc 2017-02-04 07:13:26
tfc: i have been slowly convincing my coworkers of what Monad can do and it's been going well
monochrom 2017-02-04 07:13:49
Have you shown the whole complete program?
tfc 2017-02-04 07:13:50
look at c++. it allows for so many no-runtime-cost things which help abstracting ideas further from C
hpc 2017-02-04 07:13:52
showing people what "trailing do" syntax can do in other languages like perl and ruby seems to work well
tfc 2017-02-04 07:13:59
but nevertheless people stick to c-style c++
sm 2017-02-04 07:14:12
tfc: monads will become normal, and we'll make improvements in usability (which might or might not be called haskell)
tfc 2017-02-04 07:14:35
they are thankful for shared_ptr, constructor/destructor logic and so on, but the programs are still sequences of if while else for foo
hpc 2017-02-04 07:14:35
i think just eliminating the magic around the name will go a long way
hpc 2017-02-04 07:14:41
and having more connective concepts like Monoid
hpc 2017-02-04 07:15:06
it's much better now than it was when i first learned haskell
Welkin 2017-02-04 07:15:27
hpc: well now you are a fuly-grown lizard man
tfc 2017-02-04 07:15:40
i am currently programming haskell a lot and i am completely fascinated. i got to understand monads, but i still can hardly explain what applicative and monoid etc. mean
hpc 2017-02-04 07:15:45
FAM also helps document the relationship
Welkin 2017-02-04 07:15:58
FAAMA
Welkin 2017-02-04 07:16:01
FAAMAC
hpc 2017-02-04 07:16:10
Monoid is super easy
Welkin 2017-02-04 07:16:12
oops
Welkin 2017-02-04 07:16:17
FASMMAC
hpc 2017-02-04 07:16:27
it's two operations, (<>) and mempty
Welkin 2017-02-04 07:16:31
:D
hpc 2017-02-04 07:16:35
with x <> mempty = x = mempty <> x
Welkin 2017-02-04 07:16:39
and then you can use that to explain semigroups
MarcelineVQ 2017-02-04 07:16:43
Welkin: what are the last two :>
hpc 2017-02-04 07:16:46
and (x <> y) <> z = x <> (y <> z)
Welkin 2017-02-04 07:16:54
MarcelineVQ: Arrow and Category :D
benzrf 2017-02-04 07:17:15
13:15 i am currently programming haskell a lot and i am completely fascinated. i got to understand monads, but i still can hardly explain what applicative and monoid etc. mean
hpc 2017-02-04 07:17:15
if you need to give examples, i like to give the ones for (+) and (*)
benzrf 2017-02-04 07:17:25
if this is true, i suspect that perhaps you don't actually understand monads =p
hpc 2017-02-04 07:17:31
mempty = 0, (<>) = (+)
tfc 2017-02-04 07:17:36
benzrf: you might be right, lol.
hpc 2017-02-04 07:17:36
mempty = 1, (<>) = (*)
monochrom 2017-02-04 07:17:40
monoid should be the easy one because so many programmers are so obsessed with numbers and strings.
benzrf 2017-02-04 07:18:12
monochrom: i think the problem is less about monoids in specific, and more about mathematical abstractions in general
hpc 2017-02-04 07:18:12
Monoid might even be so important it should be taught before Functor
Welkin 2017-02-04 07:18:27
Monoid and Functor first
hpc 2017-02-04 07:18:39
because it's one that damn near everyone learns already, if they notice it or not
benzrf 2017-02-04 07:18:41
tfc: the key thing to understand is that many of haskell's abstractions don't necessarily map cleanly to a specific intuitive notion
tfc 2017-02-04 07:18:49
when i first read my first haskell book, all the theoretical explanations and concept blew up my brain. i think if i read such introductory stuff again in half a year, i will finally get it. ;)
Welkin 2017-02-04 07:18:54
monoid can help to understand monad
hpc 2017-02-04 07:18:55
anyone who's taken basic algebra will recognize it instantly
hpc 2017-02-04 07:19:46
it introduces the concept of algebraic laws, and you can tell the value of those laws pretty much instantly too
tfc 2017-02-04 07:19:54
well i had a lot algebra at university, but it still doesn't click immediately. although programming haskell in general feels a lot like doing math on the blackboard.
benzrf 2017-02-04 07:19:57
tfc: the purpose of things like monoid, monad, and so on (in haskell), is very simply that empirically speaking, a lot of pieces of code that are useful for specific types all look like each other
benzrf 2017-02-04 07:21:02
tfc: it just so happens that for Int and (+) and 0, for [a] and (++) and [], for Int and (*) and 1, it is empirically the case that you will see a lot of scraps of code that are identical except for swapping out those 3 things
tfc 2017-02-04 07:21:20
yes
Welkin 2017-02-04 07:21:22
so I end up using <> a lot
benzrf 2017-02-04 07:21:27
and that's really all there is to monoids, in the end
Welkin 2017-02-04 07:21:28
and almost never (++)
Welkin 2017-02-04 07:22:00
mainly because of String/Text/ByteString
benzrf 2017-02-04 07:22:10
well, that's not the full story, i guess
Welkin 2017-02-04 07:22:18
benzrf: your quotations look funny
Welkin 2017-02-04 07:22:31
they are `]` with an inverted background color
benzrf 2017-02-04 07:22:39
Welkin: thats italics, your client doesnt render it
Xnuk 2017-02-04 07:23:12
@lpaste
lambdabot 2017-02-04 07:23:12
Haskell pastebin: http://lpaste.net/
benzrf 2017-02-04 07:23:25
tfc: once someone identifies the common features between these usages, you get a kind of feedback effect where people then find new things they can do generically over that set of features - but to begin with, it's really only as simple as i just put it
Welkin 2017-02-04 07:24:01
best monad explanation http://blog.sigfpe.com/2006/08/you-could-have-invented-monads-and.html
benzrf 2017-02-04 07:24:06
meh
tfc 2017-02-04 07:24:13
benzrf: yes i realized that, but the picture in my mind around that is still very primitive.
hpc 2017-02-04 07:24:13
you get to say "this is a monoid, therefore a gazillion things other people discovered previously"
benzrf 2017-02-04 07:24:17
tfc: oh, ok :)
benzrf 2017-02-04 07:24:23
sorry
lpaste 2017-02-04 07:24:34
Xnuk pasted "Cannot kill 10^123456789" at http://lpaste.net/352085
tfc 2017-02-04 07:24:35
i use monads every day and it's easy for me to stack IO and state and whatever monads
benzrf 2017-02-04 07:24:47
Welkin: i looked at that a lot back when i was starting out, and ultimately the only thing that really helped was just using a shitload of monads
Welkin 2017-02-04 07:25:03
using monads and understanding them are two different things though
hpc 2017-02-04 07:25:13
Xnuk: are you running it with -threaded?
tfc 2017-02-04 07:25:15
but it was pretty hard for me today to learn how to mix do notation stuff with applicative code lines in Data.Yaml
Welkin 2017-02-04 07:25:16
I used them a lot when I was building apps with yesod
Welkin 2017-02-04 07:25:28
but I didn't really understand them
benzrf 2017-02-04 07:25:30
Welkin: i feel like any blogpost about monads, no matter how good, is going to pretty much be like trying to use new analogies for mathematical concepts instead of actually doing the exercises
Xnuk 2017-02-04 07:26:08
hpc: Oh I forgot it
monochrom 2017-02-04 07:26:09
Xnuk: "print" is where the computation of 10^123456789 begins and will take whatever it takes to finish.
hpc 2017-02-04 07:27:14
Xnuk: oh yeah, you need to put the evaluation of that huge number inside the forked thread
hpc 2017-02-04 07:27:49
Xnuk: replace return with evaluate
hpc 2017-02-04 07:27:57
and import Control.Exception
monochrom 2017-02-04 07:28:01
Another triumph of my http://www.vex.net/~trebla/humour/tautologies.html #4
Xnuk 2017-02-04 07:28:31
monochrom, hpc: Thanks, I'll give it a try
hexagoxel 2017-02-04 07:29:19
:t timeout
benzrf 2017-02-04 07:29:20
tfc: you're comfortable with functor and monad, you said
lambdabot 2017-02-04 07:29:20
error: Variable not in scope: timeout
benzrf 2017-02-04 07:29:22
?
hexagoxel 2017-02-04 07:29:28
Xnuk: http://hackage.haskell.org/package/base-4.9.1.0/docs/System-Timeout.html#v:timeout
tfc 2017-02-04 07:29:40
benzrf: yes
benzrf 2017-02-04 07:30:18
tfc: well, stop me if you've heard this one before, but you might be able to think of applicative as a "watered-down" version of monad
hpc 2017-02-04 07:30:28
:t ap
lambdabot 2017-02-04 07:30:30
Monad m => m (a -> b) -> m a -> m b
hpc 2017-02-04 07:30:34
:t (<*>)
lambdabot 2017-02-04 07:30:35
Applicative f => f (a -> b) -> f a -> f b
hpc 2017-02-04 07:30:37
:t return
hexagoxel 2017-02-04 07:30:38
Xnuk: doesn't remove the need to seq/force/evaluate though
lambdabot 2017-02-04 07:30:39
Monad m => a -> m a
hpc 2017-02-04 07:30:40
:t pure
lambdabot 2017-02-04 07:30:42
Applicative f => a -> f a
tfc 2017-02-04 07:31:23
yes, it is very obvious that on some level they do the same thing
tfc 2017-02-04 07:31:38
there's a really really obivous pattern. :D
benzrf 2017-02-04 07:31:40
tfc: in particular, you can treat `f a' where f is an Applicative in the same mental way as `f a' when f is a Monad, but the Applicativeness only gives you the ability to concatenate two of them together into one with the result of both
Welkin 2017-02-04 07:31:47
applicatives cannot be sequenced, and they cannot depend on the result of the previous computation
benzrf 2017-02-04 07:31:49
i.e., f a -> f b -> f (a, b)
Welkin 2017-02-04 07:31:51
unlike monads
tfc 2017-02-04 07:32:35
oh, yes. that's helpful, i did not realize this before.
benzrf 2017-02-04 07:32:48
so you can do everything you can with do-notation EXCEPT that a variable bound with a '<-' cannot appear anywhere except in an argument to pure/return
benzrf 2017-02-04 07:33:09
this is kosher for applicative: do x <- foo; bar; y <- baz; return (x + y)
benzrf 2017-02-04 07:33:15
this is not: do x <- foo; bar x; y <- baz; return (x + y)
benzrf 2017-02-04 07:33:28
hence "cannot depend on the result of the previous computation"
hpc 2017-02-04 07:33:46
this is where the concept of applicative do-notation comes from too
tfc 2017-02-04 07:33:49
let me note that down, that's a very helpful example
Welkin 2017-02-04 07:34:07
benzrf: is it halal, too?
benzrf 2017-02-04 07:34:13
i hope so!
benzrf 2017-02-04 07:34:24
in more technical terms, if you have `m (m a)' with Monad m, you can get an `m a'; but with just Applicative m, you can't
benzrf 2017-02-04 07:34:48
in fact, the typical mathematical definition of a monad is about `m (m a) -> a', not bind
hpc 2017-02-04 07:34:59
m (m a) -> m a
Welkin 2017-02-04 07:35:05
mma!
benzrf 2017-02-04 07:35:07
er, fuck yeah
hpc 2017-02-04 07:35:12
;)
benzrf 2017-02-04 07:35:19
typo :(
Welkin 2017-02-04 07:35:30
but it's easier to think about monad in terms of >>= and return
Welkin 2017-02-04 07:35:35
rather than join
hpc 2017-02-04 07:35:36
sometimes
kaol 2017-02-04 07:35:49
Am I the only one who just tries various permutations of fundeps until GHC type checks whenever they are needed?
hpc 2017-02-04 07:35:56
join :: [[a]] -> [a] is pretty easy to reason about
hpc 2017-02-04 07:36:04
join :: Maybe (Maybe a) -> Maybe a, too
hpc 2017-02-04 07:36:16
join for Cont, maybe not
tfc 2017-02-04 07:36:33
i don't know cont
Welkin 2017-02-04 07:36:47
>>= and return form a monoid though
benzrf 2017-02-04 07:36:55
you mean join
hpc 2017-02-04 07:36:55
tfc: Cont is a good type to save for later
benzrf 2017-02-04 07:37:01
join and return form a monoid
monochrom 2017-02-04 07:37:02
<*> is like product (in fact liftA2(,) is exactly product, and <*> could have been derived from liftA2(,)), >>= is like dependent product.
hpc 2017-02-04 07:37:05
(>=>) and return, rather
hpc 2017-02-04 07:37:12
form a category
benzrf 2017-02-04 07:37:13
no, (>=>) and return form a category ;)
hpc 2017-02-04 07:37:20
yeah
hpc 2017-02-04 07:37:29
categories are very similar to monoids though
benzrf 2017-02-04 07:37:43
Welkin: return and join *literally* form a Monoide , though
Monoide 2017-02-04 07:37:58
Monoid*
benzrf 2017-02-04 07:38:07
ahaha
benzrf 2017-02-04 07:38:10
i press tab compulsively
Monoide 2017-02-04 07:38:12
;P
benzrf 2017-02-04 07:38:12
sorry
hpc 2017-02-04 07:38:13
tfc: if you want to slightly prepare yourself for it, consider expressions of the form ($ x)
hpc 2017-02-04 07:38:18
:t ($ "yes")
lambdabot 2017-02-04 07:38:20
([Char] -> b) -> b
hpc 2017-02-04 07:38:24
:t ($ "no")
lambdabot 2017-02-04 07:38:26
([Char] -> b) -> b
hpc 2017-02-04 07:38:40
but don't think too terribly hard about it, there's more important things to learn first
monochrom 2017-02-04 07:39:06
sodium cyanide and potassium monoide
benzrf 2017-02-04 07:40:23
bbl
tfc 2017-02-04 07:41:02
hpz benzrf yeah i am on it. will use haskell a lot in the next months, and every week there's some other concept finally grasped.
Welkin 2017-02-04 07:42:15
lol, hpz
tfc 2017-02-04 07:42:21
oops
tfc 2017-02-04 07:42:21
:D
tfc 2017-02-04 07:42:51
however i love learning all that stuff because it gives me shitloads of ideas how i can write better C++.
tfc 2017-02-04 07:43:14
i actually started learning haskell when i realized that i already to purely functional programming when doing metaprogramming with C++ templates.
monochrom 2017-02-04 07:44:52
@djinn ((((a -> r) -> r) -> r) -> r) -> ((a -> r) -> r)
lambdabot 2017-02-04 07:44:52
f a b = a (\ c -> c b)