From: Matthijs Kooijman Date: Mon, 17 Aug 2009 10:09:25 +0000 (+0200) Subject: Make vectorTH use singleton when possible. X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fmaster-project%2Fsupport%2Ftfvec.git;a=commitdiff_plain Make vectorTH use singleton when possible. This enabled the code generated by vectorTH to work with precision. --- diff --git a/Data/Param/TFVec.hs b/Data/Param/TFVec.hs index 1b2051e..33758f9 100644 --- a/Data/Param/TFVec.hs +++ b/Data/Param/TFVec.hs @@ -102,6 +102,7 @@ vectorCPS xs = unsafeVectorCPS (toInteger (P.length xs)) xs vectorTH :: (Lift a, Typeable a) => [a] -> ExpQ -- 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 @@ -349,4 +350,4 @@ lexTFVec :: ReadS String lexTFVec ('>':rest) = [(">",rest)] lexTFVec ('<':rest) = [("<",rest)] lexTFVec str = lex str - \ No newline at end of file +