X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fmaster-project%2Fsupport%2Ftfvec.git;a=blobdiff_plain;f=Data%2FParam%2FTFVec.hs;h=7a0fa1dcc0ab1d1d000bd497097944ebbec64297;hp=fd620e74887df2bb2349170252573c181e5cfa4b;hb=74aad9e23f7b911124ece69b2886f4ec0c88e390;hpb=c10bc759aefb228a7471f4230c3b19c9735b788e diff --git a/Data/Param/TFVec.hs b/Data/Param/TFVec.hs index fd620e7..7a0fa1d 100644 --- a/Data/Param/TFVec.hs +++ b/Data/Param/TFVec.hs @@ -69,7 +69,7 @@ import Prelude hiding ( zipWith, zip, unzip, concat, reverse, iterate ) import qualified Data.Foldable as DF (Foldable, foldr) import qualified Data.Traversable as DT (Traversable(traverse)) -import Language.Haskell.TH +import Language.Haskell.TH hiding (Pred) import Language.Haskell.TH.Syntax (Lift(..)) newtype (NaturalT s) => TFVec s a = TFVec {unTFVec :: [a]} @@ -95,8 +95,11 @@ singleton x = x +> empty vectorCPS :: [a] -> (forall s . NaturalT s => TFVec s a -> w) -> w vectorCPS xs = unsafeVectorCPS (toInteger (P.length xs)) xs +-- FIXME: Not the most elegant solution... but it works for now in clash vectorTH :: Lift a => [a] -> ExpQ -vectorTH xs = (vectorCPS xs) lift +-- vectorTH xs = (vectorCPS xs) lift +vectorTH [] = [| empty |] +vectorTH (x:xs) = [| x +> $(vectorTH xs) |] unsafeVector :: NaturalT s => s -> [a] -> TFVec s a unsafeVector l xs