But it looks like the sequence is only ever accessed with consing and unconsing. If so, would it be possible to change the implementation to use lists instead? Maybe something like:
instance Representable f => Representable (Cofree f) where
type Rep (Cofree f) = [Rep f]
index = flip (foldr f extract) where
f x xs ys = xs (index (unwrap ys) x)
tabulate = coiterW (\f -> tabulate (\x -> f . (:) x))
The extra flexibility and lower overhead of lists would be handy, and I haven't seen any of the extra features of sequences being used with this instance.
The index for
Cofree
is currentlySeq
from Data.Sequence:https://github.com/ekmett/adjunctions/blob/3040e61f1dcae3fb108cc2e0e03239afcb35479d/src/Data/Functor/Rep.hs#L505-L510
But it looks like the sequence is only ever accessed with consing and unconsing. If so, would it be possible to change the implementation to use lists instead? Maybe something like:
tabulate
could alternatively be:The extra flexibility and lower overhead of lists would be handy, and I haven't seen any of the extra features of sequences being used with this instance.