on master help sign in
Add JS as a possible Derivation, correct binary serialization, add error when serialization goes wrong.
commit662fd7669ae8ddd1892c1e8bf26e0dcf5cedd7bd authorEvan Czaplicki <info@elm-lang.org> dateThu 2 Jan 2014, 13:38 (13 years ago) parent578dfb8
1 file changed+12−7
compiler/SourceSyntax/Declaration.hs+12−7
compiler/SourceSyntax/Declaration.hs+12−7
@@ -1,3 +1,4 @@
1+{-# OPTIONS_GHC -Wall #-}
12module SourceSyntax.Declaration where
23
34import Data.Binary
@@ -17,21 +18,25 @@ data Declaration tipe var
1718data Assoc = L | N | R
1819 deriving (Eq)
1920
20−data Derivation = Json | Binary | RecordConstructor
21+data Derivation = Json | JS | Binary | New
2122 deriving (Eq, Show)
2223
2324instance Binary Derivation where
2425 get = do n <- getWord8
2526 return $ case n of
2627 0 -> Json
27− 1 -> Binary
28− 2 -> RecordConstructor
28+ 1 -> JS
29+ 2 -> Binary
30+ 3 -> New
31+ _ -> error "Unable to decode Derivation. You may have corrupted binary files,\n\
32+ \so please report an issue at <https://github.com/evancz/Elm/issues>"
2933
3034 put derivation =
31− case derivation of
32− Json -> putWord8 0
33− Binary -> putWord8 1
34− RecordConstructor -> putWord8 2
35+ putWord8 $ case derivation of
36+ Json -> 0
37+ JS -> 1
38+ Binary -> 2
39+ New -> 3
3540
3641instance Show Assoc where
3742 show assoc =