Last active
February 16, 2018 22:06
-
-
Save cemerick/2f83ec0e792f8abdfecbd2e50b0e637e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- tweaking `CLaSH.Sized.Vector.vfold` so that an initial vector can be provided/built upon | |
-- reusing the `Append` motive from the main `dfold` example | |
data Append (m :: Nat) (a :: *) (f :: TyFun Nat *) :: * | |
type instance Apply (Append m a) l = Vec (l + m) a | |
vifold :: forall k j a b . (KnownNat k, KnownNat j) | |
=> (forall l . SNat l -> a -> Vec (j + l) b -> Vec (j + l + 1) b) | |
-> Vec j b | |
-> Vec k a | |
-> Vec (j + k) b | |
vifold f init xs = dfold (Proxy @(Append j b)) f init xs | |
{-# INLINE vifold #-} | |
{- | |
this works, though I'm getting complained at if I index into the accumulated | |
vector in my `f`: | |
No instance for (KnownNat l) arising from a use of `wfun' | |
Possible fix: | |
add (KnownNat l) to the context of | |
a type expected by the context: | |
SNat l | |
-> Unsigned 8 -> Vec (16 + l) Word32 -> Vec ((16 + l) + 1) Word32 | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment