Requirements for collections extensions #725
Replies: 1 comment
-
DecisionsResults from a meeting with @ss2165 and @doug-q Core collections extensionThe core collections extension will contain the following ops:
Considered but rejected for now
Guppy extensionFurthermore, we will define a custom Guppy extension for special collection ops that are required by Guppy. This extension will live in the Guppy repo. Some of these ops might also be replaced with a Guppy implementation in the future.
UnclearSome list operations require that the element type is equatable or sortable. It would be nice if the corresponding hugr ops could take an equality or ordering predicate as an argument. However, following the proposed changes in #285 (comment) it would become impossible to use polymorphicly defined functions in this context. Until this question is resolved, we delay making a decision on the following ops:
|
Beta Was this translation helpful? Give feedback.
-
The current
Collections
extension is mostly a placeholder and only defines two ops. Below are some list ops that are required for Guppy:List(T) -> T, List(T)
orList(T) -> Sum((T, List), Error)
T, List(T) -> List(T)
List(T) -> int
orList(T) -> int, List(T)
?List(T), int -> T
orList(T), int -> T, List(T)
but the element is not removed from the list!Nice to have ops (but could also be implemented by hand):
T, T, ... -> List(T)
List(T), int -> T, List(T)
List(T) -> Bool
List(T) -> Bool
List(T), List(T) -> List(T)
(List(T), Int) -> List(T)
for copyableT
(List(T), T) -> Int
for equatableT
(List(T), T) -> Int
for equatableT
(S -> T), List(S) -> List(T)
(T -> Bool), List(T) -> List(T)
(S -> Bool), (S -> T), List(S) -> List(T)
List(S), List(T) -> List(Tuple(S, T))
List(T) -> List(T)
(T, T -> Bool), List(T) -> List(T)
List(T), T -> Bool
for equatableT
At the moment, we only target immutable classical lists for Guppy. However, later we might also want updating at a given index:
List(T), int, T -> List(T)
.Would it make sense to add a notion of immutable list to Hugr? The Hugr runtime wouldn't need to copy these lists if a port is connected multiple times.
Generally, some of the functions above only make sense for non-linear lists (e.g. Filter). Do we want to offer different APIs depending on linearity?
Beta Was this translation helpful? Give feedback.
All reactions