Search Haskell Channel Logs

Saturday, January 28, 2017

#haskell channel featuring boojinks, Dryvnt, ph88, qcrvszvz, JSharp, Axman6, and 5 others.

sjl__ 2017-01-28 00:47:00
thats currying
sjl__ 2017-01-28 00:47:02
https://wiki.haskell.org/Currying
boojinks 2017-01-28 00:47:07
the arrow is what is called 'right associative'
boojinks 2017-01-28 00:47:24
so the compiler reads that as something :: Int -> (Int -> Int)
boojinks 2017-01-28 00:47:56
which actually means something is a function that takes an Int and returns another function that takes an Int and returns an Int.
boojinks 2017-01-28 00:48:39
which is a somewhat foreign idea if you're used to Python so for the moment you could just think about it as a function that takes two Ints and returns an Int.
boojinks 2017-01-28 00:50:12
for example, addMyInts :: Int -> Int -> Int
Dryvnt 2017-01-28 00:56:25
Is this the place to request code reviews (Not now, but some uncertain time in the future several days away)?
systadmin 2017-01-28 00:56:39
boojinks: so I have a function that has a type of X, then I want the compiler to return it as Y, then I want the compiler to return Y as Z?
systadmin 2017-01-28 00:57:05
Dryvnt: can I see your code? :)
boojinks 2017-01-28 00:57:45
systadmin: assuming you meant it takes an X and a Y and gives you back a Z then yes
boojinks 2017-01-28 00:57:51
func :: X -> Y -> Z
ph88 2017-01-28 00:58:00
guys one advice, put OPTION Wall in your code .. it allowed me to catch quite a few more bugs
Dryvnt 2017-01-28 01:00:30
systadmin: Not yet. It's barely 40 lines. Just planning for the future.
systadmin 2017-01-28 01:00:39
Dryvnt: ok
ph88 2017-01-28 01:03:19
i was giving some extra constraints on an instance but ghc somehow figured out they are not needed, why does ghc say this?? https://paste.fedoraproject.org/538085/48560495/
Atlantic777 2017-01-28 01:07:37
Hi! I'm learning about functional programming way of solving problems through solving some problems from codechef in haskell (a competitive programming site). Now and then there is a problem which is well suited for stream processing but with a state object.
Atlantic777 2017-01-28 01:08:52
For example, one such problem is: there is a very long array of integers. All elements but one have it's pair. Find the element without pair.
systadmin 2017-01-28 01:09:35
Codechef?
Atlantic777 2017-01-28 01:09:37
One way would be to collect all elements of the array, sort, group, find the group with only one element, but this is somehow ackward.
Atlantic777 2017-01-28 01:10:42
systadmin: I'm sorry, here is the exact link to the site and the problem I'm giving as an example: https://www.codechef.com/problems/MISSP
systadmin 2017-01-28 01:11:21
Brb, I gotta restart my wifi
Atlantic777 2017-01-28 01:13:49
So, I feel like the fold approach could be suitable here.
Atlantic777 2017-01-28 01:15:15
Each time when a new element of array is "consumed", I create new state object. The end state object is then my final solution. Is a state object like this an ackward solution? Am I doing something wrong here?
qcrvszvz 2017-01-28 01:20:45
:t foldr
lambdabot 2017-01-28 01:20:47
Foldable t => (a -> b -> b) -> b -> t a -> b
Atlantic777 2017-01-28 01:23:01
thanks qcrvszvz, I'm familiar with foldr. I'm just asking for opinion what would be an elegant (and efficient) way for solving such problems. :)
qcrvszvz 2017-01-28 01:28:33
probably foldr ;)
qcrvszvz 2017-01-28 01:28:50
for efficiency: foldr'
boojinks 2017-01-28 01:29:16
I barely even understand that problem o.o
Axman6 2017-01-28 01:29:50
there is no foldr'
boojinks 2017-01-28 01:30:22
oh, I get it now. herpyderp.
boojinks 2017-01-28 01:31:55
Atlantic777: you certainly could implement it with a fold.
Axman6 2017-01-28 01:33:02
Atlantic777: what do you know about the values in the values in the input?
Atlantic777 2017-01-28 01:34:13
Axman6: well, I know that inputs are integers, that there is always odd number of elements in input and that exactly one element occurs only once, all other elements occur exactly twice.
Axman6 2017-01-28 01:35:03
hmm, looking at the problem, I'd be using a bit vector. complement the nth bit when you see it, then find the bit that's set at the end
Atlantic777 2017-01-28 01:35:48
Axman6: bit vectors can be indexed in constant time?
Axman6 2017-01-28 01:36:19
as constant as your hardware allows, sure
Axman6 2017-01-28 01:36:33
(constant time data structures are usually a lie)
JSharp 2017-01-28 01:36:43
I'm sure they mean O(1) ... which is theoretical.
Atlantic777 2017-01-28 01:37:35
Yup, I don't mean strictly O(1)
Axman6 2017-01-28 01:37:37
sure, but no hardware impements anything that would give you that for large enough n
JSharp 2017-01-28 01:38:01
*sigh* of course it does.
JSharp 2017-01-28 01:39:31
the measure is usually only good for relative performance judgements, when looking at abstract algorithms on *whatever* hardware -- which is its purpose.
JSharp 2017-01-28 01:40:03
you're technically correct, yes -- but that's also not the point of theoretical complexity measurements
Axman6 2017-01-28 01:40:12
I wasn't talking about abstract performance though, I was talking about the actual log n cost you pay for anything you use in memory
piyush-kurur 2017-01-28 01:42:14
does anyone know of automated randomness tests preferably with haskell interface. I would like to add tests of randomness to the prg in raaz
systadmin 2017-01-28 01:42:31
What do you call those `->` expressions again?
systadmin 2017-01-28 01:42:31
It's at the tip of my tongue
Axman6 2017-01-28 01:42:40
type signatures