git-annex/standalone/no-th/haskell-patches/reflection_remove-TH.patch
Joey Hess ccef06da41 allow building webapp with EvilSplicer for non-android arm
Was able to reuse many of the android patches, but several had to be
re-done. On Android, ghc is a stage2 build, so can compile, but not run TH
code. But debian's ghc on armel cannot even compile TH code, so it has
to be patched out.

Some haskell packages have been updated to new versions, including yesod
and DAV, and their patches had to be redone.

The Makefile now has 2 new targets. The first is run on a companion x86
system to do the build and get TH splices. Then the second target is run
the same source tree on the arm system to build without needing TH.

This commit was sponsored by Svenne Krap.
2013-12-18 21:41:17 +00:00

113 lines
3.5 KiB
Diff

From 22c68b43dce437b3c22956f5a968f1b886e60e0c Mon Sep 17 00:00:00 2001
From: Joey Hess <joey@kitenet.net>
Date: Tue, 17 Dec 2013 19:15:16 +0000
Subject: [PATCH] remove TH
---
fast/Data/Reflection.hs | 80 +------------------------------------------------
1 file changed, 1 insertion(+), 79 deletions(-)
diff --git a/fast/Data/Reflection.hs b/fast/Data/Reflection.hs
index 119d773..cf99efa 100644
--- a/fast/Data/Reflection.hs
+++ b/fast/Data/Reflection.hs
@@ -58,7 +58,7 @@ module Data.Reflection
, Given(..)
, give
-- * Template Haskell reflection
- , int, nat
+ --, int, nat
-- * Useful compile time naturals
, Z, D, SD, PD
) where
@@ -151,87 +151,9 @@ instance Reifies n Int => Reifies (PD n) Int where
reflect = (\n -> n + n - 1) <$> retagPD reflect
{-# INLINE reflect #-}
--- | This can be used to generate a template haskell splice for a type level version of a given 'int'.
---
--- This does not use GHC TypeLits, instead it generates a numeric type by hand similar to the ones used
--- in the \"Functional Pearl: Implicit Configurations\" paper by Oleg Kiselyov and Chung-Chieh Shan.
-int :: Int -> TypeQ
-int n = case quotRem n 2 of
- (0, 0) -> conT ''Z
- (q,-1) -> conT ''PD `appT` int q
- (q, 0) -> conT ''D `appT` int q
- (q, 1) -> conT ''SD `appT` int q
- _ -> error "ghc is bad at math"
-
--- | This is a restricted version of 'int' that can only generate natural numbers. Attempting to generate
--- a negative number results in a compile time error. Also the resulting sequence will consist entirely of
--- Z, D, and SD constructors representing the number in zeroless binary.
-nat :: Int -> TypeQ
-nat n
- | n >= 0 = int n
- | otherwise = error "nat: negative"
-
-#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL < 704
-instance Show (Q a)
-instance Eq (Q a)
-#endif
-instance Num a => Num (Q a) where
- (+) = liftM2 (+)
- (*) = liftM2 (*)
- (-) = liftM2 (-)
- negate = fmap negate
- abs = fmap abs
- signum = fmap signum
- fromInteger = return . fromInteger
-
-instance Fractional a => Fractional (Q a) where
- (/) = liftM2 (/)
- recip = fmap recip
- fromRational = return . fromRational
-
--- | This permits the use of $(5) as a type splice.
-instance Num Type where
-#ifdef USE_TYPE_LITS
- a + b = AppT (AppT (VarT ''(+)) a) b
- a * b = AppT (AppT (VarT ''(*)) a) b
-#if MIN_VERSION_base(4,8,0)
- a - b = AppT (AppT (VarT ''(-)) a) b
-#else
- (-) = error "Type.(-): undefined"
-#endif
- fromInteger = LitT . NumTyLit
-#else
- (+) = error "Type.(+): undefined"
- (*) = error "Type.(*): undefined"
- (-) = error "Type.(-): undefined"
- fromInteger n = case quotRem n 2 of
- (0, 0) -> ConT ''Z
- (q,-1) -> ConT ''PD `AppT` fromInteger q
- (q, 0) -> ConT ''D `AppT` fromInteger q
- (q, 1) -> ConT ''SD `AppT` fromInteger q
- _ -> error "ghc is bad at math"
-#endif
- abs = error "Type.abs"
- signum = error "Type.signum"
-
plus, times, minus :: Num a => a -> a -> a
plus = (+)
times = (*)
minus = (-)
fract :: Fractional a => a -> a -> a
fract = (/)
-
--- | This permits the use of $(5) as an expression splice.
-instance Num Exp where
- a + b = AppE (AppE (VarE 'plus) a) b
- a * b = AppE (AppE (VarE 'times) a) b
- a - b = AppE (AppE (VarE 'minus) a) b
- negate = AppE (VarE 'negate)
- signum = AppE (VarE 'signum)
- abs = AppE (VarE 'abs)
- fromInteger = LitE . IntegerL
-
-instance Fractional Exp where
- a / b = AppE (AppE (VarE 'fract) a) b
- recip = AppE (VarE 'recip)
- fromRational = LitE . RationalL
--
1.8.5.1