Search Haskell Channel Logs

Friday, February 24, 2017

#haskell channel featuring Aku, zennist, tapirus, Tuplanolla, orion, chreekat, and 8 others.

stphrolland 2017-02-24 05:46:00
just tried it, it needs to use the {-# LANGUAGE TypeOperators #-} , but works like a breeze it seems
shapr 2017-02-24 05:47:02
tapirus: Is J's fork something like &&& in Control.Arrow?
dolio 2017-02-24 05:48:31
shapr: It's more like defining Num instances for functions, I think.
shapr 2017-02-24 05:48:44
huh, I don't even
dolio 2017-02-24 05:48:47
So you can say 'sin^2 + cos^2'
dolio 2017-02-24 05:49:05
Instead of \x -> (sin x)^2 + (cos x)^2
Aku 2017-02-24 06:02:07
How do I got about learning Monads?
Aku 2017-02-24 06:04:46
I have started learning Haskell quite recently, how should I go about leaning Monads?
Aku 2017-02-24 06:04:55
*learning
orion 2017-02-24 06:06:31
Aku: Study the definitions. Do not let metaphors enter your mind.
orion 2017-02-24 06:06:36
And the laws.
tapirus 2017-02-24 06:07:05
shapr: I'm not sure, I'm still a beginner when it comes to haskell. But in J the classical pedagogical example of a fork would be average =: (+/ % #), or (sum divide mean)
Aku 2017-02-24 06:07:21
orion: Ohhkay
chreekat 2017-02-24 06:07:35
Aku: Know that 'monad' is an abstract concept, and do as orion says, and practice *using* individual instances of Monad, like Maybe and Reader
koala_man 2017-02-24 06:07:42
Aku: some say the best way is to just write programs with IO, State and Writer until you're comfortable with them, and then look at the definitions to see how they're related
chreekat 2017-02-24 06:07:48
^
tapirus 2017-02-24 06:07:51
shapr: so for instance, '(sum divide mean) list' would be interpreted as (divide (sum list) (mean list)) in prefix notation
koala_man 2017-02-24 06:07:55
like chreekat just did
Aku 2017-02-24 06:08:47
Ohhkay..
tapirus 2017-02-24 06:10:25
shapr: or more generally, '[x] ( f g h k l) y' is equivalent to ((x f y) g ((x h y) k (x l y))) etc. in infix (where [x] means x is optional)
tapirus 2017-02-24 06:10:41
does that relate to &&& at all?
nitrix 2017-02-24 06:16:55
Aku: I'd say, stick stricly to their definition and then look at a few simple examples like the Maybe monad. Ideally, you'd have a strong understanding of Applicatives and Functors first (and type classes in general).
Tuplanolla 2017-02-24 06:17:41
@where burritos
lambdabot 2017-02-24 06:17:41
I know nothing about burritos.
nitrix 2017-02-24 06:18:20
Aku: Alternatively, we can walk the steps and I can attempt to make you "discover" monads on your own intuitively on #haskell-beginners. I have some free time :P
nitrix 2017-02-24 06:23:27
Depending on your background, we could talk about endofunctors and monoids too to arrive at monads :P
Aku 2017-02-24 06:25:08
Thanks nitrix for help but I am bit busy, I was gonna start Monads soon so just asked!
nitrix 2017-02-24 06:25:33
Feel free to come for help if you get stuck :)
Aku 2017-02-24 06:26:06
Sure :D
Aku 2017-02-24 06:26:34
How to quit from the channel?
Aku 2017-02-24 06:26:36
I am new!
hydraz 2017-02-24 06:26:48
./part
nitrix 2017-02-24 06:26:52
/part will leave the channel, /quit will disconnect completely.
Aku 2017-02-24 06:27:08
And then how to join back?
byorgey 2017-02-24 06:27:14
tapirus: I'm familiar with J, and I don't think adding fork/hook to Haskell would be a good idea. Too much syntactic complexity for not much benefit.
nitrix 2017-02-24 06:27:14
/join #haskell
Aku 2017-02-24 06:27:25
ohhkay
byorgey 2017-02-24 06:28:42
tapirus: on the other hand, the way J automatically resizes arguments to match is really cool. For a nice take on that in a functional context, see this recent paper by Jeremy Gibbons: http://www.cs.ox.ac.uk/publications/publication10857-abstract.html
byorgey 2017-02-24 06:33:09
tapirus: note in Haskell you can just define e.g. fork as a higher-order function
byorgey 2017-02-24 06:33:12
> let fork f g h y = (f y) `g` (h y) in fork sum (/) genericLength [1..6]
lambdabot 2017-02-24 06:33:15
3.5
byorgey 2017-02-24 06:33:49
which is why I claim there would not be much benefit to including it as built-in syntax.
Tuplanolla 2017-02-24 06:34:01
> liftA2 (/) sum genericLength [1 .. 6]
lambdabot 2017-02-24 06:34:04
3.5
Tuplanolla 2017-02-24 06:34:18
Even better: we already have it.
hydraz 2017-02-24 06:34:31
nice
byorgey 2017-02-24 06:34:41
yes, good point, although that is not going to make sense to a beginner yet =)
Tuplanolla 2017-02-24 06:35:26
It's nice to notice that J has implicit `liftAn` for all `n`.
tapirus 2017-02-24 06:35:36
byorgey: interesting, thanks :) reading this now
byorgey 2017-02-24 06:36:08
Tuplanolla: not exactly, it kind of iterates liftA2
byorgey 2017-02-24 06:36:35
if you give a big string of operations it builds a binary tree out of them
Tuplanolla 2017-02-24 06:36:49
Okay, almost.
zennist 2017-02-24 06:36:51
quick question: what function do you use such that: Traversable t => t a -> [a]
zennist 2017-02-24 06:37:06
i can think of using folds like: foldMap pure
zennist 2017-02-24 06:37:11
but that's for Foldable instance
byorgey 2017-02-24 06:37:44
zennist: well, every Traversable has to be Foldable.
zennist 2017-02-24 06:37:52
obviously you can go for something like: getConst . traverse (Const . pure)
byorgey 2017-02-24 06:37:53
zennist: you want Data.Foldable.toList
zennist 2017-02-24 06:38:00
but something shorter please
zennist 2017-02-24 06:38:17
ah okay - my oversight then; awesome