Integrated Dynamics

Integrated Dynamics

63M Downloads

Currying twice fails

bsngardner opened this issue ยท 6 comments

commented

This is rather complicated, and my attempts to isolate the bug did not help much. I hope I can explain in a clear way.
(Asp = Thaumcraft Aspect)

I have a complicated operator with this signature, pardon my notation:

pickitem = Op[Asp->Asp->Item]

I am trying to gate this with another operator:

gate = Op[Item->Item] => choice[redstone -> stick -> Item -> Item]
(stick doesn't matter; the important bit is that the argument is consumed and the 
last argument is curried)

Both of these work correctly apart but fail when piped together:

gated_item = Op[Asp->Asp->Item] => pipe[pickitem -> gate -> Op]

I have tested simplified versions of pickitem, and they work correctly. So the structure of this operator is important.
The entire point of this first part is to map an int between 0-250 to 0-2 with arbitrary partitions between the final values.

partitions = {160,200}
(I don't know the notation to explain this, but it is a curried apply operator. 
Filter predicate depends on Asp count since it compares Asp count to list items):
filter = Op[Asp->Op[Int->Bool]] (from Op[Asp->Int] and Op[Int->Int->Bool])
index = Op[Asp->Int] (filter the partitions list above and find the length)

This part filters an inventory for the item with it's first aspect matching the aspect argument, then appends that found item to a static list of 2 other items. This list is indexed by the index above.
(This operator also has currying, to convert a filter Op[Asp->Item->Bool] to Op[Asp->Op[Item->Bool]])

inv_filter = Op[Asp->Op[Item->Bool]]
itemlist = Op[Asp->List] 
(pipe inv_filter to filter[Op->List] to filter inventory list, pipe to head[List->Item], 
pipe to append[Item->List], where append is curried with a static list)

Put the two parts together to make pickitem

pickitem = Op[Asp->Asp->Item] => get[itemlist[Asp->List] -> index[Asp->Int] -> Item]

There are a lot of flips and applies to put all of these together which I don't have a good notation for expressing. I hope this makes sense; In the end, I have 2 curried operators that I pipe into another operator. When the resulting operator is piped to another curried operator (gate), it does not work. The display panel shows an X but there is no error message; the interface shows a check mark.

If you have a better way to explain the reproduction of this, let me know.
Thanks

Minecraft 1.12.2
Integrated Dynamics 1.1.1
Integrated Tunnels 1.6.10
Forge 14.23.5.2847

commented

Do you see any errors in your console? Or is this problem purely restricted to the game itself?
If the latter, perhaps @GreyMario may be able to help.

commented

There is no error in the console either. When I place the operator in a display panel, there is just an X on the screen.
If I try to use the operator, I do get an error when trying to display the result. With such complicated operators, it's hard to piece together what is failing, but this is the error message:
"The operator choice received an input with type Operator at position 2 while the type Item was expected."
pickitem has output of Item (and this works as expected alone), so I'm not sure how the choice is getting an Operatorwhen pickitem is piped to it.

commented

An interesting note to add: The pickitem operator described above works correctly with display panels, but the Item it returns does not work in output interfaces like Item Exporter (Export Item slot) or Player Simulator (Click Item slot). The correct item shows in the user interface of the part, but the part does not do anything with it. There is no error message, in the user interface or in the server console. If I materialize the output and put that card in, it does work, so there's not some expected reason for this not to work.
This might be an Integrated Tunnels bug, but I mention it here because it might point someone who knows the code better to the right place.

commented

Apologies for not poking my nose in here when I was mentioned. I'd meant to, but it slipped my mind.

I might get a chance soon enough to try looking into this. This involves TC6 and InDy's Thaumcraft integration?

commented

There is a good chance it does. I tried to create a simpler reproducer by cutting out the Thaumcraft operators, but it worked just fine. It's been a little while since I looked at it. Let me know if you need more information; I know my explanation is hard to follow.

In case it helps you follow it, the point of the operator is to have inputs from aspect readers (I forgot which reader it is actually) to detect what aspect goes in a jar (from suction--the jar label) and how much essentia is in there. There is a jar with a reader and a player simulator for each aspect. If the amount is below the first partition limit, the operator selects the correct aspect phial from a storage system (storage drawers) and the player simulator fills the jar. In the middle partition, it does nothing. If the essentia amount goes above the higher limit, an empty phial is selected, and it empties the jar.

commented

Feel free to comment if there is any additional information, closing until then.