@@ -1,4 +1,4 @@
1−{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, DeriveFunctor #-}
1+{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, DeriveFunctor, DeriveDataTypeable #-}
3{-| TT is the core language of Idris. The language has:
3{-| TT is the core language of Idris. The language has:
@@ -27,6 +27,7 @@ import Control.Monad.Trans.Except (Except (..))
27import Debug.Trace
27import Debug.Trace
28import qualified Data.Map.Strict as Map
28import qualified Data.Map.Strict as Map
29import Data.Char
29import Data.Char
30+import Data.Data (Data)
30import Numeric (showIntAtBase)
31import Numeric (showIntAtBase)
31import qualified Data.Text as T
32import qualified Data.Text as T
32import Data.List hiding (insert)
33import Data.List hiding (insert)
@@ -34,6 +35,7 @@ import Data.Set(Set, member, fromList, insert)
34import Data.Maybe (listToMaybe)
35import Data.Maybe (listToMaybe)
35import Data.Foldable (Foldable)
36import Data.Foldable (Foldable)
36import Data.Traversable (Traversable)
37import Data.Traversable (Traversable)
38+import Data.Typeable (Typeable)
37import Data.Vector.Unboxed (Vector)
39import Data.Vector.Unboxed (Vector)
38import qualified Data.Vector.Unboxed as V
40import qualified Data.Vector.Unboxed as V
39import qualified Data.Binary as B
41import qualified Data.Binary as B
@@ -51,6 +53,7 @@ data FC = FC { fc_fname :: String, -- ^ Filename
51 fc_start :: (Int, Int), -- ^ Line and column numbers for the start of the location span
53 fc_start :: (Int, Int), -- ^ Line and column numbers for the start of the location span
52 fc_end :: (Int, Int) -- ^ Line and column numbers for the end of the location span
54 fc_end :: (Int, Int) -- ^ Line and column numbers for the end of the location span
56+ deriving (Data, Typeable)
55-- | Ignore source location equality (so deriving classes do not compare FCs)
58-- | Ignore source location equality (so deriving classes do not compare FCs)
56instance Eq FC where
59instance Eq FC where
@@ -111,7 +114,7 @@ data ErrorReportPart = TextPart String
111 | NamePart Name
114 | NamePart Name
112 | TermPart Term
115 | TermPart Term
113 | SubReport [ErrorReportPart]
116 | SubReport [ErrorReportPart]
114− deriving (Show, Eq)
117+ deriving (Show, Eq, Data, Typeable)
117-- Please remember to keep Err synchronised with
120-- Please remember to keep Err synchronised with
@@ -159,7 +162,7 @@ data Err' t
159 | LoadingFailed String (Err' t)
162 | LoadingFailed String (Err' t)
160 | ReflectionError [[ErrorReportPart]] (Err' t)
163 | ReflectionError [[ErrorReportPart]] (Err' t)
161 | ReflectionFailed String (Err' t)
164 | ReflectionFailed String (Err' t)
162− deriving (Eq, Functor)
165+ deriving (Eq, Functor, Data, Typeable)
164type Err = Err' Term
167type Err = Err' Term
@@ -307,7 +310,7 @@ data Name = UN T.Text -- ^ User-provided name
307 | NErased -- ^ Name of something which is never used in scope
310 | NErased -- ^ Name of something which is never used in scope
308 | SN SpecialName -- ^ Decorated function names
311 | SN SpecialName -- ^ Decorated function names
309 | SymRef Int -- ^ Reference to IBC file symbol table (used during serialisation)
312 | SymRef Int -- ^ Reference to IBC file symbol table (used during serialisation)
310− deriving (Eq, Ord)
313+ deriving (Eq, Ord, Data, Typeable)
312txt :: String -> T.Text
315txt :: String -> T.Text
313txt = T.pack
316txt = T.pack
@@ -344,7 +347,7 @@ data SpecialName = WhereN Int Name Name
344 | CaseN Name
347 | CaseN Name
345 | ElimN Name
348 | ElimN Name
346 | InstanceCtorN Name
349 | InstanceCtorN Name
347− deriving (Eq, Ord)
350+ deriving (Eq, Ord, Data, Typeable)
349deriving instance Binary SpecialName
352deriving instance Binary SpecialName
350deriving instance NFData SpecialName
353deriving instance NFData SpecialName
@@ -494,7 +497,7 @@ addAlist [] ctxt = ctxt
494addAlist ((n, tm) : ds) ctxt = addDef n tm (addAlist ds ctxt)
497addAlist ((n, tm) : ds) ctxt = addDef n tm (addAlist ds ctxt)
496data NativeTy = IT8 | IT16 | IT32 | IT64
499data NativeTy = IT8 | IT16 | IT32 | IT64
497− deriving (Show, Eq, Ord, Enum)
500+ deriving (Show, Eq, Ord, Enum, Data, Typeable)
499instance Pretty NativeTy OutputAnnotation where
502instance Pretty NativeTy OutputAnnotation where
500 pretty IT8 = text "Bits8"
503 pretty IT8 = text "Bits8"
@@ -504,7 +507,7 @@ instance Pretty NativeTy OutputAnnotation where
505data IntTy = ITFixed NativeTy | ITNative | ITBig | ITChar
508data IntTy = ITFixed NativeTy | ITNative | ITBig | ITChar
506 | ITVec NativeTy Int
509 | ITVec NativeTy Int
507− deriving (Show, Eq, Ord)
510+ deriving (Show, Eq, Ord, Data, Typeable)
509intTyName :: IntTy -> String
512intTyName :: IntTy -> String
510intTyName ITNative = "Int"
513intTyName ITNative = "Int"
@@ -514,7 +517,7 @@ intTyName (ITChar) = "Char"
514intTyName (ITVec ity count) = "B" ++ show (nativeTyWidth ity) ++ "x" ++ show count
517intTyName (ITVec ity count) = "B" ++ show (nativeTyWidth ity) ++ "x" ++ show count
516data ArithTy = ATInt IntTy | ATFloat -- TODO: Float vectors https://github.com/idris-lang/Idris-dev/issues/1723
519data 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)
519deriving instance NFData IntTy
522deriving instance NFData IntTy
520deriving instance NFData NativeTy
523deriving instance NFData NativeTy
@@ -548,7 +551,7 @@ data Const = I Int | BI Integer | Fl Double | Ch Char | Str String
548 | B32V (Vector Word32) | B64V (Vector Word64)
551 | B32V (Vector Word32) | B64V (Vector Word64)
549 | AType ArithTy | StrType
552 | AType ArithTy | StrType
550 | PtrType | ManagedPtrType | BufferType | VoidType | Forgot
553 | PtrType | ManagedPtrType | BufferType | VoidType | Forgot
551− deriving (Eq, Ord)
554+ deriving (Eq, Ord, Data, Typeable)
553deriving instance Binary Const
556deriving instance Binary Const
554deriving instance NFData Const
557deriving instance NFData Const
@@ -639,7 +642,7 @@ constDocs (B64V v) = "A vector of sixty-four-bit values"
639constDocs prim = "Undocumented"
642constDocs prim = "Undocumented"
641data Universe = NullType | UniqueType | AllTypes
644data Universe = NullType | UniqueType | AllTypes
642− deriving (Eq, Ord)
645+ deriving (Eq, Ord, Data, Typeable)
644instance Show Universe where
647instance Show Universe where
645 show UniqueType = "UniqueType"
648 show UniqueType = "UniqueType"
@@ -653,7 +656,7 @@ data Raw = Var Name
653 | RUType Universe
656 | RUType Universe
654 | RForce Raw
657 | RForce Raw
655 | RConstant Const
658 | RConstant Const
656− deriving (Show, Eq)
659+ deriving (Show, Eq, Data, Typeable)
658instance Sized Raw where
661instance Sized Raw where
659 size (Var name) = 1
662 size (Var name) = 1
@@ -707,7 +710,7 @@ data Binder b = Lam { binderTy :: !b {-^ type annotation for bound variable-}
707 | PVar { binderTy :: !b }
710 | PVar { binderTy :: !b }
708 -- ^ A pattern variable
711 -- ^ A pattern variable
709 | PVTy { binderTy :: !b }
712 | PVTy { binderTy :: !b }
710− deriving (Show, Eq, Ord, Functor, Foldable, Traversable)
713+ deriving (Show, Eq, Ord, Functor, Foldable, Traversable, Data, Typeable)
712deriving instance Binary Binder
715deriving instance Binary Binder
713deriving instance NFData Binder
716deriving instance NFData Binder
@@ -749,7 +752,7 @@ raw_unapply t = ua [] t where
749-- | Universe expressions for universe checking
752-- | Universe expressions for universe checking
750data UExp = UVar Int -- ^ universe variable
753data UExp = UVar Int -- ^ universe variable
751 | UVal Int -- ^ explicit universe level
754 | UVal Int -- ^ explicit universe level
752− deriving (Eq, Ord)
755+ deriving (Eq, Ord, Data, Typeable)
754deriving instance NFData UExp
757deriving instance NFData UExp
@@ -786,7 +789,7 @@ data NameType = Bound
787 | DCon {nt_tag :: Int, nt_arity :: Int, nt_unique :: Bool} -- ^ Data constructor
790 | DCon {nt_tag :: Int, nt_arity :: Int, nt_unique :: Bool} -- ^ Data constructor
788 | TCon {nt_tag :: Int, nt_arity :: Int} -- ^ Type constructor
791 | TCon {nt_tag :: Int, nt_arity :: Int} -- ^ Type constructor
789− deriving (Show, Ord)
792+ deriving (Show, Ord, Data, Typeable)
791deriving instance Binary NameType
794deriving instance Binary NameType
792deriving instance NFData NameType
795deriving instance NFData NameType
@@ -821,7 +824,7 @@ data TT n = P NameType n (TT n) -- ^ named references with type
821 | Impossible -- ^ special case for totality checking
824 | Impossible -- ^ special case for totality checking
822 | TType UExp -- ^ the type of types at some level
825 | TType UExp -- ^ the type of types at some level
823 | UType Universe -- ^ Uniqueness type universe (disjoint from TType)
826 | UType Universe -- ^ Uniqueness type universe (disjoint from TType)
824− deriving (Ord, Functor)
827+ deriving (Ord, Functor, Data, Typeable)
826deriving instance Binary TT
829deriving instance Binary TT
827deriving instance NFData TT
830deriving instance NFData TT