4 from Data.Either import :: Either
5 from StdOverloaded import class zero
8 * Helper types for @ style types
14 reBox x :== box (unBox x)
17 * Calculate whether a type has a potentially infinite size
19 potInf :: Box Bool a | gPotInf{|*|} a
20 generic gPotInf a :: [String] -> Box Bool a
21 derive gPotInf Int, Bool, Char, Real, World, Dynamic, UNIT, CONS, FIELD, EITHER, PAIR, OBJECT of {gtd_name}, RECORD of {grd_name}
24 * Calculate the ctype representation of a type
26 toStruct :: Box GTSState a | gToStruct{|*|} a
29 instance zero GTSState
30 generic gToStruct a | gPotInf a :: GTSState -> (GTSResult, Box GTSState a)
31 derive gToStruct Int, Bool, Char, Real, UNIT, CONS of {gcd_type}, FIELD, EITHER, PAIR, OBJECT of {gtd_arity,gtd_name,gtd_conses,gtd_num_conses}, RECORD of {grd_arity,grd_name,grd_fields}
34 * Given a GTSState, generate typedefinitions
36 toCType :: GTSState -> [String]
39 * Given a GTSState, generate a parser
40 * @result Function signatures
43 toCParser :: GTSState -> ([String], [String])
45 * Given a GTSState, generate a printer
46 * @result Function signatures
49 toCPrinter :: GTSState -> ([String], [String])
52 * Generate a serialized value for the given type
54 * @param continuation list
57 toCValue :: a [Char] -> [Char] | gToCValue{|*|} a
58 generic gToCValue a :: a [Char] -> [Char]
59 derive gToCValue Int, Bool, Char, UNIT, EITHER, PAIR, CONS of {gcd_index}, FIELD, RECORD, OBJECT
62 * Parse a value from the serializized value
64 * @result Either an error or a value
66 :: FromCValueError = CVEUnknownConstructor | CVEInputExhausted
67 fromCValue :: [Char] -> Either FromCValueError (a, [Char]) | gFromCValue{|*|} a
68 generic gFromCValue a :: ([Char] -> Either FromCValueError (a, [Char]))
69 derive gFromCValue Int, Bool, Char, UNIT, EITHER, PAIR, CONS of {gcd_index}, FIELD, RECORD, OBJECT
72 * @param type in a box with a filename
76 toCFiles :: (Box String a) -> ([String], [String]) | gToStruct{|*|} a