Search Haskell Channel Logs

Tuesday, February 7, 2017

#haskell channel featuring ph88_, ph88, stephaner, ertes, jophish, muzzle, and 10 others.

tabaqui1 2017-02-07 05:45:22
so most of haskell developers prefers to optimize memory agains speed?
merijn 2017-02-07 05:45:36
IntSet is a patricia tree, afaik
merijn 2017-02-07 05:45:50
Which is similar, but not quite a radix, iirc
tabaqui1 2017-02-07 05:45:52
or they think, that I can choose between them, just by adding new Int in structure>
tabaqui1 2017-02-07 05:45:53
?
ertes 2017-02-07 05:46:09
tabaqui1: it's not an optimisation, it's just: "this data structure doesn't need to know the size for efficiency, so we don't store it"
byorgey 2017-02-07 05:46:19
tabaqui1: there's no way to generalize to all Haskell developers by looking at a single library.
ertes 2017-02-07 05:46:32
tabaqui1: users who need the size can keep track of it themselves (or pay the cost to compute it on the fly)
ertes 2017-02-07 05:47:42
tabaqui1: after all you could ask the same question of 'length' for '[]'
tabaqui1 2017-02-07 05:48:04
in case of lists, it pretty clear for me
tabaqui1 2017-02-07 05:48:24
after all they can have infinite size
ertes 2017-02-07 05:48:47
that doesn't mean that you couldn't store the size anyway… the size field would just diverge for infinite lists =)
ertes 2017-02-07 05:49:04
just make sure the size field isn't strict
tabaqui1 2017-02-07 05:49:27
hm, ok, data for the god of data
ertes 2017-02-07 05:52:21
merijn: the terminology is a bit overloaded… a trie is supposed to branch for every bit, while a radix tree is supposed to branch more effectively… you could probably say that a PATRICIA/"critbit" tree is a structure that branches most effectively
recursion-ninja 2017-02-07 05:55:00
Hey I want to use the function: GHC.Integer.Logarithms.integerLog2# on some `Integer` value but the compiler says " Couldn't match a lifted type with an unlifted type". How do I use the function?
jophish 2017-02-07 05:56:12
recursion-ninja: flog2 :: Natural -> Natural; flog2 x = fromIntegral (I# (integerLog2# (toInteger x)))
glguy 2017-02-07 05:56:30
recursion-ninja: If you don't want to dive into GHC internals you can use a package like http://hackage.haskell.org/package/integer-logarithms-1.0.1/docs/Math-NumberTheory-Logarithms.html
jophish 2017-02-07 05:56:49
you can use Integer and Int instead of Natural by dropping toInteger and fromIntegral
recursion-ninja 2017-02-07 05:57:01
I just need the `countLeadingZeros` with reasonable time complexity
recursion-ninja 2017-02-07 05:57:32
On Integers, which, for obvious reasons aren't instances of FiniteBits...
merijn 2017-02-07 05:58:02
recursion-ninja: Well, what would the leading zeros on an Integer be?
merijn 2017-02-07 05:58:14
Wouldn't that just always be either 0 or infinity?
recursion-ninja 2017-02-07 05:58:49
Fine trailing zeros, the zeros beofre the least significant bit
recursion-ninja 2017-02-07 05:59:19
I need `BitVector` to be an instance of FiniteBits which uses an `Integer` internally to store the bits.
ertes 2017-02-07 06:00:02
recursion-ninja: is there a difference between BitVector and Natural?
recursion-ninja 2017-02-07 06:00:31
Yes, BitVector has a dimension. It contains a finite number of bits
ertes 2017-02-07 06:00:42
statically?
recursion-ninja 2017-02-07 06:01:11
ertes: It's my understanding that Natural has no finite number of bits
ertes 2017-02-07 06:01:54
that's correct, but how does your BitVector constrain the size? its only option for FiniteBits to make sense is via a type argument
recursion-ninja 2017-02-07 06:01:55
ertes: Not statically, but the type signature for `finiteBits :: b -> Int` doesn't require the bits to be static across all values.
ertes 2017-02-07 06:02:34
finiteBitSize is supposed to return the *size* of the *type*, not the base 2 logarithm of the argument
glguy 2017-02-07 06:02:47
recursion-ninja: No, it's expected to ignore it's argument
glguy 2017-02-07 06:02:53
"Return the number of bits in the type of the argument. The actual value of the argument is ignored."
glguy 2017-02-07 06:02:59
http://hackage.haskell.org/package/base-4.9.1.0/docs/Data-Bits.html#v:finiteBitSize
ertes 2017-02-07 06:03:13
> finiteBitSize (0 :: Int64)
lambdabot 2017-02-07 06:03:15
64
ertes 2017-02-07 06:03:18
> finiteBitSize (15 :: Int64)
lambdabot 2017-02-07 06:03:21
64
glguy 2017-02-07 06:03:38
recursion-ninja: You should expect a user to provide 'undefined' as the argument to that class method and for that to work
recursion-ninja 2017-02-07 06:03:49
glguy: I've read that. But if it's expected to ignore the argument why isn't the type signature: `finiteBits :: Int`? Obviously this hack exists for my use case.
glguy 2017-02-07 06:04:07
recursion-ninja: Your proposed type couldn't fit into the typeclass
ertes 2017-02-07 06:04:33
recursion-ninja: because of the way type classes work… the proper type would be: finiteBitSize :: (FiniteBits a) => proxy a -> Int
ertes 2017-02-07 06:04:45
but for historical reasons (i guess) it doesn't use a proxy
glguy 2017-02-07 06:04:51
(he left)
ertes 2017-02-07 06:04:58
ah
christiaanb 2017-02-07 06:06:36
ertes: the proper type would be "finiteBitSize :: FiniteBits a => proxy a -> Word"
reactormonk 2017-02-07 06:10:14
https://hackage.haskell.org/package/uri-conduit-1.1.1.2 is deprecated - how do I find out what is the succeeding package?
glguy 2017-02-07 06:12:10
reactormonk: You could email the author or try a web search to see if the author said anything about it online.
ph88 2017-02-07 06:16:10
lyxia, the expected result should be either passed down to the arbitraryT function, or the arbitraryT function should be able to detect it from the context (which i don't think is possible .. but who knows). Unlike a parsing function arbitrary is not working on a stream and so i don't think there is lookahead to what the next arbitrary value will be (need to reverse the order of the execution here as well)
ph88_ 2017-02-07 06:19:46
:)
stephaner 2017-02-07 06:31:00
hi everyone, in this code http://lpaste.net/352179 , I don't understand why I need to use the bang pattern, why deepseq alone is not sufficient so as the content of the file is evaluated strictly ?
nitrix 2017-02-07 06:33:23
stephaner: I think that's because it only calls the `depseq` if the value is needed.
stephaner 2017-02-07 06:34:08
ok, there is a thunk just above deepseq that isnt evaluated
nitrix 2017-02-07 06:34:18
So if strictContent is needed lazily, deepseq doesn't have a chance to evaluate the data structure deeply.
nitrix 2017-02-07 06:34:23
stephaner: That's my guess.
stephaner 2017-02-07 06:34:39
good guess, that's partly why I try the bang pattern
nitrix 2017-02-07 06:34:44
stephaner: Your let-expression is similar to `force` from the same module you're using and it's documented this way.
stephaner 2017-02-07 06:34:46
I will try to verify this
stephaner 2017-02-07 06:35:13
oh ? thanx
stephaner 2017-02-07 06:35:21
I will check the documentation then, thx
nitrix 2017-02-07 06:35:46
"a variant of deepseq that is useful in some circumstances:"
nitrix 2017-02-07 06:35:48
"force x = x `deepseq` x"
nitrix 2017-02-07 06:35:53
"force x fully evaluates x, and then returns it. Note that force x only performs evaluation when the value of force x itself is demanded, so essentially it turns shallow evaluation into deep evaluation."
recursion-ninja 2017-02-07 06:36:41
Is there a predefined function I can use of type: `Integer -> [Word]` or `Integer -> [Int]` that will give me the "byte/int/word array" backing of the `Integer` value so I can opperate on it block by block?
muzzle 2017-02-07 06:38:16
recursion-ninja Data.Binary.encode ?
muzzle 2017-02-07 06:38:49
which gives you a bytestring, that you can unpack into a [Word8]
muzzle 2017-02-07 06:38:53
?
recursion-ninja 2017-02-07 06:39:24
muzzle: will that operate in O( log-base< machine-word-size>(n) )
muzzle 2017-02-07 06:40:53
recursion-ninja, I'm not really sure
muzzle 2017-02-07 06:40:58
maybe someone else knows
stephaner 2017-02-07 06:41:27
nitrix, where do you read the documentation ? you had to generate it ?
recursion-ninja 2017-02-07 06:42:04
muzzle: I was hoping for a larger word size than 8 bits so that the logrimic complexity of the operation would have a much higher base. a list of Word32 or Word64 would be preferable. Does Data.Binary have something that outputs a lis of larger Word sizes
muzzle 2017-02-07 06:43:19
recursion-ninja, I don't think so
muzzle 2017-02-07 06:43:48
recursion-ninja, encoding with Data.Binary gives you a ByteString which is Word8-backed
geekosaur 2017-02-07 06:44:51
only when unpacked. ByteString itself is stored in a packed byte format