Search Haskell Channel Logs

Thursday, February 2, 2017

#haskell channel featuring merijn, sdx23, stephaner, tsahyt, lyxia, Benzi-Junior, and 9 others.

ph88^ 2017-02-02 03:46:23
i made this code that works with GHC.Generics and it works. Could anyone have a look at my code and see if there are some things left that still can be improved? https://paste.fedoraproject.org/542869/37744148/
merijn 2017-02-02 04:00:42
Any people with persistent experience? I have a bunch of boilerplate and I'd be curious if there's a better way to deal with it...
jophish 2017-02-02 04:04:45
Are there any type systems which track entropy?
lyxia 2017-02-02 04:08:21
ph88^: do you ever use n
sdx23 2017-02-02 04:09:26
jophish: what is "entropy" in this context?
jophish 2017-02-02 04:09:51
sdx23: I'm just trying to think if this is an interesting question or not
jophish 2017-02-02 04:10:03
I was thinking about ways to help program which deal with cryptography
jophish 2017-02-02 04:10:18
for example affine types can make sure that an IV is never used more than once
ph88^ 2017-02-02 04:12:31
lyxia, no, wouldn't know what to use it for
Benzi-Junior 2017-02-02 04:13:38
hey is there a way to have stack dump out the core ?
lyxia 2017-02-02 04:13:46
ph88^: that's something you can simplify
ph88^ 2017-02-02 04:14:03
alright
ph88^ 2017-02-02 04:14:09
any other tips ?
lyxia 2017-02-02 04:14:27
ph88^: it look alright otherwise.
ph88^ 2017-02-02 04:14:35
ok thank you :)
fuzzyhorns 2017-02-02 04:21:48
im in a bit over my head in https://github.com/haskell-servant/servant/blob/master/servant-docs/src/Servant/Docs/Internal.hs#L678 how does a function like docsFor actually execute? i cant seem to get a mental model
stephaner 2017-02-02 04:22:52
I feel a bit embarrassed, I cannot find the problem in this warning: Pattern match(es) are overlapped In an equation for `reducer': reducer c [] = ... reducer c' (x : xs) = ... I thought (x:xs) could not be mistaken with []
fuzzyhorns 2017-02-02 04:22:53
i dont really follow how it takes like an api, http://haskell-servant.readthedocs.io/en/stable/tutorial/ApiType.html
stephaner 2017-02-02 04:23:10
could you indicate me what's wrong ?
merijn 2017-02-02 04:23:37
stephaner: Can you lpaste the exact code?
stephaner 2017-02-02 04:23:41
ok
stephaner 2017-02-02 04:25:57
http://lpaste.net/351975 the goal is to make a tokenizer to be used with foldr
merijn 2017-02-02 04:26:16
stephaner: 6 and 9 overlap
merijn 2017-02-02 04:26:28
As do 4 and 5
merijn 2017-02-02 04:26:44
stephaner: sep is a variable
merijn 2017-02-02 04:26:53
you're simply shadowing the existing 'sep' variable
stephaner 2017-02-02 04:27:00
it doesn't take into account the global sep varaible ?
stephaner 2017-02-02 04:27:03
ok
merijn 2017-02-02 04:27:09
stephaner: No, you can only match on literals
Tuplanolla 2017-02-02 04:27:20
It defines another `sep` that shadows the global one, stephaner.
merijn 2017-02-02 04:27:22
Everything else just introduces a new variable that shadows the existing one
merijn 2017-02-02 04:27:34
FYI, -Wall should warn about that
stephaner 2017-02-02 04:27:36
it explains the problem :-)
merijn 2017-02-02 04:27:58
I would generally recommend using -Wall and selectively disabling warnings you don't like
Tuplanolla 2017-02-02 04:28:46
That's not even bad. I've seen `otherwise` get shadowed accidentally. That was a fun one to explain.
merijn 2017-02-02 04:29:04
:D
stephaner 2017-02-02 04:29:06
let's try with Wall
merijn 2017-02-02 04:29:44
On the one hand I get occasionally annoyed about shadowing warnings, otoh, it's really nice to catch mistakes like this :)
tsahyt 2017-02-02 04:30:57
Is there a criterion template for stack somewhere? I need this rather often lately. Just asking before I write my own.
stephaner 2017-02-02 04:31:28
yep, having read this: This binding for 'sep' shadows the existing binding would have rung a bell :-)
stephaner 2017-02-02 04:31:30
many thx
merijn 2017-02-02 04:32:32
stephaner: Incidentally, if the goal of 'sep' was to factor stuff out you could accomplish something similar using guards
stephaner 2017-02-02 04:33:30
merijn good idea
lpaste 2017-02-02 04:34:31
merijn revised "No title": "No title" at http://lpaste.net/351975
nitrix 2017-02-02 04:39:34
Now that I think about it, normally universal and existantial quantifiers are used in expressions to make them into propositions.
nitrix 2017-02-02 04:39:43
Does that means type annotations in Haskell are propositions?
merijn 2017-02-02 04:40:19
nitrix: In an unsound logic, yes
merijn 2017-02-02 04:40:28
nitrix: See Curry-Howard
nitrix 2017-02-02 04:40:31
Does that means the programs are inherently proofs?
nitrix 2017-02-02 04:40:44
That seems so backwards to me :P
nitrix 2017-02-02 04:40:49
merijn: Checking.
ertes 2017-02-02 04:40:56
helo
ertes 2017-02-02 04:40:59
nitrix: yes
exio4 2017-02-02 04:41:00
nitrix: the curry-howard correspondence is.. that
exio4 2017-02-02 04:41:15
nitrix: "types are propositions, programs of that type are proofs"
ertes 2017-02-02 04:41:50
nitrix: claim: the statement 'a' implies 'a' for all statements 'a'
nitrix 2017-02-02 04:41:56
I've heard of curry howard being mentioned but I never paid too much attention to the implications and just now, with my newly aquired knowledge, did it click.
ertes 2017-02-02 04:41:56
type version: forall a. a -> a
ertes 2017-02-02 04:42:04
proof: id x = x
merijn 2017-02-02 04:42:22
nitrix: Inhabitation of the type 'a' is a proof of proposition 'a'
nitrix 2017-02-02 04:42:34
merijn: ertes Very cool.
merijn 2017-02-02 04:42:39
nitrix: Unfortunately, Haskell is Turing complete and thus all types are inhabited, rendering the logic unsound ;)
ertes 2017-02-02 04:43:00
nitrix: claim: for all statements 'a' and 'b', 'a' implies 'b'
exio4 2017-02-02 04:43:02
@djinn (a -> b) -> (b -> c) -> (a -> c)
lambdabot 2017-02-02 04:43:02
f a b c = b (a c)
merijn 2017-02-02 04:43:05
nitrix: See also this excellent talk by Wadler: https://www.youtube.com/watch?v=IOiZatlZtGU
merijn 2017-02-02 04:43:18
nitrix: I strongly recommend it, very accessible
ertes 2017-02-02 04:43:26
nitrix: nonsense :: forall a b. a -> b -- can't be proved in a sound logic, but haskell is unsound
nitrix 2017-02-02 04:43:27
merijn: Will do, appreciated.
Tuplanolla 2017-02-02 04:43:52
Follow-up question, nitrix: what does `42 :: Int` prove?
tsahyt 2017-02-02 04:43:54
so I've spun up a quite criterion benchmark for foldr (+) 0 over lists, vectors, and hashsets. These are the results http://sprunge.us/Zeih and they are very unexpected for me. How can a HashSet be that much faster than vectors? The elements are of course all disjoint, so all structures have the same number of elements.