Permalink
Browse files

Check for pre-existing Int before making a new alias.

  • Loading branch information...
1 parent ceb8fb4 commit 3cde21eb48f133e264ccabb8674352a44a978122 @TomMD committed Dec 13, 2012
Showing with 7 additions and 3 deletions.
  1. +7 −3 Data/FixedPoint/TH.hs
View
@@ -42,9 +42,13 @@ getParts i =
-- See the requirements under 'mkWord' for additional information.
mkInt :: Int -> DecsQ
mkInt i = do
- d <- mkWord i
- e <- tySynD (mkName . ("Int" ++) . show $ i) [] (appT (conT $ mkName "BigInt") (conT $ mkW i))
- return (e:d)
+ info <- lookupTypeName (mkS i)
+ if isNothing info
+ then do
+ d <- mkWord i
+ e <- tySynD (mkName . ("Int" ++) . show $ i) [] (appT (conT $ mkName "BigInt") (conT $ mkW i))
+ return (e:d)
+ else return []
-- @mkFixedPoint X Y@ Builds a fixed point alias named @FixedPointX_Y@. See
-- the requirements under 'mkWord' for additional information.

0 comments on commit 3cde21e

Please sign in to comment.