Search Haskell Channel Logs

Friday, February 10, 2017

#haskell channel featuring janos, dmwit, kubbe, lpaste_, glguy, lambdabot, and 5 others.

yyyyy 2017-02-10 06:45:14
mmachenry: language extensions, "cool" things coming from academia adopted due to their coolness etc. 15 years ago you had no Free monads, no extensible effects, no :latest-thing:.
yyyyy 2017-02-10 06:45:28
no hasochism :)
yyyyy 2017-02-10 06:46:01
i'm not against it, just stating my impression of a trend
mmachenry 2017-02-10 06:46:11
yyyyy: Yeah… I will counter your prediction with the fact that I tend to be a bit of a simpleton. I actually program in Haskell because I'm dumb, not smart. :) I haven't adopted most of those features in my actual code.
Tuplanolla 2017-02-10 06:46:18
You don't even need those, yyyyy.
yyyyy 2017-02-10 06:46:52
no, of course you don't. but sometimes you will be client to a library that might use those concepts. then you have to at least understand it.
mmachenry 2017-02-10 06:47:02
Or I'll be more charitable and say I'm aware of my limitations and wisely use Haskell for that. I'm not using Haskell because I want to try all the crazy awesome stuff.
mmachenry 2017-02-10 06:47:22
Yeah makes sense. That might happen.
yyyyy 2017-02-10 06:47:26
mmachenry: likewise. i tend to keep things simple.
lpaste_ 2017-02-10 06:48:42
Tuplanolla pasted "Obvious Algorithm" at http://lpaste.net/352328
Tuplanolla 2017-02-10 06:49:22
It's not even a year old and I already don't know how it works.
yyyyy 2017-02-10 06:50:49
Tuplanolla: lol! i suffer from the "it's a local definition, so let me use a single letter for this function…" followed by weeks later obligatory "what do this even…"
yyyyy 2017-02-10 06:52:18
and you even went pointfree on it, shame on your future self :p
Tuplanolla 2017-02-10 06:52:48
I didn't even use the owl.
yyyyy 2017-02-10 06:54:21
hahahaha! but was it due to lack of opportunity?
Tuplanolla 2017-02-10 06:56:54
Maybe...
yyyyy 2017-02-10 06:57:42
every once in a while i see a library using lens pervasively and am reminded of my lack of patience to understand it more thoroughly. i feel specially dumb when said code is littered with its operators, leading to having one monitor with haddock and one with actual library code. it's a slow process.
Tuplanolla 2017-02-10 06:59:06
The textual versions of the operators are much easier to remember.
yyyyy 2017-02-10 06:59:09
and yet… i end up using a subset of those operators on some projects, simply because it saves me time. so i can't blame whoever wrote with more on theirs.
Tuplanolla 2017-02-10 06:59:14
That's totally not my Lisp envy talking.
yyyyy 2017-02-10 06:59:40
hahaha
yyyyy 2017-02-10 07:00:11
i suppose if you use it as your daily DSL for lots of things you get used to them to the point where you can't remember how you hated it in the beginning.
Tuplanolla 2017-02-10 07:01:46
Where else have I heard of users needing their daily dose of some abbreviation?
Javran 2017-02-10 07:01:54
> ((,) <$> minimumOf traverse <*> maximumOf traverse) [1..10]
yyyyy 2017-02-10 07:01:57
APL?
lambdabot 2017-02-10 07:01:58
(Just 1,Just 10)
Javran 2017-02-10 07:02:33
hm I want to know can I do better than this, or to retrieve min and max at the same time do I have to traverse twice?
reactormonk 2017-02-10 07:06:01
How do I make a Lift instance for a phantom type without using deriving Lift?
dmwit 2017-02-10 07:08:15
> foldMap (\x -> (Min (Just x), Max (Just x))) [1..10]
lambdabot 2017-02-10 07:08:18
error:
lambdabot 2017-02-10 07:08:18
• Data constructor not in scope: Min :: Maybe Integer -> t
lambdabot 2017-02-10 07:08:18
• Perhaps you meant one of these:
dmwit 2017-02-10 07:10:31
> foldMap (\x -> (Just (Semigroup.Min x), Just (Semigroup.Max x))) [1..10 :: Int]
lambdabot 2017-02-10 07:10:33
(Just (Min {getMin = 1}),Just (Max {getMax = 10}))
dmwit 2017-02-10 07:10:38
Javran: ^^
reactormonk 2017-02-10 07:11:00
Ah, doens't work at all. https://github.com/mboes/th-lift/commit/cd382e016339cd5d5dbe55edf78a1027020736c0
Tuplanolla 2017-02-10 07:11:14
> foldMap (Min &&& Max) [1 .. 10]
lambdabot 2017-02-10 07:11:17
error:
lambdabot 2017-02-10 07:11:17
• Data constructor not in scope: Min :: Integer -> c
lambdabot 2017-02-10 07:11:17
• Perhaps you meant one of these:
Tuplanolla 2017-02-10 07:11:29
> foldMap (Semigroup.Min &&& Semigroup.Max) [1 .. 10]
lambdabot 2017-02-10 07:11:33
error:
lambdabot 2017-02-10 07:11:33
• Ambiguous type variable 'a0' arising from a use of 'show_M100692917862...
lambdabot 2017-02-10 07:11:33
prevents the constraint '(Show a0)' from being solved.
Tuplanolla 2017-02-10 07:11:45
That should work anyway.
dmwit 2017-02-10 07:11:48
> foldMap (Just . Semigroup.Min &&& Just . Semigroup.Max) [1 .. 10 :: Int]
lambdabot 2017-02-10 07:11:51
(Just (Min {getMin = 1}),Just (Max {getMax = 10}))
dmwit 2017-02-10 07:12:10
I think the Just is necessary. foldMap demands Monoid
Tuplanolla 2017-02-10 07:12:13
You don't even need `Maybe`.
reactormonk 2017-02-10 07:12:16
ah nope, that's not it. blubb.
dmwit 2017-02-10 07:12:18
Prove it.
Tuplanolla 2017-02-10 07:12:24
> foldMap (Sum &&& Product) [1 .. 10 :: Int]
lambdabot 2017-02-10 07:12:27
(Sum {getSum = 55},Product {getProduct = 3628800})
dmwit 2017-02-10 07:12:47
:t foldMap
lambdabot 2017-02-10 07:12:49
(Monoid m, Foldable t) => (a -> m) -> t a -> m
dmwit 2017-02-10 07:12:59
Tuplanolla: Sum and Product are Monoids. Min and Max are not.
Tuplanolla 2017-02-10 07:13:01
Oh, `Min` is a bit different.
Tuplanolla 2017-02-10 07:13:07
Indeed.
glguy 2017-02-10 07:13:23
Option is good for promoting a Semigroup to a Monoid
dmwit 2017-02-10 07:13:29
Tuplanolla: Oh, actually, Min and Max *are* Monoids.
dmwit 2017-02-10 07:13:40
Provided the contained type is Ord and Bounded. So I am the one who is wrong!
dmwit 2017-02-10 07:14:10
> foldMap (Semigroup.Min &&& Semigroup.Max) [1 .. 10 :: Int]
lambdabot 2017-02-10 07:14:13
(Min {getMin = 1},Max {getMax = 10})
dmwit 2017-02-10 07:14:34
Although the answer you get for [] could be a bit surprising if you're not paying attention.
dmwit 2017-02-10 07:14:51
Using Maybe (or Option, outside of lambdabot) is probably cleaner.
Tuplanolla 2017-02-10 07:15:01
Yes.
dmwit 2017-02-10 07:15:04
> foldMap (Semigroup.Min &&& Semigroup.Max) ([] :: [Int])
lambdabot 2017-02-10 07:15:06
(Min {getMin = 9223372036854775807},Max {getMax = -9223372036854775808})
Tuplanolla 2017-02-10 07:15:36
Do we have a point-at-infinity `Integer` type?
dmwit 2017-02-10 07:16:43
Yes, in monoid-extras there is PosInf and NegInf.
dmwit 2017-02-10 07:17:11
http://hackage.haskell.org/package/monoid-extras-0.4.2/docs/Data-Monoid-Inf.html
dmwit 2017-02-10 07:17:51
The primary difference between `PosInf a` and `Option (Min a)` is that `PosInf` promises that `max` will treat the infinity correctly and `Option` doesn't.
dmwit 2017-02-10 07:18:06
One of `Option (Min a)` and `Option (Max a)` does not (cannot) treat the infinity correctly.
dmwit 2017-02-10 07:18:43
Well. `compare`, not `max`. But you get the idea.
Javran 2017-02-10 07:21:03
I see, thanks all!
kubbe 2017-02-10 07:32:48
Hello! Is it possible to take out a value out of a Table, which contains tuples?
glguy 2017-02-10 07:33:56
That'd depend on what a Table is
kubbe 2017-02-10 07:37:04
The table is a character counter atm. It saves the character and the amount of times it occurs in the string
kubbe 2017-02-10 07:37:18
but we need to take out these values and create a tree of them. How should we do it?
dmwit 2017-02-10 07:37:30
Hi again kubbe. =)
kubbe 2017-02-10 07:37:49
Hello! I have more or less the same problems as yesterday :( dmwit
janos 2017-02-10 07:38:20
kubbe: do you have some code we can see? Still struggling to understand what the problem is :)
dmwit 2017-02-10 07:38:24
Nobody can really answer the question you're asking unless you show the code (or at least the type signatures for the API) of Table.
dmwit 2017-02-10 07:38:41
?paste in case you've lost the link to the paste site we prefer
lambdabot 2017-02-10 07:38:41
Haskell pastebin: http://lpaste.net/
kubbe 2017-02-10 07:38:42
Yeah sure thing! 2 seconds.
kubbe 2017-02-10 07:42:47
Huffman-file: http://lpaste.net/352329 | PrioQueue-file: http://lpaste.net/352330 | Table-file: http://lpaste.net/352331