tfp-th (empty) → 0.8
raw patch · 5 files changed
+121/−0 lines, 5 filesdep +basedep +template-haskelldep +tfpsetup-changed
Dependencies added: base, template-haskell, tfp
Files
- LICENSE +26/−0
- Setup.hs +2/−0
- src/Types/Data/Num/Decimal/Literals/Big.hs +6/−0
- src/Types/Data/Num/Decimal/Literals/TH.hs +49/−0
- tfp-th.cabal +38/−0
+ LICENSE view
@@ -0,0 +1,26 @@+Copyright (c) 2013 Henning Thielemann+Copyright (c) 2008 Peter Gavin+All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:+ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.+ * Redistributions in binary form must reproduce the above copyright+ notice, this list of conditions and the following disclaimer in the+ documentation and/or other materials provided with the distribution.+ * Neither the name of the copyright holder nor the+ names of its contributors may be used to endorse or promote products+ derived from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ src/Types/Data/Num/Decimal/Literals/Big.hs view
@@ -0,0 +1,6 @@+{-# LANGUAGE TemplateHaskell #-}+module Types.Data.Num.Decimal.Literals.Big where++import Types.Data.Num.Decimal.Literals.TH++$( decLiteralsD "D" "d" (-10000) (10000) )
+ src/Types/Data/Num/Decimal/Literals/TH.hs view
@@ -0,0 +1,49 @@+{-# LANGUAGE TemplateHaskell #-}+module Types.Data.Num.Decimal.Literals.TH where++import Language.Haskell.TH++import qualified Types.Data.Num.Decimal.Digits as D+import qualified Types.Data.Num.Ops as O++decLiteralT :: Integer -> Q Type+decLiteralT k = appT (conT (''D.Dec)) (decLiteralT' k)+ where decLiteralT' n | n < 0 = appT (conT ''D.Neg') (decLiteralT' (-n))+ | n == 0 = conT ''D.DecN+ | otherwise = appT (appT (conT ''(O.:.)) (decLiteralT' (n `div` 10))) (conT (case n `mod` 10 of+ 0 -> ''D.Dec0 + 1 -> ''D.Dec1+ 2 -> ''D.Dec2+ 3 -> ''D.Dec3+ 4 -> ''D.Dec4+ 5 -> ''D.Dec5+ 6 -> ''D.Dec6+ 7 -> ''D.Dec7+ 8 -> ''D.Dec8+ 9 -> ''D.Dec9+ d -> error $ "not a decimal digit: " ++ show d))++decLiteralV :: Integer -> Q Exp+decLiteralV n = sigE [| undefined |] (decLiteralT n)++decLiteralD :: String+ -> String+ -> Integer+ -> Q [Dec]+decLiteralD typePrefix valPrefix n =+ do let (tsign, vsign, num) =+ if n < 0 then ("N", "n", show (-n)) else ("", "", show n)+ typeName = mkName $ typePrefix ++ tsign ++ num+ valName = mkName $ valPrefix ++ vsign ++ num+ tySyn <- tySynD typeName [] (decLiteralT n)+ sig <- sigD valName (conT typeName)+ val <- valD (varP valName) (normalB [| undefined |]) []+ return [ tySyn, sig, val ]++decLiteralsD :: String+ -> String+ -> Integer+ -> Integer+ -> Q [Dec]+decLiteralsD typePrefix valPrefix from to =+ fmap concat $ sequence $ [ decLiteralD typePrefix valPrefix n | n <- [from..to] ]
+ tfp-th.cabal view
@@ -0,0 +1,38 @@+Name: tfp-th+Version: 0.8+License: BSD3+License-File: LICENSE+Copyright: Copyright (c) 2013 Henning Thielemann, 2008 Peter Gavin+Author: Peter Gavin, Henning Thielemann+Maintainer: haskell@henning-thielemann.de+Homepage: http://www.haskell.org/haskellwiki/Type_arithmetic+Synopsis: Template-Haskell code for tfp+Description:+ This package contains Template Haskell for generating tons of type integer literals+ and a module that provides integers from a large range.+Category: Type System+Tested-with: GHC == 7.4.2, GHC == 7.6.3+Stability: alpha+Cabal-version: >= 1.6+Build-Type: Simple++Source-Repository head+ Type: darcs+ Location: http://code.haskell.org/~thielema/tfp-th/++Source-Repository this+ Tag: 0.8+ Type: darcs+ Location: http://code.haskell.org/~thielema/tfp-th/+++Library+ Build-Depends:+ tfp >=0.8 && <0.9,+ template-haskell >=2.0,+ base >=3.0 && <5+ GHC-Options: -Wall+ Hs-Source-Dirs: src+ Exposed-Modules:+ Types.Data.Num.Decimal.Literals.Big+ Types.Data.Num.Decimal.Literals.TH