Created
February 22, 2015 07:40
-
-
Save rblaze/84b7b6c0b1ec5e40a532 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[24 of 24] Compiling Main ( Main.hs, Main.o ) | |
Main.hs:35:27: | |
Could not deduce (Typeable a0) arising from a use of ‘mkT’ | |
from the context (Data a) | |
bound by a type expected by the context: Data a => a -> a | |
at Main.hs:35:15-43 | |
The type variable ‘a0’ is ambiguous | |
Note: there are several potential instances: | |
instance Typeable Compat -- Defined in ‘Unittest.Compat.Compat’ | |
instance Typeable Blob -- Defined in ‘Bond.Types’ | |
instance Typeable ProtoSig -- Defined in ‘Bond.Types’ | |
...plus 34 others | |
In the first argument of ‘everywhere’, namely ‘(mkT (convert))’ | |
In the expression: everywhere (mkT (convert)) ss | |
In an equation for ‘ss'’: ss' = everywhere (mkT (convert)) ss | |
Main.hs:35:32: | |
Could not deduce (BondBinary SimpleBinaryProto a0) | |
arising from a use of ‘convert’ | |
from the context (Data a) | |
bound by a type expected by the context: Data a => a -> a | |
at Main.hs:35:15-43 | |
The type variable ‘a0’ is ambiguous | |
Note: there are several potential instances: | |
instance BondBinaryProto proto'tag => BondBinary proto'tag Compat | |
-- Defined in ‘Unittest.Compat.Compat’ | |
instance BondBinary t ListHead => BondBinary t Blob | |
-- Defined in ‘Bond.BinaryProto’ | |
instance (BondBinaryProto t, BondBinaryStruct t a) => | |
BondBinary t (Bonded a) | |
-- Defined in ‘Bond.BinaryProto’ | |
...plus 35 others | |
In the first argument of ‘mkT’, namely ‘(convert)’ | |
In the first argument of ‘everywhere’, namely ‘(mkT (convert))’ | |
In the expression: everywhere (mkT (convert)) ss |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# Language FlexibleContexts, DeriveDataTypeable #-} | |
module Main where | |
import Unittest.Compat.Compat | |
import Bond.API | |
import Bond.Imports | |
import qualified Data.ByteString.Lazy as BS | |
import Data.Data | |
import Data.Typeable | |
import Data.Generics | |
runGetOrFail g s = case runCompactBinaryGet g s of | |
Right (rest, _, msg) | BS.null rest -> msg | |
Right (_, _, _) -> error $ "Not all input consumed" | |
Left (_, n, msg) -> error $ "offset " ++ show n ++ " " ++ msg | |
convert v@(BondedObject _) = v | |
convert s = case unpackBonded s of | |
Left msg -> error msg | |
Right obj -> makeBonded obj | |
main :: IO () | |
main = do | |
putStrLn "reading" | |
b <- BS.readFile "/home/blaze/bond/test/compat/data/compat.compact2.dat" | |
putStrLn "parsing original" | |
let s = runGetOrFail bondGet b :: Compat | |
-- print s | |
putStrLn "saving" | |
let sbond = m_basicUnintialized s | |
let Right s'bond = unpackBonded sbond | |
let ss = s { m_basicUnintialized = makeBonded s'bond } | |
print ss | |
let ss' = everywhere (mkT (convert)) ss | |
let b' = runFastBinaryPut (bondPut ss) | |
BS.writeFile "out.dat" b' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment