Search Haskell Channel Logs

Thursday, February 9, 2017

#haskell channel featuring sqrt2, byorgey, c_wraith, mniip, merijn, zennist, and 5 others.

kubbe 2017-02-09 02:47:47
Haha, you got that right. Well the solution we handed in was approved
kubbe 2017-02-09 02:48:08
Thank you for your assistance Myrl-saki, much appricieted
Myrl-saki 2017-02-09 02:48:14
kubbe: Great. I guess I'm going to sleep now. Night~
Myrl-saki 2017-02-09 02:48:22
kubbe: Glad to know I've helped.
mniip 2017-02-09 02:49:03
hey kubbe
Profpatsch 2017-02-09 02:49:54
Argh.
Profpatsch 2017-02-09 02:50:05
Anyone versed with monad-logger?
Profpatsch 2017-02-09 02:50:27
How do I supress logging output of a sub-task?
Profpatsch 2017-02-09 02:50:55
I have something like runSqlNoLog = Log.filterLogger (\_ _ -> False) . runSql
Profpatsch 2017-02-09 02:51:19
But it still dumps all inserts to the command line.
kubbe 2017-02-09 02:52:19
mniip, whats up mate!
kubbe 2017-02-09 02:53:16
Btw guys. In this game I have I want to submit a "quit"-function. So it is possible for the player to quit the game and not continue playing after a game. How can I terminate a program without having to clsoe GHCI
Myrl-saki 2017-02-09 02:53:53
:t exit
lambdabot 2017-02-09 02:53:55
error: Variable not in scope: exit
Myrl-saki 2017-02-09 02:54:07
:t exitWith
lambdabot 2017-02-09 02:54:09
error: Variable not in scope: exitWith
Myrl-saki 2017-02-09 02:54:13
Ehhhh
Myrl-saki 2017-02-09 02:54:25
Nyeh. I forgot the type.
Myrl-saki 2017-02-09 02:54:33
kubbe: Check hoogle, it's a great resource.
kubbe 2017-02-09 02:55:04
Alright! Thanks
Myrl-saki 2017-02-09 02:56:01
Apparently, exitWith is correct. https://www.haskell.org/hoogle/?hoogle=exitWith
kubbe 2017-02-09 02:59:38
Hmm, alright! Okey :) Look at this: http://pastebin.com/KTVYaGP3
kubbe 2017-02-09 03:00:15
in the gamestate, atm only when the player has won I want to ask the player if he/she stills wants to play. If yes; run main. else: quit the game
byorgey 2017-02-09 03:01:15
merijn: re: GHC support for monoid-extras, at least 7.8+. I think currently Travis-CI tests it back to 7.6
merijn 2017-02-09 03:02:17
byorgey: I'm asking because I noticed: "minimum xs = P.minimum (Infinity : map Finite xs)"
merijn 2017-02-09 03:02:37
byorgey: Seems like that'd be asymptotically faster using "minimum = P.minimum . (Infinity:) . coerce"
merijn 2017-02-09 03:02:46
oh, wait
merijn 2017-02-09 03:02:48
I'm dumb
merijn 2017-02-09 03:02:54
It's not a newtype xD
byorgey 2017-02-09 03:03:03
merijn: nope =)
byorgey 2017-02-09 03:03:50
merijn: I don't think it would be asymptotically faster anyway, it would still hae to traverse the list
byorgey 2017-02-09 03:03:54
*have
merijn 2017-02-09 03:04:08
Semi-related, anyone know if I can delete a branch from a repo on github?
merijn 2017-02-09 03:04:14
(from the web, that is)
byorgey 2017-02-09 03:04:45
merijn: hmm, I don't know if there's any way to do it via the web interface
byorgey 2017-02-09 03:04:50
I know how to do it from the command line.
merijn 2017-02-09 03:05:03
byorgey: I'm not using git, hence the problem :p
byorgey 2017-02-09 03:05:28
how do you have a repo on github if you're not using git?
merijn 2017-02-09 03:05:43
byorgey: Mercurial's wonderful bidirectional git-bridge :)
kubbe 2017-02-09 03:05:59
nvm, I solved it with it just returning (). It works since the main is defined main :: IO ()
byorgey 2017-02-09 03:06:16
merijn: oh, you can. click on "branches" in the little bar at the top (commits ... branches ... releases ... etc.)
merijn 2017-02-09 03:06:25
byorgey: Yeah, I found it :)
byorgey 2017-02-09 03:06:25
merijn: then there are little trash can icons next to each branch
byorgey 2017-02-09 03:06:31
great =)
byorgey 2017-02-09 03:06:50
ah, mercurial git-bridge, cool
merijn 2017-02-09 03:07:35
byorgey: https://github.com/diagrams/monoid-extras/pull/30 Those should all be uncontroversial, I think.
byorgey 2017-02-09 03:07:49
merijn: great, thanks, I'll have a look soon
merijn 2017-02-09 03:08:10
I'd have liked an Enum instance too, but I don't see a way to reasonable properly handle both bounded and unbounded enums
byorgey 2017-02-09 03:10:26
merijn: hmm, the Num/Fractional/Floating instances seem fishy. I'll have to think through them more carefully. What do you use those for?
merijn 2017-02-09 03:12:34
byorgey: I'm trying to keep track of upper and lower bounds which I update incrementally so I just end up writing "(+5)", which I suppose could also be "fmap (+5)" but these instances behave the same as, say, Double arithmetic
merijn 2017-02-09 03:12:43
> ((1/0) :: Double)
lambdabot 2017-02-09 03:12:45
Infinity
merijn 2017-02-09 03:12:48
> ((1/0) :: Double) + 2
lambdabot 2017-02-09 03:12:50
Infinity
byorgey 2017-02-09 03:13:59
merijn: well, no, that's the problem, they don't behave exactly the same. For example:
byorgey 2017-02-09 03:14:07
> (-(1/0) :: Double) * (-(1/0))
lambdabot 2017-02-09 03:14:10
Infinity
byorgey 2017-02-09 03:14:30
but for NegInf the instance you gave would give Infinity * Infinity = Infinity
merijn 2017-02-09 03:14:36
hmmm, I suppose
merijn 2017-02-09 03:14:53
byorgey: I had it in my code because I was using Infinity as undefined, rather than infinity
merijn 2017-02-09 03:15:08
I'm not particularly married to the Num instance if there's a functor
byorgey 2017-02-09 03:15:20
OK, I'll think about it some more
c_wraith 2017-02-09 03:17:24
doesn't countable infinite * countable infinity = countable infinity?
merijn 2017-02-09 03:17:58
c_wraith: His point is that Infinity for NegInf is negative infinity, so it's sign should flip
c_wraith 2017-02-09 03:18:08
Ah
merijn 2017-02-09 03:18:09
Since -inf * -inf = +inf in IEEE754
merijn 2017-02-09 03:19:25
Is there an easy way to compute the number of (decimal) digits required to display an Int64? Or should I fromIntegral and logBase it as a Double?
mniip 2017-02-09 03:19:49
length . show?
Masterhacker2004 2017-02-09 03:20:20
Hey
merijn 2017-02-09 03:20:21
mniip: That's a rather bad way of doing it... :p
mniip 2017-02-09 03:20:44
only computed once if you do it right
mniip 2017-02-09 03:21:00
and, tbf, could be worse
sqrt2 2017-02-09 03:21:08
there won't be a way without taking a logarithm, whether explicitly or implicitly
mniip 2017-02-09 03:21:23
logarithming it is prone to rounding and off by one errors
byorgey 2017-02-09 03:21:34
merijn: http://www.hedonisticlearning.com/posts/find-first-set.html ;-) (probably overkill)
mniip 2017-02-09 03:21:38
length.show is concise and clear in what it does
sqrt2 2017-02-09 03:21:39
mniip: you only need one digit of accuracy, so that's not the problem
c_wraith 2017-02-09 03:21:44
Int64 isn't that big. You can just have a table of points at which the number of digits increases
mniip 2017-02-09 03:21:58
sqrt2, 100000 vs 99999
c_wraith 2017-02-09 03:21:59
Fortunately, the table is easy to create. 10, 100, 1000, ... :)
byorgey 2017-02-09 03:22:03
though I guess that's *binary* logarithm and you want decimal.
merijn 2017-02-09 03:22:09
byorgey: Seems like it'd be considerably slower than just logbase :p
mniip 2017-02-09 03:22:18
one could be rounded into the other, and the floor of the logarithm would change
sqrt2 2017-02-09 03:22:43
mniip: double still has plenty of significant digits
mniip 2017-02-09 03:23:00
not enough for Int64
byorgey 2017-02-09 03:23:08
merijn: agreed =)
mniip 2017-02-09 03:25:20
any of ya folk good with CT?
merijn 2017-02-09 03:25:31
mniip: Probably? ;)
Masterhacker2004 2017-02-09 03:25:57
I am good at counterterroist ye
mniip 2017-02-09 03:25:58
shameless crossposting #2
mniip 2017-02-09 03:25:59
1486629679 [11:41:19] what does the umlaut-arrow denote exactly? 1486629740 [11:42:20] the definition of an extranatural transformation implies two profunctors, however I'm seeing it being used as codomain object -> functor
sqrt2 2017-02-09 03:26:11
in experiment, i can distinguish 10^19 and 10^19-1 using a double
byorgey 2017-02-09 03:26:30
mniip: usually I have seen an arrow with two dots used to indicate a dinatural transformation
mniip 2017-02-09 03:26:30
sqrt2, that is very weird
merijn 2017-02-09 03:26:37
sqrt2: Doubles are accurate up to 2^53
mniip 2017-02-09 03:26:42
byorgey, I'm fairly sure this is an extranatural?
merijn 2017-02-09 03:26:45
sqrt2: After that they lose accuracy
merijn 2017-02-09 03:26:52
> 10^19
lambdabot 2017-02-09 03:26:55
10000000000000000000
merijn 2017-02-09 03:27:03
> 2^53
lambdabot 2017-02-09 03:27:06
9007199254740992
mniip 2017-02-09 03:27:12
> 10^19-1
lambdabot 2017-02-09 03:27:14
9999999999999999999
mniip 2017-02-09 03:27:17
> 10^19-1 :: Double
lambdabot 2017-02-09 03:27:20
1.0e19
merijn 2017-02-09 03:27:25
Probably got lucky there
sqrt2 2017-02-09 03:27:25
ah, damnit, i mistyped
byorgey 2017-02-09 03:28:02
mniip: extranatural is a special case of dinatural, I think
mniip 2017-02-09 03:28:08
oh?
byorgey 2017-02-09 03:28:19
that's what nlab says at least =)
mniip 2017-02-09 03:28:20
I got the idea of it being something completely different
byorgey 2017-02-09 03:29:13
https://ncatlab.org/nlab/show/dinatural+transformation
mniip 2017-02-09 03:30:56
dinatural is more general than natural too
byorgey 2017-02-09 03:31:14
yes
merijn 2017-02-09 03:32:17
byorgey: Also, the docs of Inf could use a reminder of which is which. I keep having to open the source and look at the Ord implementation to figure out which is which
mniip 2017-02-09 03:32:37
or not
byorgey 2017-02-09 03:32:57
merijn: good idea. Could you either make a PR or open an issue so I won't forget?
mniip 2017-02-09 03:33:00
a DT is not an NT in the functor-from-product sense
mniip 2017-02-09 03:33:06
but you can encode an NT with a DT
mniip 2017-02-09 03:33:24
if you make the ^op part of the functor a constant functor
byorgey 2017-02-09 03:33:46
merijn: re: your Int64 question, if I were you I would just implement an integer logarithm function. e.g. see https://bonsaicode.wordpress.com/2010/05/07/programming-praxis-integer-logarithms/
mniip 2017-02-09 03:33:55
then S(c', c) = S(c, c)
mniip 2017-02-09 03:34:02
S(f, 1) = 1
mniip 2017-02-09 03:34:11
and that gets you an NT on the remaining parts of the diagram
byorgey 2017-02-09 03:34:22
mniip: right
merijn 2017-02-09 03:34:38
byorgey: done
merijn 2017-02-09 03:36:19
byorgey: Seems like a hassle compared to "floor . logBase 10 . (+1) . fromIntegral" :) I'm not too worried about possible discrepancies since 1) I expect most/all values to be rather small and 2) I'm trying to determine rough bounds on max request size, so being off by a few bytes isn't that big an issue
byorgey 2017-02-09 03:37:18
merijn: OK, sure, if you don't care about potential inaccuracy then I agree logBase 10 is a better solution. I thought you cared about it being accurate.
merijn 2017-02-09 03:38:22
byorgey: Just "mostly", trying to figure out how many id's I can squeeze into a single HTTP request by doing exponential increase + binary search, if I'm off by a few bytes and need to redo the request...*shrug*
zennist 2017-02-09 03:38:38
Hi anyone familiar with the yesod/persistent library can shed some light on how to do testing with data layer built on top of that?
mniip 2017-02-09 03:38:50
so a DT is, roughly,
mniip 2017-02-09 03:38:51
forall a. p a a -> q a a
mniip 2017-02-09 03:38:56
for profunctors p and q
merijn 2017-02-09 03:39:23
mniip: DT as in dependent type? Or is that an ambiguous acronym?
mniip 2017-02-09 03:39:32
dinatural transformation
zennist 2017-02-09 03:40:49
notably, I'd like to implement my 'impure' web services such that all the logic in pure - and the data related impure code expressed in persist could be tested but with minimal test footprint
mniip 2017-02-09 03:40:58
and an extranatural is like
mniip 2017-02-09 03:41:05
forall a b. p a a -> q b b
mniip 2017-02-09 03:41:22
for profunctors (possibly differntly kinded) p and q
byorgey 2017-02-09 03:42:47
mniip: that's exactly what a DT is. I'm not so sure of your analogy for extranatural. Though to be fair I'm less familiar with them than I am with dinatural.
mniip 2017-02-09 03:43:03
dinatural is "simple enough"
c_wraith 2017-02-09 03:43:18
man, I have so much trouble with CT diagrams, compared to haskell types...
merijn 2017-02-09 03:43:30
c_wraith: Join the club
c_wraith 2017-02-09 03:43:49
I guess CT ideas are always more general than their simplest expression as a haskell type.
byorgey 2017-02-09 03:44:35
c_wraith: yes. In fact, one can say something stronger: CT ideas are always more general than your current most general understanding of them.
c_wraith 2017-02-09 03:44:45
:)
mniip 2017-02-09 03:44:54
not all CT ideas are exxpressible
mniip 2017-02-09 03:44:55
in haskell