Make vectorTH use singleton when possible.
[matthijs/master-project/support/tfvec.git] / Data / Param / TFVec.hs
index 529c52c12a163dfb3b31397ddfbd987189e78ca4..33758f9f5762aec6b422493be1b5b8f22887ac39 100644 (file)
@@ -100,9 +100,10 @@ vectorCPS xs = unsafeVectorCPS (toInteger (P.length xs)) xs
 
 -- FIXME: Not the most elegant solution... but it works for now in clash
 vectorTH :: (Lift a, Typeable a) => [a] -> ExpQ
-vectorTH xs = sigE [| (TFVec xs) |] (decTFVecT (toInteger (P.length xs)) xs)
--- vectorTH [] = [| empty |]
--- vectorTH (x:xs) = [| x +> $(vectorTH xs) |]
+-- vectorTH xs = sigE [| (TFVec xs) |] (decTFVecT (toInteger (P.length xs)) xs)
+vectorTH [] = [| empty |]
+vectorTH [x] = [| singleton x |]
+vectorTH (x:xs) = [| x +> $(vectorTH xs) |]
 
 unsafeVector :: NaturalT s => s -> [a] -> TFVec s a
 unsafeVector l xs
@@ -349,4 +350,4 @@ lexTFVec :: ReadS String
 lexTFVec ('>':rest) = [(">",rest)]
 lexTFVec ('<':rest) = [("<",rest)]
 lexTFVec str = lex str
-                                           
\ No newline at end of file
+