This is a (low-prio) feature request. Comonad interface is very convenient for looking at a vector from all perspectives (indices) at once. It allows tranformations of the entire vector by allowing the mapping to peek into neighbouring elements . Think blurring of pixels 0, or other image transformations 1. Writing down the instance is easy:
{-# language DeriveFunctor, TupleSections #-}
module CoVec where
import CLaSH.Prelude hiding (extend)
import Control.Comonad
newtype CoVec n a = CoVec (Index n, Vec n a) deriving (Eq, Show, Functor)
instance KnownNat n => Comonad (CoVec n) where
extract (CoVec (i, v)) = v !! i
duplicate (CoVec (i, v)) = CoVec (i, CoVec . (,v) <$> indicesI)
The question is whether one wants to add the Comonad dependency.
Another problem might be the consumption of logical resources (LUTs). I did not evaluate this issue.
This is a (low-prio) feature request.
Comonad
interface is very convenient for looking at a vector from all perspectives (indices) at once. It allows tranformations of the entire vector by allowing the mapping to peek into neighbouring elements . Think blurring of pixels 0, or other image transformations 1. Writing down the instance is easy:The question is whether one wants to add the
Comonad
dependency.Another problem might be the consumption of logical resources (LUTs). I did not evaluate this issue.