@@ -1,4 +1,4 @@
1−{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, DeriveFunctor #-}
1+{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, DeriveFunctor, DeriveDataTypeable #-}
22
33{-| TT is the core language of Idris. The language has:
44
@@ -27,6 +27,7 @@ import Control.Monad.Trans.Except (Except (..))
2727import Debug.Trace
2828import qualified Data.Map.Strict as Map
2929import Data.Char
30+import Data.Data (Data)
3031import Numeric (showIntAtBase)
3132import qualified Data.Text as T
3233import Data.List hiding (insert)
@@ -34,6 +35,7 @@ import Data.Set(Set, member, fromList, insert)
3435import Data.Maybe (listToMaybe)
3536import Data.Foldable (Foldable)
3637import Data.Traversable (Traversable)
38+import Data.Typeable (Typeable)
3739import Data.Vector.Unboxed (Vector)
3840import qualified Data.Vector.Unboxed as V
3941import qualified Data.Binary as B
@@ -51,6 +53,7 @@ data FC = FC { fc_fname :: String, -- ^ Filename
5153 fc_start :: (Int, Int), -- ^ Line and column numbers for the start of the location span
5254 fc_end :: (Int, Int) -- ^ Line and column numbers for the end of the location span
5355 }
56+ deriving (Data, Typeable)
5457
5558-- | Ignore source location equality (so deriving classes do not compare FCs)
5659instance Eq FC where
@@ -111,7 +114,7 @@ data ErrorReportPart = TextPart String
111114 | NamePart Name
112115 | TermPart Term
113116 | SubReport [ErrorReportPart]
114− deriving (Show, Eq)
117+ deriving (Show, Eq, Data, Typeable)
115118
116119
117120-- Please remember to keep Err synchronised with
@@ -159,7 +162,7 @@ data Err' t
159162 | LoadingFailed String (Err' t)
160163 | ReflectionError [[ErrorReportPart]] (Err' t)
161164 | ReflectionFailed String (Err' t)
162− deriving (Eq, Functor)
165+ deriving (Eq, Functor, Data, Typeable)
163166
164167type Err = Err' Term
165168
@@ -307,7 +310,7 @@ data Name = UN T.Text -- ^ User-provided name
307310 | NErased -- ^ Name of something which is never used in scope
308311 | SN SpecialName -- ^ Decorated function names
309312 | SymRef Int -- ^ Reference to IBC file symbol table (used during serialisation)
310− deriving (Eq, Ord)
313+ deriving (Eq, Ord, Data, Typeable)
311314
312315txt :: String -> T.Text
313316txt = T.pack
@@ -344,7 +347,7 @@ data SpecialName = WhereN Int Name Name
344347 | CaseN Name
345348 | ElimN Name
346349 | InstanceCtorN Name
347− deriving (Eq, Ord)
350+ deriving (Eq, Ord, Data, Typeable)
348351{-!
349352deriving instance Binary SpecialName
350353deriving instance NFData SpecialName
@@ -494,7 +497,7 @@ addAlist [] ctxt = ctxt
494497addAlist ((n, tm) : ds) ctxt = addDef n tm (addAlist ds ctxt)
495498
496499data NativeTy = IT8 | IT16 | IT32 | IT64
497− deriving (Show, Eq, Ord, Enum)
500+ deriving (Show, Eq, Ord, Enum, Data, Typeable)
498501
499502instance Pretty NativeTy OutputAnnotation where
500503 pretty IT8 = text "Bits8"
@@ -504,7 +507,7 @@ instance Pretty NativeTy OutputAnnotation where
504507
505508data IntTy = ITFixed NativeTy | ITNative | ITBig | ITChar
506509 | ITVec NativeTy Int
507− deriving (Show, Eq, Ord)
510+ deriving (Show, Eq, Ord, Data, Typeable)
508511
509512intTyName :: IntTy -> String
510513intTyName ITNative = "Int"
@@ -514,7 +517,7 @@ intTyName (ITChar) = "Char"
514517intTyName (ITVec ity count) = "B" ++ show (nativeTyWidth ity) ++ "x" ++ show count
515518
516519data ArithTy = ATInt IntTy | ATFloat -- TODO: Float vectors https://github.com/idris-lang/Idris-dev/issues/1723
517− deriving (Show, Eq, Ord)
520+ deriving (Show, Eq, Ord, Data, Typeable)
518521{-!
519522deriving instance NFData IntTy
520523deriving instance NFData NativeTy
@@ -548,7 +551,7 @@ data Const = I Int | BI Integer | Fl Double | Ch Char | Str String
548551 | B32V (Vector Word32) | B64V (Vector Word64)
549552 | AType ArithTy | StrType
550553 | PtrType | ManagedPtrType | BufferType | VoidType | Forgot
551− deriving (Eq, Ord)
554+ deriving (Eq, Ord, Data, Typeable)
552555{-!
553556deriving instance Binary Const
554557deriving instance NFData Const
@@ -639,7 +642,7 @@ constDocs (B64V v) = "A vector of sixty-four-bit values"
639642constDocs prim = "Undocumented"
640643
641644data Universe = NullType | UniqueType | AllTypes
642− deriving (Eq, Ord)
645+ deriving (Eq, Ord, Data, Typeable)
643646
644647instance Show Universe where
645648 show UniqueType = "UniqueType"
@@ -653,7 +656,7 @@ data Raw = Var Name
653656 | RUType Universe
654657 | RForce Raw
655658 | RConstant Const
656− deriving (Show, Eq)
659+ deriving (Show, Eq, Data, Typeable)
657660
658661instance Sized Raw where
659662 size (Var name) = 1
@@ -707,7 +710,7 @@ data Binder b = Lam { binderTy :: !b {-^ type annotation for bound variable-}
707710 | PVar { binderTy :: !b }
708711 -- ^ A pattern variable
709712 | PVTy { binderTy :: !b }
710− deriving (Show, Eq, Ord, Functor, Foldable, Traversable)
713+ deriving (Show, Eq, Ord, Functor, Foldable, Traversable, Data, Typeable)
711714{-!
712715deriving instance Binary Binder
713716deriving instance NFData Binder
@@ -749,7 +752,7 @@ raw_unapply t = ua [] t where
749752-- | Universe expressions for universe checking
750753data UExp = UVar Int -- ^ universe variable
751754 | UVal Int -- ^ explicit universe level
752− deriving (Eq, Ord)
755+ deriving (Eq, Ord, Data, Typeable)
753756{-!
754757deriving instance NFData UExp
755758!-}
@@ -786,7 +789,7 @@ data NameType = Bound
786789 | Ref
787790 | DCon {nt_tag :: Int, nt_arity :: Int, nt_unique :: Bool} -- ^ Data constructor
788791 | TCon {nt_tag :: Int, nt_arity :: Int} -- ^ Type constructor
789− deriving (Show, Ord)
792+ deriving (Show, Ord, Data, Typeable)
790793{-!
791794deriving instance Binary NameType
792795deriving instance NFData NameType
@@ -821,7 +824,7 @@ data TT n = P NameType n (TT n) -- ^ named references with type
821824 | Impossible -- ^ special case for totality checking
822825 | TType UExp -- ^ the type of types at some level
823826 | UType Universe -- ^ Uniqueness type universe (disjoint from TType)
824− deriving (Ord, Functor)
827+ deriving (Ord, Functor, Data, Typeable)
825828{-!
826829deriving instance Binary TT
827830deriving instance NFData TT