ongy 2017-02-02 05:47:47
k0001: there's #xmonad :) Also that's the strut bug in 0.12, let me search for the comment about it
ongy 2017-02-02 05:48:22
https://wiki.haskell.org/Xmonad/Notable_changes_since_0.11#ManageDocks_changes this one
k0001 2017-02-02 05:48:25
ongy: oh, nice! Thank you :)
ski 2017-02-02 05:54:07
jophish,sdx23 : .. i recall seeing it mentioned that one define a notion of entropy on partitions / equivalence relations on a given set
z0ltan 2017-02-02 05:54:56
Hello, folks. I needed a quick help with Haskell mode on emacs... how to force format of pasted code? It doesn't appear to be happening by default :(
sdx23 2017-02-02 05:55:12
ski: there quite some - coming from a physics background I was just wondering what the notion meant in regard of type systems.
ski 2017-02-02 06:01:07
sdx23 : "The Logic of Partitions: Introduction to the Dual of the Logic of Subsets" by David P. Ellerman in 2010-06 at was where i saw it .. do you have any handy link for a discussion/exposition of some of the ones you had in mind ?
infandum 2017-02-02 06:04:05
Using lens only (no map), how can I get the first two elements of a list in a tuple? Like: f [(1,56,53), (3,4,8), (0,3,1)] == [(1,56), (3, 4), (0, 3)]
infandum 2017-02-02 06:04:23
I should mention that list is a Value
tsahyt 2017-02-02 06:04:24
does it ever make sense to put inline pragmas on where bindings?
infandum 2017-02-02 06:04:59
so it would be something like toListOf (_Array . traverse . _1) or something, except that would only get the first one
nitrix 2017-02-02 06:08:22
infandum: You can use _1 and _2 to obtain the respective tuple elements.
infandum 2017-02-02 06:08:37
nitrix: But how to do it on ONE traversal?
infandum 2017-02-02 06:08:42
Not doing it twice and zipping
nitrix 2017-02-02 06:08:56
Oh, you might want (.:) or something similar.
infandum 2017-02-02 06:09:02
oooo what's that
infandum 2017-02-02 06:09:11
oh, for aeson?
nitrix 2017-02-02 06:09:14
Well that one would do it twice. Let me think.
infandum 2017-02-02 06:11:17
nitrix: I guess I'm thinking like an arrow or something
infandum 2017-02-02 06:11:24
or that bimap
infandum 2017-02-02 06:11:32
the lens equivalent of that
nitrix 2017-02-02 06:13:03
Curiously, is `traverse (\e -> pure (e ^. _1, e ^. _2))` not good enough?
nitrix 2017-02-02 06:13:30
> traverse (\e -> pure (e ^. _1, e ^. _2)) [(1,56,53),(3,4,8), (0,3,1)]
lambdabot 2017-02-02 06:13:32
error:
lambdabot 2017-02-02 06:13:32
• Ambiguous type variables 'f0', 't0', 't1' arising from a use of 'show_...
lambdabot 2017-02-02 06:13:32
prevents the constraint '(Show (f0 [(t0, t1)]))' from being solved.
nitrix 2017-02-02 06:14:30
It's a tiny repetitive, but you can change that with ehm...
infandum 2017-02-02 06:14:42
nitrix: It's in a Value though
infandum 2017-02-02 06:14:48
from json
infandum 2017-02-02 06:15:03
so I'm using lenses to get the info
nitrix 2017-02-02 06:19:45
Maybe having a proper example would help because I'm really tempted to not use lenses for this.
glguy 2017-02-02 06:19:57
> let notMap = over mapped in notMap (\(x,y,_) -> (x,y)) [(1,56,53), (3,4,8), (0,3,1)] == [(1,56), (3, 4), (0, 3)]
lambdabot 2017-02-02 06:20:00
True
nitrix 2017-02-02 06:20:11
Seriously, map (\(x,y,_) -> (x,y)) ...
nitrix 2017-02-02 06:20:22
glguy: Yup.
jophish 2017-02-02 06:20:36
jle`: Hi, I'm expipiplus1 on github. If you let me know your hackage username I can add you as a maintainer for vector-sized
jle` 2017-02-02 06:21:38
jophish: it's 'jle' !
jle` 2017-02-02 06:21:42
http://hackage.haskell.org/user/jle
jle` 2017-02-02 06:21:44
:)
jophish 2017-02-02 06:24:14
jle`: ok, I've added you, might take a moment to trickle through.
jophish 2017-02-02 06:24:20
Thanks for your contributions!
Clarinerd 2017-02-02 06:28:19
Can I ask a question?
Clarinerd 2017-02-02 06:28:38
Kinda new, so not quite sure how the channel works
jophish 2017-02-02 06:28:46
Clarinerd: usually best just to ask :)
ski 2017-02-02 06:29:22
Clarinerd : you already did ..
Clarinerd 2017-02-02 06:30:48
Fair enough. I'm learning Haskell to join a research group, and one of the advisors for the group tasked me with building a basic data structure for representing Polynomials
ski 2017-02-02 06:31:28
polynomials in one variable ?
Clarinerd 2017-02-02 06:31:29
The trick is that it has to share its substructure, such that having two versions of (x+4) would only take up one space in memory.
Clarinerd 2017-02-02 06:31:33
Many.
Clarinerd 2017-02-02 06:31:49
Sorry, no
Clarinerd 2017-02-02 06:32:01
one variable, n-degree
ski 2017-02-02 06:32:20
not quite sure what you mean by "two versions of (x+4)"
ski 2017-02-02 06:32:53
do you mean having two factors `x + 4', or do you mean two separate polynomials both being `x + 4' ?
Clarinerd 2017-02-02 06:33:30
Both, in fact.
Clarinerd 2017-02-02 06:33:48
At least according to the problem description I was given.
Clarinerd 2017-02-02 06:34:04
It is still possible that it was worded incorrectly and/or poorly
Cale 2017-02-02 06:34:26
I don't believe it makes a whole lot of sense to attempt that in general.
MarcelineVQ 2017-02-02 06:35:05
might be good to make a paste of the problem posed, in case there's a translation error
ski 2017-02-02 06:35:29
the obvious way to represent a polynomial in one variable is as a list of the coefficient, presumably simplest to order them from coefficients corresponding to lower powers of the variable before ones corresponding to higher powers
Clarinerd 2017-02-02 06:35:45
Good point. I'll copy it over. Just a sec
ski 2017-02-02 06:36:27
maybe you want to try to factor your polynomial when you can ? or perhaps just keep the expression structure (possibly reshaping it a bit) ?
sssilver 2017-02-02 06:36:29
hey guys, interesting q came up during discussion with a colleague
Cale 2017-02-02 06:36:50
Even after it completely ruins the maintainability of your program, the amount of bookkeeping you'll need in order to keep track of already-constructed polynomials will eat into any cost savings you might have expected to obtain.
sssilver 2017-02-02 06:36:52
suppose you have a long call chain, e.g. a calls b which calls c, then d, e, and at the end it's z
sssilver 2017-02-02 06:37:07
a takes an argument from the user, which is only used in z
sssilver 2017-02-02 06:37:23
now all your b, c, d, e, f, etc signatures are polluted because they need to pass that argument down
sssilver 2017-02-02 06:37:30
is there a pattern that solves this problem?
sssilver 2017-02-02 06:37:34
provided everything's happening in a single thread
Cale 2017-02-02 06:37:44
Though I don't know, maybe you have a very large number of occurrences of the exact same small polynomials or something.
ski 2017-02-02 06:38:03
sssilver : one alternative is to pass along a context argument, and to augment it with another field for your extra argument
Clarinerd 2017-02-02 06:38:12
Create data structure that can represent sets of polynomials using shared substructure
Clarinerd 2017-02-02 06:38:14
Be able to print everything it represents as an instance of Show
sssilver 2017-02-02 06:38:30
ski that's basically the idea of "thread-local variables"
Clarinerd 2017-02-02 06:38:35
That's all that I have in writing.
_sras_ 2017-02-02 06:38:54
Why does this fails type check, http://lpaste.net/351988 ?
Cale 2017-02-02 06:38:56
Well, *maybe* that refers to the ability to share tails of lists or something.
sssilver 2017-02-02 06:38:59
ski any other tips? also, could passing that context be made a bit more implicit to contain verbosity?
ski 2017-02-02 06:39:49
sssilver : it's not clear whether by "thread" you mean a multi-processing mechanism, or just sub computations that are grouped together by the same argument role being passed to them (and perhaps also out of them)
Clarinerd 2017-02-02 06:39:52
Cale: I agree with your earlier premise about it not making sense. But, in the off chance that they're just talking about sharing portions of the lists as you mentioned, how would I go about that?
sssilver 2017-02-02 06:40:25
ski I mean these functions are being called in a single thread, so sync isn't a problem
Cale 2017-02-02 06:40:42
sssilver: I would recommend just passing the argument along without thinking of it as "pollution", because it's conceptually really not. If the result of z is used to determine the result of a in some way, then the outcome of applying a really does depend on it.
ski 2017-02-02 06:41:01
sssilver : there's `Reader',`ReaderT', but in simple cases, simply passing it explicitly may be preferable. if the actual passing (not the type signatures, assuming you have them) is tiresome, you could try implicit parameters
_sras_ 2017-02-02 06:41:10
nevermind. It is using lift from another module...
Cale 2017-02-02 06:41:16
sssilver: So making that dependency obvious can be helpful. If your problem is a proliferation of such parameters, the solution is to design data types better to organise them in a coherent way.
ski 2017-02-02 06:41:19
sssilver : and what Cale said
Cale 2017-02-02 06:42:02
Clarinerd: Well, perhaps just start by taking a polynomial to be a list of coefficients.
sssilver 2017-02-02 06:42:06
Cale but even if you (properly) aggregate them all into one type, you're still passing that along, and in some ways that doesn't feel elegant
sssilver 2017-02-02 06:42:30
ski what are "implicit parameters"?
Cale 2017-02-02 06:42:30
Clarinerd: So, perhaps just start with something like newtype Poly a = P [a]
ski 2017-02-02 06:42:49
Clarinerd : not directly related, but i'd hope that they don't expect your `Show' instance to generate a string that's not a valid Haskell representation of code which evaluated in an appropriate environment yields a value equal to the original value ..
Cale 2017-02-02 06:42:57
Clarinerd: and then we can define addition like add (P xs) (P ys) = P (zipWith (+) xs ys)
ski 2017-02-02 06:43:39
sssilver :
Cale 2017-02-02 06:44:11
Clarinerd: and basic stuff like x = P [0,1]
Clarinerd 2017-02-02 06:44:38
ski: not exactly sure what you mean, but I feel like if I can get my mind around a representation, Show won't be too bad