@@ -1,4 +1,4 @@
1−
1+{-# OPTIONS_GHC -W #-}
22module AST.Variable where
33
44import Data.Binary
@@ -6,10 +6,6 @@ import Control.Applicative ((<$>), (<*>))
66import Text.PrettyPrint as P
77import AST.PrettyPrint
88
9−import qualified Data.List as List
10−import qualified Text.PrettyPrint as P
11−import AST.PrettyPrint
12−
139newtype Raw = Raw String
1410 deriving (Eq,Ord,Show)
1511
@@ -37,6 +33,7 @@ instance ToString Canonical where
3733 toString (Canonical home name) =
3834 case home of
3935 Local -> name
36+ BuiltIn -> name
4037 Module path -> path ++ "." ++ name
4138
4239-- | A listing of values. Something like (a,b,c) or (..) or (a,b,..)
@@ -59,12 +56,7 @@ instance Pretty Raw where
5956 pretty (Raw var) = variable var
6057
6158instance Pretty Canonical where
62− pretty (Canonical home name) =
63− P.text (home' ++ name)
64− where
65− home' = case home of
66− Local -> ""
67− Module name -> name ++ "."
59+ pretty var = P.text (toString var)
6860
6961instance Pretty a => Pretty (Listing a) where
7062 pretty (Listing explicits open) =
@@ -84,12 +76,14 @@ instance Binary Canonical where
8476 put (Canonical home name) =
8577 case home of
8678 Local -> putWord8 0 >> put name
87− Module path -> putWord8 1 >> put path >> put name
79+ BuiltIn -> putWord8 1 >> put name
80+ Module path -> putWord8 2 >> put path >> put name
8881
8982 get = do tag <- getWord8
9083 case tag of
9184 0 -> Canonical Local <$> get
92− 1 -> Canonical . Module <$> get <*> get
85+ 1 -> Canonical BuiltIn <$> get
86+ 2 -> Canonical . Module <$> get <*> get
9387 _ -> error "Unexpected tag when deserializing canonical variable"
9488
9589instance Binary Value where
@@ -97,14 +91,16 @@ instance Binary Value where
9791 let put' n info = putWord8 n >> put info in
9892 case portable of
9993 Value name -> put' 0 name
94+ Alias name -> put' 1 name
10095 ADT name ctors ->
101− do put' 1 name
96+ do put' 2 name
10297 put ctors
10398
10499 get = do tag <- getWord8
105100 case tag of
106101 0 -> Value <$> get
107− 1 -> ADT <$> get <*> get
102+ 1 -> Alias <$> get
103+ 2 -> ADT <$> get <*> get
108104 _ -> error "Error reading valid import/export information from serialized string"
109105
110106instance (Binary a) => Binary (Listing a) where