nshepperd 2017-02-11 07:45:41
you mean the implementation of mconcat? yeah I suppose it would use fusion magic. although in the end it's really just adding up the length, allocating that much then doing some memcpys
tsahyt 2017-02-11 07:46:26
but it would require two traversals of the list, one for the length, one for the memcpys?
tsahyt 2017-02-11 07:46:46
I suppose at least for small lists that's the fastest way to do it anyhow
tsahyt 2017-02-11 07:47:01
besides, depending on the origin of the list, that one itself might be subject to fusion
tsahyt 2017-02-11 07:49:33
Bish: FWIW, lists make great control structures for some tasks due to their implementation as actual lists. e.g. foldl' (+) [0..10000] might look like it's building a linked list in memory with 10000 elements in it and then iterating over them, adding them all up, but with optimizations on it compiles to a tight loop much like you would write it in C
tsahyt 2017-02-11 07:49:47
and this sort of thing often works across relatively complicated transformations
tsahyt 2017-02-11 07:50:49
I'm missing a 0 in there, foldl' (+) 0 [0..10000]
e 2017-02-11 07:54:40
if that compiles to a loop it's not exactly a poster child for good optimisation
monochrom 2017-02-11 07:55:24
Why?
barrucadu 2017-02-11 07:56:12
Because it could be reduced to a constant
tsahyt 2017-02-11 07:56:30
fair enough, bad example
e 2017-02-11 07:56:51
no, it's a reasonable example
tsahyt 2017-02-11 07:57:20
I'm not even sure whether GHC transforms this into a constant time form though
e 2017-02-11 07:57:24
i'm just stretching it further than it was intended and acting surprised when it breaks
monochrom 2017-02-11 07:58:07
Would this be a poster child? (But this time C.) https://plus.google.com/u/0/102208456519922110915/posts/DZsZ6mvA4T6
WzC 2017-02-11 07:58:49
Question: I would ike to store a bunch of functions, lets say of type (Ord b => a -> b) in a data structure, s.t. when I want to do a lookup I'm given a value of type a and I wish to report all functions in the DS that report b.
Lokathor 2017-02-11 07:59:16
barrucadu, imagine (\x -> foldl' (+) 0 [0..x]) then :P
WzC 2017-02-11 07:59:19
does anyone see a way of fiddling around that so that I can use Data.Set/Data.Map as the DS?
e 2017-02-11 07:59:34
monochrom: haha
monochrom 2017-02-11 07:59:45
:)
Welkin 2017-02-11 07:59:47
WzC: you cannot inspect types at runtime
WzC 2017-02-11 07:59:49
or do I have to basically redo the work and reimplement everything in Data.Set again
Welkin 2017-02-11 07:59:57
because they don't exist any more
WzC 2017-02-11 07:59:58
I know what the types will be
WzC 2017-02-11 08:00:01
they will be fixed
mr_sm1th 2017-02-11 08:00:14
Is there no nor operator?
WzC 2017-02-11 08:00:17
ist's just that the functions I'm storing are only comparable once I give you a thing of type a
NeverDie 2017-02-11 08:00:18
Functional programming discord chat if anyone's interested: https://discord.gg/NGM7BGW
mr_sm1th 2017-02-11 08:00:49
NeverDie: I think IRC people tend to look down on Discord. :')
Welkin 2017-02-11 08:00:54
WzC: you can store anything you want (functions, values)
osfameron 2017-02-11 08:01:20
NeverDie: eeeek, *voice* chat?
Welkin 2017-02-11 08:01:20
that is how typeclasses work; they are just a "dictionary" with the methods
monochrom 2017-02-11 08:01:40
Oh wait, discord is voice?!
WzC 2017-02-11 08:01:56
sure, but I don't see a way of sneaking in the value of type a to use for the comparison though
osfameron 2017-02-11 08:01:59
dunno, I just googled it, saw VoIP and skype mentioned
mr_sm1th 2017-02-11 08:02:02
No it's just a proprietary chat/voice platform.
monochrom 2017-02-11 08:02:03
There is a reason I use IRC, not talk on the phone, you know that?
Welkin 2017-02-11 08:02:15
WzC: I'm not sure what you are asking
mr_sm1th 2017-02-11 08:02:34
In any case, I'm going to have to write my own nor operator?
Welkin 2017-02-11 08:02:54
WzC: just apply the function over the `a`
WzC 2017-02-11 08:03:11
sure, but then I have to apply all *n* of them to a,
monochrom 2017-02-11 08:03:13
mr_sm1th: Look into Data.Bits, it's what's already avaiable.
WzC 2017-02-11 08:03:18
I want to search in O(lg n) time
NeverDie 2017-02-11 08:03:24
mr_sm1th: Hmm, I see.
mr_sm1th 2017-02-11 08:03:43
monochrom: Looks like it then.
WzC 2017-02-11 08:04:08
maybe mapMonotonicKeys works, I don't know if that function is lazy enough
mr_sm1th 2017-02-11 08:04:20
nor = not xor
mr_sm1th 2017-02-11 08:04:25
that works I suppose
monochrom 2017-02-11 08:04:30
No no!
monochrom 2017-02-11 08:04:48
nor x y = not (x || y)
nshepperd 2017-02-11 08:04:57
e: hm, that does actually compile to a loop in ghc. how sad.
mr_sm1th 2017-02-11 08:05:34
oh I'm actually looking for a && b || !a && !b
mr_sm1th 2017-02-11 08:05:44
I don't even know what it's called my god
monochrom 2017-02-11 08:05:47
Ah that yes.
WzC 2017-02-11 08:05:47
doesn't look like it at least
Lokathor 2017-02-11 08:05:55
Discord has a texual chat in all channels, and some channels can have voice enabled as well
monochrom 2017-02-11 08:05:58
People call it xnor, I call it equality.
mr_sm1th 2017-02-11 08:06:27
monochrom: ^^
mr_sm1th 2017-02-11 08:06:48
I was confused because my predicate itself is an equality.
monochrom 2017-02-11 08:06:50
I call it equality because my thesis supervisor calls it equality and I learned from him.
mr_sm1th 2017-02-11 08:06:53
But thanks
mr_sm1th 2017-02-11 08:07:07
monochrom: Your thesis advisor sounds like wise (wo)man.
monochrom 2017-02-11 08:07:16
YES!
boarders_ 2017-02-11 08:07:49
if I write my own implementation of church numerals in haskell like the bottom here: http://shhaumb.github.io/arithmetical-theorems-with-lambda-calculus/
boarders_ 2017-02-11 08:08:13
how can I get it to write a convert from numbers into unary notation
boarders_ 2017-02-11 08:08:26
like into succ(succ(succ(...succ zero))...)
Tuplanolla 2017-02-11 08:08:30
Surely we should enumerate all the 16 possible function and name them.
nshepperd 2017-02-11 08:08:48
WzC: you're doing a point query given two values a, b and you want to find all functions where f a == b?
lambdamu 2017-02-11 08:09:14
Hi, is there a way to make this work http://lpaste.net/352399, it works with Show instead of ShowEq the compound constraint seems to be not passable as an type argument, I guess this is to be expected?
boarders_ 2017-02-11 08:09:32
or maybe I should ask why convert 0 = zero and convert n+1 = succ (convert n) is not valid?
WzC 2017-02-11 08:10:11
yes, (and I'll give you that the Set is somehow build s.t. it is ordered on the b values)
monochrom 2017-02-11 08:10:13
lambdamu: IIRC there is one more extension for that
nshepperd 2017-02-11 08:10:46
WzC: this won't work with arbitrary functions, you'll need more structure on them to search efficient
lambdamu 2017-02-11 08:10:50
monochrom: Ah, got a name? I activated quite a lot already
monochrom 2017-02-11 08:11:00
I forgot
WzC 2017-02-11 08:11:43
nshepperd: given that I tell you that if I were to evaluate all of them, the b values would be ordered I should be able to get O(log n) query
lambdamu 2017-02-11 08:12:07
monochrom: It is not one of those http://lpaste.net/352401
nshepperd 2017-02-11 08:12:08
WzC: eg. an ordering on the functions such that f < g means that forall a. f a < g a
WzC 2017-02-11 08:12:08
(as some background context: I'm implementing a sweep-line algo)
d_tox 2017-02-11 08:12:50
Has anyone seen a Prolog interpreter implemented in Haskell?
Tuplanolla 2017-02-11 08:13:09
Why, d_tox? Did you lose one?
WzC 2017-02-11 08:13:20
i.e. I'll give you a datastructure d, storing functions of type a -> b, where b is ordable, and as a query I now give you an a, and I promise you that *if* i were to do a : fmap (a $) on my data structure, the b's would be in order
WzC 2017-02-11 08:13:26
can you find them in O(log n) time
d_tox 2017-02-11 08:13:31
Tuplanolla: ^o^. Nope, but looking for one ^^
nshepperd 2017-02-11 08:13:44
WzC: hm, I see
WzC 2017-02-11 08:13:52
I'm hoping to reuse Data.Set/Data.Map somehow
WzC 2017-02-11 08:14:04
without having to reimplement that
Tuplanolla 2017-02-11 08:14:08
@hackage prolog
lambdabot 2017-02-11 08:14:08
http://hackage.haskell.org/package/prolog
d_tox 2017-02-11 08:14:45
Tuplanolla: Thank you! Will look into it!
WzC 2017-02-11 08:14:46
if mapWithKeys would be lazy I guess it would suffice, but since the trees behind Data.Set seem to have a strict spine I don't think that works
monochrom 2017-02-11 08:15:18
lambdamu: I'm now wondering if it's just "it's a type synonym with a parameter, so you always have to name the parameter syntactically"
WzC 2017-02-11 08:15:24
mapKeysMonotonic* I mean
monochrom 2017-02-11 08:15:26
s/name/give/
nshepperd 2017-02-11 08:15:35
given this is a sweepline algorithm I guess the ordering property here is going to be kind of dynamic and depend on the current 'a'
monochrom 2017-02-11 08:15:50
i.e. it wants you to write "ShowEq something" not "ShowEq" alone
WzC 2017-02-11 08:16:31
nshepperd: exactly
lambdamu 2017-02-11 08:16:56
monochrom: Yes I suspect this is to be expected type synonyms are probably reduced immediately
boarders_ 2017-02-11 08:17:24
oh nevermind I was just being a fool above
lambdamu 2017-02-11 08:17:37
monochrom: Makes ConstraintKinds a little less useful
nshepperd 2017-02-11 08:17:48
WzC: probably I would put these in a Data.Sequence and do a binary search manually
WzC 2017-02-11 08:17:53
in my current approach I reimplemented a part of a balanced BST, but I keep needing more of the ops in Data.Set that I kind of just want to reuse it
WzC 2017-02-11 08:18:13
nshepperd: the crappy thing is that Data.Sequence doesn't support binary searching in O(log n) time, it only gives O(log^2 n) time
WzC 2017-02-11 08:18:36
which proabaly doesn't show up in practice, but I'd like to use a proper solution if possible
nshepperd 2017-02-11 08:19:13
WzC: Otherwise, I think you could use a Data.Map if you wrap these in a newtype and use unsafe Data.Reflection voodoo to provide the 'current' value of 'a' for each operation
monochrom 2017-02-11 08:19:28
lambdamu: Maybe LiberalTypeSynonyms allows it. If not, I don't know.
nshepperd 2017-02-11 08:19:53
newtype DynamicOrd s a b = Do (a -> b)
nshepperd 2017-02-11 08:20:39
instance Reifies s a, Ord b => Ord (DynamicOrd s a b) where { ... }
nshepperd 2017-02-11 08:21:11
and then you wrap each call to Map functions with 'given' providing the current 'a'
WzC 2017-02-11 08:21:23
hmm that is an interesting idea
WzC 2017-02-11 08:21:52
let's see if I can get s.t. like that to work
nshepperd 2017-02-11 08:22:01
Do f < Do g = let a = reflect Proxy in f a < f g
volhovm 2017-02-11 08:24:08
Hi! I'm logging some data with exclusive lock (hslogger does that i suppose) and trying to read those logs to send them at the same time.
volhovm 2017-02-11 08:24:34
the read log fails with "openBinaryFile: resource busy (file is locked)", it seems like i'm missing something
volhovm 2017-02-11 08:24:56
so lock is one-process-only? i can read logs with cat w/o problems
Tuplanolla 2017-02-11 08:25:40
What should happen when the reader reaches end of file, volhovm?
nshepperd 2017-02-11 08:25:45
WzC: Yet another alternative would be to roll your own http://hackage.haskell.org/package/fingertree instead of using Data.Sequence, and do binary search in log(n) then
volhovm 2017-02-11 08:26:26
Tuplanolla: i suppose i'd be okay with any number of finished lines in it.
WzC 2017-02-11 08:26:42
nshepperd: do you have an estimate how much overhead the Reflection stuff would give?
nshepperd 2017-02-11 08:29:00
WzC: I would expect it to be compiled down to basically what you would write by hand for a 'dynamic' Map, assuming the Ord instance is inlined
nshepperd 2017-02-11 08:29:12
basically the Map functions taking an extra argument
WzC 2017-02-11 08:29:44
hmm ok that is quite ok it seems
WzC 2017-02-11 08:30:03
it does seem that I will have to drag around Typable a constraints everwhere then
nshepperd 2017-02-11 08:30:36
huh, that shouldn't be required
WzC 2017-02-11 08:31:30
hmm maybe I'm missing something about that approach then, let me read through the docs for a bit longer
codedmart 2017-02-11 08:32:22
Anyone with some pointers? I would like to use a uuid as my Primary key with persistent.
hugh-adolph 2017-02-11 08:37:57
https://www.youtube.com/watch?v=1aqLpNXQsUI
monochrom 2017-02-11 08:38:21
What is that video?
monochrom 2017-02-11 08:39:17
OK you are a spammer.
hugh-adolph 2017-02-11 08:39:19
yes it is a video
monochrom 2017-02-11 08:40:49
And are they trying to compete with me in my niche of tautologies?!