spikefoo 2017-02-07 09:46:29
kubbe: I think it's better to use 'data PriorityQueue = ...' instead. That way priority queues are a different type than lists, which makes sure you never use a list as a priority queue
kubbe 2017-02-07 09:47:21
spikefoo, you are probably right but we are 'forced' to use type. We are supposed to learn how to handle types and typeclasses aswell. I would not have done this way normal
kubbe 2017-02-07 09:49:19
but in this case; the priotityqueue-type is returning a list of the two values I have in the tree, right? spikefoo
spikefoo 2017-02-07 09:49:59
kubbe: make sure your assignment is to really use a 'type' statement, because only a 'data' statement actually creates a new type. 'type' statements do not create a new type, only an alias
spikefoo 2017-02-07 09:50:55
kubbe: It looks like you're not using the Tree data type you defined. Are you implementing a priority using an array or using a heap (tree)?
kubbe 2017-02-07 09:54:07
I am not really sure if im honest. I am supposed to use heaps, but I havn't really understood whats up. Since I am creating arrays of tuples with the values. And the least-function is supposed to take out the lowest rank (the int-value) from I gues the array. And the input-examples you can see under the function-specs
kubbe 2017-02-07 09:57:37
I am only using the Tree data type in the Heap data type. But I am not sure what either is doing. Especially confused around the "[Tree a]" in the Tree data type spikefoo
spikefoo 2017-02-07 09:58:23
kubbe: did you write the definitions of Tree and Heap, or are they part of the assignment?
spikefoo 2017-02-07 09:59:39
kubbe: if you're implementing a priority queue using a heap, you don't need a [(a,Int)] list. Just a heap (a tree whose root is the minimum element)
kubbe 2017-02-07 09:59:41
I wrote the definitions on the data types Tree and Heap. They are not really that important, but that is the way we did trees before. And I have understood that the Heap is supposed to create an array of trees? Why, I have no idea spikefoo
kubbe 2017-02-07 10:00:22
Oh, okey. How do I create that? I got a bunch of errors when I tried to return Heap directly into PQ a
c_wraith 2017-02-07 10:00:44
"heap" is a name shared by a lot of partially ordered data structures.
spikefoo 2017-02-07 10:02:03
kubbe: if you write 'data PriorityQueue a = PriorityQueue [(a, Int)]', use can use 'PriorityQueue lst' to make a priority queue out of list lst. so empty becomes 'empty = PriorityQueue []'
spikefoo 2017-02-07 10:02:54
kubbe: but if you're implementing a heap, you don't need that array. You only a need a tree.
kubbe 2017-02-07 10:03:13
Alright, 2 sec im gonna write it. I have some "Hows it going"-class tomorrow where I'll ask if the code is OK. But I think that as long as I can explain whats up then it'll be fine
kubbe 2017-02-07 10:03:48
Okey, are those two variants different? The thing where I re-write the priorityqueue or where I change the data types? spikefoo
spikefoo 2017-02-07 10:06:09
kubbe: if you're using the heap implementation, you'll only use one data definiton: 'data PriorityQueue = ...' to define it as a tree structure. If you're implementing using an array, you'll also use a single data definition 'data PriorityQueue = PriorityQueue [(a,Int)]'.
spikefoo 2017-02-07 10:06:38
So, you only need one data definition any way
spikefoo 2017-02-07 10:06:52
I'm guessing you need to implement a binary heap, if you learned about trees
spikefoo 2017-02-07 10:07:08
so find out what implementation you need to write
kubbe 2017-02-07 10:07:46
Yes, I do need to implement a binary heap. Trees have been the focus for a few classes now. Now I heard that I can use w/e definition of priorityqueue. Its my choosing, and therefor I can have w/e data types aswell
spikefoo 2017-02-07 10:09:05
kubbe: so you only a single definition 'data PriorityQueue = ...'. There's no need to define the Tree and Heap data structures.
spikefoo 2017-02-07 10:09:11
*only need
kubbe 2017-02-07 10:09:20
I think I'll try it with the heap implementation. But if Im not going to have heap as a data type, should it be a type statement instead?
spikefoo 2017-02-07 10:12:20
kubbe: you can define a single data type called PriorityQueue, you don't need a data type named "Heap". The PriorityQueue itself will be a binary heap
kubbe 2017-02-07 10:13:09
thats cool! Okey. I guess it will look the same as my data Tree does at the moment?
kubbe 2017-02-07 10:13:15
spikefoo
spikefoo 2017-02-07 10:14:40
kubbe: yes, except you don't want a list of children ([PriorityQueue]), becuase there are at most two children for each node, not any number of children
kubbe 2017-02-07 10:16:19
Oh, and then I'll create the tree recursivly instead? Like this: http://pastebin.com/JGJ5BwKL spikefoo
spikefoo 2017-02-07 10:17:18
kubbe: exactly. you need to update 'empty' now for this new implementation
kubbe 2017-02-07 10:19:19
So 'empty' should now return the empty tree?
spikefoo 2017-02-07 10:19:26
kubbe: yes
AWizzArd 2017-02-07 10:20:27
One „problem" of static type checking for example in Java is: when you want to implement an interface you need to implement all methods at once. But typically a dev wants to implement one specific functionality.
AWizzArd 2017-02-07 10:20:31
If the compiler now rejects incomplete implementations then some stub methods need to be added. It could happen that they are forgotten later.
AWizzArd 2017-02-07 10:20:36
How does this work out with Haskell, when one wants to make a data type an instance of a Type Class?
kubbe 2017-02-07 10:20:43
spikefoo: in my point it should just say "empty = Empty"?
spikefoo 2017-02-07 10:20:54
kubbe: yes
spikefoo 2017-02-07 10:21:14
i'm ave to go now
spikefoo 2017-02-07 10:21:16
bye
EvanR 2017-02-07 10:23:06
AWizzArd: classes with a huge number of interfaces that you dont want to fully implement? sounds broken
EvanR 2017-02-07 10:23:29
a huge number of methods*
EvanR_ 2017-02-07 10:23:59
however you dont have to implement anything if you dont want to, you can leave it undefined, in which case itll crash at runtime
AWizzArd 2017-02-07 10:25:14
EvanR: probably one would like to implement all methods belonging to an interface, but not at the moment of realization that a type should belong to a certain type class.
EvanR_ 2017-02-07 10:25:59
haskell definitely supports incomplete programs
EvanR_ 2017-02-07 10:27:15
i just write the code
EvanR_ 2017-02-07 10:27:24
instance Show Foo where -- nothing else
EvanR_ 2017-02-07 10:27:36
code loads, gives me a warning
sshine 2017-02-07 10:27:39
AWizzArd, not sure Haskell is any different there. you might leave a bunch of 'undefined's around and forget about them. in both cases one should be able to detect such matters using a lint tool.
EvanR_ 2017-02-07 10:28:09
show Foo gives me a freeze up
AWizzArd 2017-02-07 10:30:56
Okay, so I can use instance TC MyType where … and simply not write implementations for all functions belonging to the type class TC.
nitrix 2017-02-07 10:32:52
mokus_: I opened https://github.com/mokus0/monad-loops/pull/16
nitrix 2017-02-07 10:33:20
mokus_: Let me know if you're actually the maintainer and if you need to discuss it.
nitrix 2017-02-07 10:40:22
Is async bounded threads known to not be compatible with runInBoundThread? Also, are there known issues for async on windows?
nitrix 2017-02-07 10:42:11
I'm getting really curious freezing of my SDL window, presumably stuck in a foreign call. It looks like there are no race conditions with the MVars I'm using, but that too is plausible.
nitrix 2017-02-07 10:42:42
If I had a memory corruption problem with local thread variables, would the Haskell runtime segfault instead of freezing?
nitrix 2017-02-07 10:43:04
GHC detects MVar deadlocks too, I'm confused.
maerwald 2017-02-07 10:43:19
use promela :P