Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix generation of word sizes that are powers of two.

  • Loading branch information...
commit 5cd7024d9ae09ffa457d85891a37605df92edfb7 1 parent 3cde21e
@TomMD authored
Showing with 9 additions and 4 deletions.
  1. +9 −4 Data/FixedPoint/TH.hs
View
13 Data/FixedPoint/TH.hs
@@ -19,10 +19,15 @@ mkWord i
let b = isNothing info
if b then do
let (h,l) = getParts i
- hD <- mkWord h
- lD <- mkWord l
- a <- tySynD (mkW i) [] (appT (appT (conT $ mkName "BigWord") (conT $ mkW h)) (conT $ mkW l))
- return $ a:(hD++lD)
+ if h == 0
+ then do let l' = l`div`2
+ lD <- mkWord l'
+ a <- tySynD (mkW i) [] (appT (appT (conT $ mkName "BigWord") (conT $ mkW l')) (conT $ mkW l'))
+ return $ a:lD
+ else do hD <- mkWord h
+ lD <- mkWord l
+ a <- tySynD (mkW i) [] (appT (appT (conT $ mkName "BigWord") (conT $ mkW h)) (conT $ mkW l))
+ return $ a:(hD++lD)
else return []
mkS :: Int -> String
Please sign in to comment.
Something went wrong with that request. Please try again.