on master help sign in
Add binary instance for Main type in AST.Expr.Canonical
commitfa3c0a7bb839e460ff230ddd225d7b810e3e1985 authorEvan Czaplicki <evancz@users.noreply.github.com> dateTue 28 Mar 2017, 14:57 (10 years ago) parentde5ba20
1 file changed+26
src/AST/Expression/Canonical.hs+26
src/AST/Expression/Canonical.hs+26
@@ -11,6 +11,7 @@ module AST.Expression.Canonical
1111 where
1212
1313
14+import Data.Binary
1415import Data.Monoid ((<>))
1516import Data.Text (Text)
1617import qualified Data.Text.Lazy as LText
@@ -160,3 +161,28 @@ collectLambdas lexpr@(A.A _ expr) =
160161
161162 _ ->
162163 ([], lexpr)
164+
165+
166+
167+-- BINARY
168+
169+
170+instance Binary Main where
171+ put main =
172+ case main of
173+ VDom ->
174+ putWord8 0
175+
176+ NoFlags ->
177+ putWord8 1
178+
179+ Flags tipe ->
180+ putWord8 2 >> put tipe
181+
182+ get =
183+ do word <- getWord8
184+ case word of
185+ 0 -> pure VDom
186+ 1 -> pure NoFlags
187+ 2 -> pure Flags <*> get
188+ _ -> error "problem getting Can.Main binary"