| 26 | | |
| 27 | | instance (Typeable a) => Haskell2Xml (TVar a) where |
| 28 | | toHType _ = Prim "TVar" "tvar" |
| 29 | | toContents _ = [CElem (Elem "tvar" [] [])] |
| 30 | | |
| 31 | | instance Haskell2Xml Exp where |
| 32 | | toHType _ = Prim "Exp" "exp" |
| 33 | | toContents _ = [CElem (Elem "exp" [] [])] |
| 34 | | fromContents _ = (Noop, []) |
| 35 | | |
| 36 | | instance Haskell2Xml VRat where |
| 37 | | toHType _ = Prim "Rational" "rational" |
| 38 | | toContents i = [CElem (Elem "rational" [mkAttr "value" (show i)] [])] |
| 39 | | where |
| 40 | | mkAttr :: String -> String -> Attribute |
| 41 | | mkAttr n v = (n, AttValue [Left v]) |
| 42 | | fromContents (CElem (Elem "rational" [("value",(AttValue [Left s]))] []):cs) |
| 43 | | = (read s, cs) |
| 44 | | fromContents (_:cs) = fromContents cs |
| 138 | | {- |
| 139 | | |
| 140 | | data Scope = SState -- ^ Persistent across calls |
| 141 | | | SMy -- ^ Lexical |
| 142 | | | SOur -- ^ Package |
| 143 | | | SLet -- ^ Hypotheticalised (reverted upon failure) |
| 144 | | | STemp -- ^ Temporary (reverted at scope exit) |
| 145 | | | SGlobal -- ^ Global |
| 146 | | |
| 147 | | data SubType = SubMethod -- ^ Method |
| 148 | | | SubCoroutine -- ^ Coroutine |
| 149 | | | SubMacro -- ^ Macro |
| 150 | | | SubRoutine -- ^ Regular subroutine |
| 151 | | | SubBlock -- ^ Bare block |
| 152 | | | SubPointy -- ^ Pointy sub |
| 153 | | | SubPrim -- ^ Built-in primitive operator (see "Pugs.Prim") |
| 154 | | |
| 155 | | |
| 156 | | data Val |
| 157 | | = VUndef -- ^ Undefined value |
| 158 | | | VBool !VBool -- ^ Boolean value |
| 159 | | | VInt !VInt -- ^ Integer value |
| 160 | | | VRat !VRat -- ^ Rational number value |
| 161 | | | VNum !VNum -- ^ Number (i.e. a double) |
| 162 | | | VStr !VStr -- ^ String value |
| 163 | | | VList !VList -- ^ List value |
| 164 | | | VType !VType -- ^ Type value (e.g. @Int@ or @Type@) |
| 165 | | |
| 166 | | data Cxt = CxtVoid -- ^ Context that isn't expecting any values |
| 167 | | | CxtItem !Type -- ^ Context expecting a value of the specified type |
| 168 | | | CxtSlurpy !Type -- ^ Context expecting multiple values of the |
| 169 | | -- specified type |
| 170 | | data Type |
| 171 | | = MkType !String -- ^ A regular type |
| 172 | | | TypeOr !Type !Type -- ^ The disjunction (|) of two types |
| 173 | | | TypeAnd !Type !Type -- ^ The conjunction (&) of two types |
| 174 | | |
| 175 | | data Param = MkParam |
| 176 | | { isInvocant :: !Bool -- ^ Is it in invocant slot? |
| 177 | | , isOptional :: !Bool -- ^ Is it optional? |
| 178 | | , isNamed :: !Bool -- ^ Is it named-only? |
| 179 | | , isLValue :: !Bool -- ^ Is it lvalue (i.e. not `is copy`)? |
| 180 | | , isWritable :: !Bool -- ^ Is it writable (i.e. `is rw`)? |
| 181 | | , isLazy :: !Bool -- ^ Is it call-by-name (short-circuit)? |
| 182 | | , paramName :: !String -- ^ Parameter name |
| 183 | | , paramContext :: !Cxt -- ^ Parameter context: slurpiness and type |
| 184 | | , paramDefault :: !Exp -- ^ Default expression (to evaluate to) |
| 185 | | } |
| 186 | | |
| 187 | | data Pos = MkPos |
| 188 | | { posName :: !String |
| 189 | | , posBeginLine :: !Int |
| 190 | | , posBeginColumn :: !Int |
| 191 | | , posEndLine :: !Int |
| 192 | | , posEndColumn :: !Int |
| 193 | | } |
| 194 | | |
| 195 | | -} |
| 202 | | |
| 203 | | instance Haskell2Xml PIL_Environment where |
| 204 | | toHType v = |
| 205 | | Defined "PIL_Environment" [] |
| 206 | | [Constr "PIL_Environment" [] [toHType aa,toHType ab]] |
| 207 | | where |
| 208 | | (PIL_Environment aa ab) = v |
| 209 | | fromContents (CElem (Elem constr [] cs):etc) |
| 210 | | | "PIL_Environment" `isPrefixOf` constr = |
| 211 | | (\(aa,cs00)-> (\(ab,_)-> (PIL_Environment aa ab, etc)) |
| 212 | | (fromContents cs00)) |
| 213 | | (fromContents cs) |
| 214 | | toContents v@(PIL_Environment aa ab) = |
| 215 | | [mkElemC (showConstr 0 (toHType v)) (concat [toContents aa, |
| 216 | | toContents ab])] |
| 226 | | instance Haskell2Xml PIL_Stmts where |
| 227 | | toHType v = |
| 228 | | Defined "PIL_Stmts" [] |
| 229 | | [Constr "PNil" [] [],Constr "PStmts" [] [toHType aa,toHType ab], |
| 230 | | Constr "PPad" [] [toHType ac,toHType ad,toHType ae]] |
| 231 | | where |
| 232 | | (PStmts aa ab) = v |
| 233 | | (PPad ac ad ae) = v |
| 234 | | fromContents (CElem (Elem constr [] cs):etc) |
| 235 | | | "PStmts" `isPrefixOf` constr = |
| 236 | | (\(aa,cs00)-> (\(ab,_)-> (PStmts aa ab, etc)) (fromContents cs00)) |
| 237 | | (fromContents cs) |
| 238 | | | "PPad" `isPrefixOf` constr = |
| 239 | | (\(ac,cs00)-> (\(ad,cs01)-> (\(ae,_)-> (PPad ac ad ae, etc)) |
| 240 | | (fromContents cs01)) |
| 241 | | (fromContents cs00)) |
| 242 | | (fromContents cs) |
| 243 | | | "PNil" `isPrefixOf` constr = |
| 244 | | (PNil,etc) |
| 245 | | toContents v@PNil = |
| 246 | | [mkElemC (showConstr 0 (toHType v)) []] |
| 247 | | toContents v@(PStmts aa ab) = |
| 248 | | [mkElemC (showConstr 1 (toHType v)) (concat [toContents aa, |
| 249 | | toContents ab])] |
| 250 | | toContents v@(PPad ac ad ae) = |
| 251 | | [mkElemC (showConstr 2 (toHType v)) (concat [toContents ac, |
| 252 | | toContents ad,toContents ae])] |
| 253 | | |
| 261 | | |
| 262 | | instance Haskell2Xml PIL_Stmt where |
| 263 | | toHType v = |
| 264 | | Defined "PIL_Stmt" [] |
| 265 | | [Constr "PNoop" [] [],Constr "PStmt" [] [toHType aa], |
| 266 | | Constr "PPos" [] [toHType ab,toHType ac,toHType ad]] |
| 267 | | where |
| 268 | | (PStmt aa) = v |
| 269 | | (PPos ab ac ad) = v |
| 270 | | fromContents (CElem (Elem constr [] cs):etc) |
| 271 | | | "PStmt" `isPrefixOf` constr = |
| 272 | | (\(aa,_)-> (PStmt aa, etc)) (fromContents cs) |
| 273 | | | "PPos" `isPrefixOf` constr = |
| 274 | | (\(ab,cs00)-> (\(ac,cs01)-> (\(ad,_)-> (PPos ab ac ad, etc)) |
| 275 | | (fromContents cs01)) |
| 276 | | (fromContents cs00)) |
| 277 | | (fromContents cs) |
| 278 | | | "PNoop" `isPrefixOf` constr = |
| 279 | | (PNoop,etc) |
| 280 | | toContents v@PNoop = |
| 281 | | [mkElemC (showConstr 0 (toHType v)) []] |
| 282 | | toContents v@(PStmt aa) = |
| 283 | | [mkElemC (showConstr 1 (toHType v)) (toContents aa)] |
| 284 | | toContents v@(PPos ab ac ad) = |
| 285 | | [mkElemC (showConstr 2 (toHType v)) (concat [toContents ab, |
| 286 | | toContents ac,toContents ad])] |
| 299 | | instance Haskell2Xml PIL_Expr where |
| 300 | | toHType v = |
| 301 | | Defined "PIL_Expr" [] |
| 302 | | [Constr "PRawName" [] [toHType aa],Constr "PExp" [] [toHType ab], |
| 303 | | Constr "PLit" [] [toHType ac],Constr "PThunk" [] [toHType ad], |
| 304 | | Constr "PCode" [] [toHType ae,toHType af,toHType ag]] |
| 305 | | where |
| 306 | | (PRawName aa) = v |
| 307 | | (PExp ab) = v |
| 308 | | (PLit ac) = v |
| 309 | | (PThunk ad) = v |
| 310 | | (PCode ae af ag) = v |
| 311 | | fromContents (CElem (Elem constr [] cs):etc) |
| 312 | | | "PThunk" `isPrefixOf` constr = |
| 313 | | (\(ad,_)-> (PThunk ad, etc)) (fromContents cs) |
| 314 | | | "PRawName" `isPrefixOf` constr = |
| 315 | | (\(aa,_)-> (PRawName aa, etc)) (fromContents cs) |
| 316 | | | "PLit" `isPrefixOf` constr = |
| 317 | | (\(ac,_)-> (PLit ac, etc)) (fromContents cs) |
| 318 | | | "PExp" `isPrefixOf` constr = |
| 319 | | (\(ab,_)-> (PExp ab, etc)) (fromContents cs) |
| 320 | | | "PCode" `isPrefixOf` constr = |
| 321 | | (\(ae,cs00)-> (\(af,cs01)-> (\(ag,_)-> (PCode ae af ag, etc)) |
| 322 | | (fromContents cs01)) |
| 323 | | (fromContents cs00)) |
| 324 | | (fromContents cs) |
| 325 | | toContents v@(PRawName aa) = |
| 326 | | [mkElemC (showConstr 0 (toHType v)) (toContents aa)] |
| 327 | | toContents v@(PExp ab) = |
| 328 | | [mkElemC (showConstr 1 (toHType v)) (toContents ab)] |
| 329 | | toContents v@(PLit ac) = |
| 330 | | [mkElemC (showConstr 2 (toHType v)) (toContents ac)] |
| 331 | | toContents v@(PThunk ad) = |
| 332 | | [mkElemC (showConstr 3 (toHType v)) (toContents ad)] |
| 333 | | toContents v@(PCode ae af ag) = |
| 334 | | [mkElemC (showConstr 4 (toHType v)) (concat [toContents ae, |
| 335 | | toContents af,toContents ag])] |
| 336 | | |
| 342 | | instance Haskell2Xml PIL_Decl where |
| 343 | | toHType v = |
| 344 | | Defined "PIL_Decl" [] |
| 345 | | [Constr "PSub" [] [toHType aa,toHType ab,toHType ac,toHType ad]] |
| 346 | | where |
| 347 | | (PSub aa ab ac ad) = v |
| 348 | | fromContents (CElem (Elem constr [] cs):etc) |
| 349 | | | "PSub" `isPrefixOf` constr = |
| 350 | | (\(aa,cs00)-> (\(ab,cs01)-> (\(ac,cs02)-> (\(ad, |
| 351 | | _)-> (PSub aa ab ac ad, etc)) |
| 352 | | (fromContents cs02)) |
| 353 | | (fromContents cs01)) |
| 354 | | (fromContents cs00)) |
| 355 | | (fromContents cs) |
| 356 | | toContents v@(PSub aa ab ac ad) = |
| 357 | | [mkElemC (showConstr 0 (toHType v)) (concat [toContents aa, |
| 358 | | toContents ab,toContents ac,toContents ad])] |
| 359 | | |
| 385 | | instance Haskell2Xml PIL_LValue where |
| 386 | | toHType v = |
| 387 | | Defined "PIL_LValue" [] |
| 388 | | [Constr "PVar" [] [toHType aa], |
| 389 | | Constr "PApp" [] [toHType ab,toHType ac,toHType ad,toHType ae], |
| 390 | | Constr "PAssign" [] [toHType af,toHType ag], |
| 391 | | Constr "PBind" [] [toHType ah,toHType ai]] |
| 392 | | where |
| 393 | | (PVar aa) = v |
| 394 | | (PApp ab ac ad ae) = v |
| 395 | | (PAssign af ag) = v |
| 396 | | (PBind ah ai) = v |
| 397 | | fromContents (CElem (Elem constr [] cs):etc) |
| 398 | | | "PVar" `isPrefixOf` constr = |
| 399 | | (\(aa,_)-> (PVar aa, etc)) (fromContents cs) |
| 400 | | | "PBind" `isPrefixOf` constr = |
| 401 | | (\(ah,cs00)-> (\(ai,_)-> (PBind ah ai, etc)) (fromContents cs00)) |
| 402 | | (fromContents cs) |
| 403 | | | "PAssign" `isPrefixOf` constr = |
| 404 | | (\(af,cs00)-> (\(ag,_)-> (PAssign af ag, etc)) (fromContents cs00)) |
| 405 | | (fromContents cs) |
| 406 | | | "PApp" `isPrefixOf` constr = |
| 407 | | (\(ab,cs00)-> (\(ac,cs01)-> (\(ad,cs02)-> (\(ae, |
| 408 | | _)-> (PApp ab ac ad ae, etc)) |
| 409 | | (fromContents cs02)) |
| 410 | | (fromContents cs01)) |
| 411 | | (fromContents cs00)) |
| 412 | | (fromContents cs) |
| 413 | | toContents v@(PVar aa) = |
| 414 | | [mkElemC (showConstr 0 (toHType v)) (toContents aa)] |
| 415 | | toContents v@(PApp ab ac ad ae) = |
| 416 | | [mkElemC (showConstr 1 (toHType v)) (concat [toContents ab, |
| 417 | | toContents ac,toContents ad,toContents ae])] |
| 418 | | toContents v@(PAssign af ag) = |
| 419 | | [mkElemC (showConstr 2 (toHType v)) (concat [toContents af, |
| 420 | | toContents ag])] |
| 421 | | toContents v@(PBind ah ai) = |
| 422 | | [mkElemC (showConstr 3 (toHType v)) (concat [toContents ah, |
| 423 | | toContents ai])] |
| 424 | | |
| 429 | | instance Haskell2Xml TParam where |
| 430 | | toHType v = |
| 431 | | Defined "TParam" [] [Constr "MkTParam" [] [toHType aa,toHType ab]] |
| 432 | | where |
| 433 | | (MkTParam aa ab) = v |
| 434 | | fromContents (CElem (Elem constr [] cs):etc) |
| 435 | | | "MkTParam" `isPrefixOf` constr = |
| 436 | | (\(aa,cs00)-> (\(ab,_)-> (MkTParam aa ab, etc)) |
| 437 | | (fromContents cs00)) |
| 438 | | (fromContents cs) |
| 439 | | toContents v@(MkTParam aa ab) = |
| 440 | | [mkElemC (showConstr 0 (toHType v)) (concat [toContents aa, |
| 441 | | toContents ab])] |
| 442 | | |
| 452 | | |
| 453 | | instance Haskell2Xml TCxt where |
| 454 | | toHType v = |
| 455 | | Defined "TCxt" [] |
| 456 | | [Constr "TCxtVoid" [] [],Constr "TCxtLValue" [] [toHType aa], |
| 457 | | Constr "TCxtItem" [] [toHType ab], |
| 458 | | Constr "TCxtSlurpy" [] [toHType ac], |
| 459 | | Constr "TTailCall" [] [toHType ad]] |
| 460 | | where |
| 461 | | (TCxtLValue aa) = v |
| 462 | | (TCxtItem ab) = v |
| 463 | | (TCxtSlurpy ac) = v |
| 464 | | (TTailCall ad) = v |
| 465 | | fromContents (CElem (Elem constr [] cs):etc) |
| 466 | | | "TTailCall" `isPrefixOf` constr = |
| 467 | | (\(ad,_)-> (TTailCall ad, etc)) (fromContents cs) |
| 468 | | | "TCxtVoid" `isPrefixOf` constr = |
| 469 | | (TCxtVoid,etc) |
| 470 | | | "TCxtSlurpy" `isPrefixOf` constr = |
| 471 | | (\(ac,_)-> (TCxtSlurpy ac, etc)) (fromContents cs) |
| 472 | | | "TCxtLValue" `isPrefixOf` constr = |
| 473 | | (\(aa,_)-> (TCxtLValue aa, etc)) (fromContents cs) |
| 474 | | | "TCxtItem" `isPrefixOf` constr = |
| 475 | | (\(ab,_)-> (TCxtItem ab, etc)) (fromContents cs) |
| 476 | | toContents v@TCxtVoid = |
| 477 | | [mkElemC (showConstr 0 (toHType v)) []] |
| 478 | | toContents v@(TCxtLValue aa) = |
| 479 | | [mkElemC (showConstr 1 (toHType v)) (toContents aa)] |
| 480 | | toContents v@(TCxtItem ab) = |
| 481 | | [mkElemC (showConstr 2 (toHType v)) (toContents ab)] |
| 482 | | toContents v@(TCxtSlurpy ac) = |
| 483 | | [mkElemC (showConstr 3 (toHType v)) (toContents ac)] |
| 484 | | toContents v@(TTailCall ad) = |
| 485 | | [mkElemC (showConstr 4 (toHType v)) (toContents ad)] |
| 492 | | |
| 493 | | instance Haskell2Xml TEnv where |
| 494 | | toHType v = |
| 495 | | Defined "TEnv" [] |
| 496 | | [Constr "MkTEnv" [] |
| 497 | | [toHType aa,toHType ab,toHType ac,toHType ad,toHType ae]] |
| 498 | | where |
| 499 | | (MkTEnv aa ab ac ad ae) = v |
| 500 | | fromContents (CElem (Elem constr [] cs):etc) |
| 501 | | | "MkTEnv" `isPrefixOf` constr = |
| 502 | | (\(aa,cs00)-> (\(ab,cs01)-> (\(ac,cs02)-> (\(ad,cs03)-> (\(ae, |
| 503 | | _)-> (MkTEnv aa ab ac ad ae, etc)) |
| 504 | | (fromContents cs03)) |
| 505 | | (fromContents cs02)) |
| 506 | | (fromContents cs01)) |
| 507 | | (fromContents cs00)) |
| 508 | | (fromContents cs) |
| 509 | | toContents v@(MkTEnv aa ab ac ad ae) = |
| 510 | | [mkElemC (showConstr 0 (toHType v)) (concat [toContents aa, |
| 511 | | toContents ab,toContents ac,toContents ad, |
| 512 | | toContents ae])] |
| 521 | | |
| 522 | | instance Haskell2Xml Scope where |
| 523 | | toHType v = |
| 524 | | Defined "Scope" [] |
| 525 | | [Constr "SState" [] [],Constr "SMy" [] [],Constr "SOur" [] [], |
| 526 | | Constr "SLet" [] [],Constr "STemp" [] [],Constr "SGlobal" [] []] |
| 527 | | fromContents (CElem (Elem constr [] cs):etc) |
| 528 | | | "STemp" `isPrefixOf` constr = |
| 529 | | (STemp,etc) |
| 530 | | | "SState" `isPrefixOf` constr = |
| 531 | | (SState,etc) |
| 532 | | | "SOur" `isPrefixOf` constr = |
| 533 | | (SOur,etc) |
| 534 | | | "SMy" `isPrefixOf` constr = |
| 535 | | (SMy,etc) |
| 536 | | | "SLet" `isPrefixOf` constr = |
| 537 | | (SLet,etc) |
| 538 | | | "SGlobal" `isPrefixOf` constr = |
| 539 | | (SGlobal,etc) |
| 540 | | toContents v@SState = |
| 541 | | [mkElemC (showConstr 0 (toHType v)) []] |
| 542 | | toContents v@SMy = |
| 543 | | [mkElemC (showConstr 1 (toHType v)) []] |
| 544 | | toContents v@SOur = |
| 545 | | [mkElemC (showConstr 2 (toHType v)) []] |
| 546 | | toContents v@SLet = |
| 547 | | [mkElemC (showConstr 3 (toHType v)) []] |
| 548 | | toContents v@STemp = |
| 549 | | [mkElemC (showConstr 4 (toHType v)) []] |
| 550 | | toContents v@SGlobal = |
| 551 | | [mkElemC (showConstr 5 (toHType v)) []] |
| 561 | | |
| 562 | | instance Haskell2Xml SubType where |
| 563 | | toHType v = |
| 564 | | Defined "SubType" [] |
| 565 | | [Constr "SubMethod" [] [],Constr "SubCoroutine" [] [], |
| 566 | | Constr "SubMacro" [] [],Constr "SubRoutine" [] [], |
| 567 | | Constr "SubBlock" [] [],Constr "SubPointy" [] [], |
| 568 | | Constr "SubPrim" [] []] |
| 569 | | fromContents (CElem (Elem constr [] cs):etc) |
| 570 | | | "SubRoutine" `isPrefixOf` constr = |
| 571 | | (SubRoutine,etc) |
| 572 | | | "SubPrim" `isPrefixOf` constr = |
| 573 | | (SubPrim,etc) |
| 574 | | | "SubPointy" `isPrefixOf` constr = |
| 575 | | (SubPointy,etc) |
| 576 | | | "SubMethod" `isPrefixOf` constr = |
| 577 | | (SubMethod,etc) |
| 578 | | | "SubMacro" `isPrefixOf` constr = |
| 579 | | (SubMacro,etc) |
| 580 | | | "SubCoroutine" `isPrefixOf` constr = |
| 581 | | (SubCoroutine,etc) |
| 582 | | | "SubBlock" `isPrefixOf` constr = |
| 583 | | (SubBlock,etc) |
| 584 | | toContents v@SubMethod = |
| 585 | | [mkElemC (showConstr 0 (toHType v)) []] |
| 586 | | toContents v@SubCoroutine = |
| 587 | | [mkElemC (showConstr 1 (toHType v)) []] |
| 588 | | toContents v@SubMacro = |
| 589 | | [mkElemC (showConstr 2 (toHType v)) []] |
| 590 | | toContents v@SubRoutine = |
| 591 | | [mkElemC (showConstr 3 (toHType v)) []] |
| 592 | | toContents v@SubBlock = |
| 593 | | [mkElemC (showConstr 4 (toHType v)) []] |
| 594 | | toContents v@SubPointy = |
| 595 | | [mkElemC (showConstr 5 (toHType v)) []] |
| 596 | | toContents v@SubPrim = |
| 597 | | [mkElemC (showConstr 6 (toHType v)) []] |
| 609 | | instance Haskell2Xml Val where |
| 610 | | toHType v = |
| 611 | | Defined "Val" [] |
| 612 | | [Constr "VUndef" [] [],Constr "VBool" [] [toHType aa], |
| 613 | | Constr "VInt" [] [toHType ab],Constr "VRat" [] [toHType ac], |
| 614 | | Constr "VNum" [] [toHType ad],Constr "VStr" [] [toHType ae], |
| 615 | | Constr "VList" [] [toHType af],Constr "VType" [] [toHType ag]] |
| 616 | | where |
| 617 | | (VBool aa) = v |
| 618 | | (VInt ab) = v |
| 619 | | (VRat ac) = v |
| 620 | | (VNum ad) = v |
| 621 | | (VStr ae) = v |
| 622 | | (VList af) = v |
| 623 | | (VType ag) = v |
| 624 | | fromContents (CElem (Elem constr [] cs):etc) |
| 625 | | | "VUndef" `isPrefixOf` constr = |
| 626 | | (VUndef,etc) |
| 627 | | | "VType" `isPrefixOf` constr = |
| 628 | | (\(ag,_)-> (VType ag, etc)) (fromContents cs) |
| 629 | | | "VStr" `isPrefixOf` constr = |
| 630 | | (\(ae,_)-> (VStr ae, etc)) (fromContents cs) |
| 631 | | | "VRat" `isPrefixOf` constr = |
| 632 | | (\(ac,_)-> (VRat ac, etc)) (fromContents cs) |
| 633 | | | "VNum" `isPrefixOf` constr = |
| 634 | | (\(ad,_)-> (VNum ad, etc)) (fromContents cs) |
| 635 | | | "VList" `isPrefixOf` constr = |
| 636 | | (\(af,_)-> (VList af, etc)) (fromContents cs) |
| 637 | | | "VInt" `isPrefixOf` constr = |
| 638 | | (\(ab,_)-> (VInt ab, etc)) (fromContents cs) |
| 639 | | | "VBool" `isPrefixOf` constr = |
| 640 | | (\(aa,_)-> (VBool aa, etc)) (fromContents cs) |
| 641 | | toContents v@VUndef = |
| 642 | | [mkElemC (showConstr 0 (toHType v)) []] |
| 643 | | toContents v@(VBool aa) = |
| 644 | | [mkElemC (showConstr 1 (toHType v)) (toContents aa)] |
| 645 | | toContents v@(VInt ab) = |
| 646 | | [mkElemC (showConstr 2 (toHType v)) (toContents ab)] |
| 647 | | toContents v@(VRat ac) = |
| 648 | | [mkElemC (showConstr 3 (toHType v)) (toContents ac)] |
| 649 | | toContents v@(VNum ad) = |
| 650 | | [mkElemC (showConstr 4 (toHType v)) (toContents ad)] |
| 651 | | toContents v@(VStr ae) = |
| 652 | | [mkElemC (showConstr 5 (toHType v)) (toContents ae)] |
| 653 | | toContents v@(VList af) = |
| 654 | | [mkElemC (showConstr 6 (toHType v)) (toContents af)] |
| 655 | | toContents v@(VType ag) = |
| 656 | | [mkElemC (showConstr 7 (toHType v)) (toContents ag)] |
| 657 | | |
| 663 | | |
| 664 | | instance Haskell2Xml Cxt where |
| 665 | | toHType v = |
| 666 | | Defined "Cxt" [] |
| 667 | | [Constr "CxtVoid" [] [],Constr "CxtItem" [] [toHType aa], |
| 668 | | Constr "CxtSlurpy" [] [toHType ab]] |
| 669 | | where |
| 670 | | (CxtItem aa) = v |
| 671 | | (CxtSlurpy ab) = v |
| 672 | | fromContents (CElem (Elem constr [] cs):etc) |
| 673 | | | "CxtVoid" `isPrefixOf` constr = |
| 674 | | (CxtVoid,etc) |
| 675 | | | "CxtSlurpy" `isPrefixOf` constr = |
| 676 | | (\(ab,_)-> (CxtSlurpy ab, etc)) (fromContents cs) |
| 677 | | | "CxtItem" `isPrefixOf` constr = |
| 678 | | (\(aa,_)-> (CxtItem aa, etc)) (fromContents cs) |
| 679 | | toContents v@CxtVoid = |
| 680 | | [mkElemC (showConstr 0 (toHType v)) []] |
| 681 | | toContents v@(CxtItem aa) = |
| 682 | | [mkElemC (showConstr 1 (toHType v)) (toContents aa)] |
| 683 | | toContents v@(CxtSlurpy ab) = |
| 684 | | [mkElemC (showConstr 2 (toHType v)) (toContents ab)] |
| 692 | | |
| 693 | | instance Haskell2Xml Type where |
| 694 | | toHType v = |
| 695 | | Defined "Type" [] |
| 696 | | [Constr "MkType" [] [toHType aa], |
| 697 | | Constr "TypeOr" [] [toHType ab,toHType ac], |
| 698 | | Constr "TypeAnd" [] [toHType ad,toHType ae]] |
| 699 | | where |
| 700 | | (MkType aa) = v |
| 701 | | (TypeOr ab ac) = v |
| 702 | | (TypeAnd ad ae) = v |
| 703 | | fromContents (CElem (Elem constr [] cs):etc) |
| 704 | | | "TypeOr" `isPrefixOf` constr = |
| 705 | | (\(ab,cs00)-> (\(ac,_)-> (TypeOr ab ac, etc)) (fromContents cs00)) |
| 706 | | (fromContents cs) |
| 707 | | | "TypeAnd" `isPrefixOf` constr = |
| 708 | | (\(ad,cs00)-> (\(ae,_)-> (TypeAnd ad ae, etc)) (fromContents cs00)) |
| 709 | | (fromContents cs) |
| 710 | | | "MkType" `isPrefixOf` constr = |
| 711 | | (\(aa,_)-> (MkType aa, etc)) (fromContents cs) |
| 712 | | toContents v@(MkType aa) = |
| 713 | | [mkElemC (showConstr 0 (toHType v)) (toContents aa)] |
| 714 | | toContents v@(TypeOr ab ac) = |
| 715 | | [mkElemC (showConstr 1 (toHType v)) (concat [toContents ab, |