0 | module Go.AST.Combinators
   1 |
   2 | import Data.Bits
   3 | import public Data.List
   4 | import public Data.List1
   5 | import public Data.List.Quantifiers
   6 | import public Go.AST
   7 | import public Go.Token
   8 |
   9 | public export
  10 | interface Commentable a where
  11 |   setComments : CommentGroup -> a -> a
  12 |
  13 | export
  14 | comment : Commentable a => String -> a -> a
  15 | comment str = setComments $ MkCommentGroup $ singleton $ MkComment str
  16 |
  17 | export
  18 | comments : Commentable a => (cs : List String) -> {auto 0 ok : NonEmpty cs} -> a -> a
  19 | comments (x::xs) = setComments $ MkCommentGroup $ map MkComment (x:::xs)
  20 |
  21 | export
  22 | implementation Statement (AssignmentStatement ls rs) => Commentable (AssignmentStatement ls rs) where
  23 |   setComments cg = { comment := Just cg }
  24 |
  25 | export
  26 | implementation Statement (ExpressionStatement e) => Commentable (ExpressionStatement e) where
  27 |   setComments cg = { comment := Just cg }
  28 |
  29 | export
  30 | implementation Specification (ValueSpec e es) => Commentable (ValueSpec e es) where
  31 |   setComments cg = { comment := Just cg }
  32 |
  33 | public export
  34 | interface Documentable a where
  35 |   setDocs : CommentGroup -> a -> a
  36 |
  37 | export
  38 | doc : Documentable a => String -> a -> a
  39 | doc str = setDocs $ MkCommentGroup $ singleton $ MkComment str
  40 |
  41 | export
  42 | docs : Documentable a => (ds : List String) -> {auto 0 ok : NonEmpty ds} -> a -> a
  43 | docs (d::ds) = setDocs $ MkCommentGroup $ map MkComment (d:::ds)
  44 |
  45 | export
  46 | implementation Statement (AssignmentStatement ls rs) => Documentable (AssignmentStatement ls rs) where
  47 |   setDocs ds = { doc := Just ds }
  48 |
  49 | export
  50 | implementation Specification (ValueSpec ls rs) => Documentable (ValueSpec ls rs) where
  51 |   setDocs ds = { doc := Just ds }
  52 |
  53 | export
  54 | implementation Statement (ExpressionStatement e) => Documentable (ExpressionStatement e) where
  55 |   setDocs ds = { doc := Just ds }
  56 |
  57 | export
  58 | implementation Statement (ReturnStatement rs) => Documentable (ReturnStatement rs) where
  59 |   setDocs ds = { doc := Just ds }
  60 |
  61 | export
  62 | implementation Declaration (FuncDeclaration rcs ts ps rs sts) => Documentable (FuncDeclaration rcs ts ps rs sts) where
  63 |   setDocs ds = { doc := Just ds }
  64 |
  65 | export
  66 | data Package = MkPackage String
  67 |
  68 | export
  69 | package : String -> Package
  70 | package = MkPackage
  71 |
  72 | export
  73 | id_ :
  74 |   String ->
  75 |   Identifier
  76 | id_ name = MkIdentifier name
  77 |
  78 | export
  79 | file :
  80 |   { ds : List Type } ->
  81 |   { auto 0 ok : All Declaration ds } ->
  82 |   (name : String) ->
  83 |   Package ->
  84 |   List ImportSpec ->
  85 |   HList ds ->
  86 |   File ds
  87 | file name (MkPackage pkg) imports decls = MkFile Nothing name (id_ pkg) decls imports [] []
  88 |
  89 | namespace Literal
  90 |
  91 |   hexDigit : Int -> Char
  92 |   hexDigit v = if v < 10 then chr $ v + ord '0'
  93 |                          else chr $ v - 10 + ord 'a'
  94 |
  95 |   unicodeLiteral : Char -> String
  96 |   unicodeLiteral c =
  97 |     let v = ord c
  98 |         low1 = v .&. 0x0f
  99 |         high1 = (v `shiftR` 4) .&. 0x0f
 100 |         low2 = (v `shiftR` 8) .&. 0x0f
 101 |         high2 = (v `shiftR` 12) .&. 0x0f
 102 |     in if high2 > 0 || low2 > 0 then pack $ [ '\\', 'u', hexDigit high2, hexDigit low2, hexDigit high1, hexDigit low1 ]
 103 |                                 else pack $ [ '\\', 'x', hexDigit high1, hexDigit low1 ]
 104 |
 105 |   export
 106 |   runeL :
 107 |     Char ->
 108 |     BasicLiteral
 109 |   runeL c = MkBasicLiteral MkChar $ escape c
 110 |     where
 111 |       escape : Char -> String
 112 |       escape c = if (c >= ' ') && (c /= '\\')
 113 |                     && (c /= '\'') && (c <= '~')
 114 |                     then cast c
 115 |                     else case c of
 116 |                               '\0' => "\\x00"
 117 |                               '\a' => "\\a"
 118 |                               '\b' => "\\b"
 119 |                               '\f' => "\\f"
 120 |                               '\n' => "\\n"
 121 |                               '\r' => "\\r"
 122 |                               '\t' => "\\t"
 123 |                               '\v' => "\\v"
 124 |                               '\'' => "\\'"
 125 |                               '\\' => "\\\\"
 126 |                               other => unicodeLiteral other
 127 |
 128 |   export
 129 |   charL :
 130 |     Char ->
 131 |     BasicLiteral
 132 |   charL = runeL
 133 |
 134 |   export
 135 |   stringL :
 136 |     String ->
 137 |     BasicLiteral
 138 |   stringL str = MkBasicLiteral MkString escaped
 139 |     where
 140 |       escape : Char -> String
 141 |       escape c = if (c >= ' ') && (c /= '\\')
 142 |                     && (c /= '"') && (c <= '~')
 143 |                     then cast c
 144 |                     else case c of
 145 |                               '\0' => "\\x00"
 146 |                               '\a' => "\\a"
 147 |                               '\b' => "\\b"
 148 |                               '\f' => "\\f"
 149 |                               '\n' => "\\n"
 150 |                               '\r' => "\\r"
 151 |                               '\t' => "\\t"
 152 |                               '\v' => "\\v"
 153 |                               '\\' => "\\\\"
 154 |                               '"'  => "\\\""
 155 |                               other => unicodeLiteral other
 156 |
 157 |       escaped : String
 158 |       escaped = concatMap escape $ unpack str
 159 |
 160 |   export
 161 |   intL :
 162 |     Int ->
 163 |     BasicLiteral
 164 |   intL i = MkBasicLiteral MkInt $ show i
 165 |
 166 |   export
 167 |   floatL :
 168 |     Double ->
 169 |     BasicLiteral
 170 |   floatL f = MkBasicLiteral MkFloat $ show f
 171 |
 172 |   export
 173 |   expL :
 174 |     Double ->
 175 |     Int ->
 176 |     BasicLiteral
 177 |   expL f e = MkBasicLiteral MkFloat $ concat [floored, "e", show e]
 178 |     where
 179 |       floored : String
 180 |       floored = if f == floor f then show $ the Int $ cast $ floor f
 181 |                                 else show f
 182 |
 183 |   export
 184 |   imagL :
 185 |     Int ->
 186 |     BasicLiteral
 187 |   imagL i = MkBasicLiteral MkImag "\{show i}i"
 188 |
 189 |   export
 190 |   boolL :
 191 |     Bool ->
 192 |     BasicLiteral
 193 |   boolL b = MkBasicLiteral MkIdentifier $ case b of
 194 |                                           True => "true"
 195 |                                           False => "false"
 196 |
 197 |   export
 198 |   compositL :
 199 |     GoType t =>
 200 |     All Expression es =>
 201 |     t ->
 202 |     HList es ->
 203 |     CompositLiteral t es
 204 |   compositL t es = MkCompositLiteral (Just t) es
 205 |
 206 |   export
 207 |   compositL' :
 208 |     All Expression es =>
 209 |     HList es ->
 210 |     CompositLiteral BadType es
 211 |   compositL' es = MkCompositLiteral Nothing es
 212 |
 213 |   export
 214 |   funcL :
 215 |     All Statement sts =>
 216 |     FieldList ps ->
 217 |     FieldList rs ->
 218 |     HList sts ->
 219 |     FunctionLiteral [] ps rs sts
 220 |   funcL ps rs sts = MkFunctionLiteral (MkFunctionType [] ps rs) (MkBlockStatement sts)
 221 |
 222 | export
 223 | import_ :
 224 |   (path : String) ->
 225 |   ImportSpec
 226 | import_ path = MkImportSpec Nothing Nothing (stringL path) Nothing
 227 |
 228 | export
 229 | importN :
 230 |   (name : String) ->
 231 |   (path : String) ->
 232 |   ImportSpec
 233 | importN name path = MkImportSpec Nothing (Just $ id_ name) (stringL path) Nothing
 234 |
 235 | export
 236 | void : FieldList []
 237 | void = []
 238 |
 239 | export
 240 | fields :
 241 |   GoType t =>
 242 |   List String ->
 243 |   t ->
 244 |   Field t
 245 | fields fs t = MkField Nothing (id_ <$> fs) (Just t) Nothing Nothing
 246 |
 247 | export
 248 | fields' :
 249 |   List String ->
 250 |   Field BadType
 251 | fields' fs = MkField Nothing (id_ <$> fs) (Maybe BadType `the` Nothing) Nothing Nothing
 252 |
 253 | export
 254 | field :
 255 |   GoType t =>
 256 |   String ->
 257 |   t ->
 258 |   Field t
 259 | field f t = MkField Nothing [id_ f] (Just t) Nothing Nothing
 260 |
 261 | export
 262 | field' :
 263 |   String ->
 264 |   Field BadType
 265 | field' f = MkField Nothing [id_ f] Nothing Nothing Nothing
 266 |
 267 | export
 268 | fieldT :
 269 |   GoType t =>
 270 |   t ->
 271 |   Field t
 272 | fieldT t = MkField Nothing [] (Just t) Nothing Nothing
 273 |
 274 | namespace Type
 275 |
 276 |   export
 277 |   tid :
 278 |     String ->
 279 |     String ->
 280 |     TypeIdentifier
 281 |   tid p n = MkTypeIdentifier (Just $ id_ p) (id_ n)
 282 |
 283 |   export
 284 |   tid' :
 285 |     String ->
 286 |     TypeIdentifier
 287 |   tid' n = MkTypeIdentifier Nothing (id_ n)
 288 |
 289 |   export
 290 |   struct :
 291 |     FieldList ts ->
 292 |     StructType ts
 293 |   struct = MkStructType
 294 |
 295 |   export
 296 |   array :
 297 |     Expression l =>
 298 |     GoType t =>
 299 |     l ->
 300 |     t ->
 301 |     ArrayType l t
 302 |   array l t = MkArrayType (Just l) t
 303 |
 304 |   export
 305 |   array' :
 306 |     GoType t =>
 307 |     t ->
 308 |     ArrayType BadExpression t
 309 |   array' t = MkArrayType Nothing t
 310 |
 311 |   export
 312 |   map_ :
 313 |     GoType k =>
 314 |     GoType v =>
 315 |     k ->
 316 |     v ->
 317 |     MapType k v
 318 |   map_ k v = MkMapType k v
 319 |
 320 |   export
 321 |   func' :
 322 |     FieldList ps ->
 323 |     FieldList rs ->
 324 |     FunctionType [] ps rs
 325 |   func' ps rs = MkFunctionType [] ps rs
 326 |
 327 |   export
 328 |   bool : TypeIdentifier
 329 |   bool = tid' "bool"
 330 |
 331 |   export
 332 |   string : TypeIdentifier
 333 |   string = tid' "string"
 334 |
 335 |   export
 336 |   int : TypeIdentifier
 337 |   int = tid' "int"
 338 |
 339 |   export
 340 |   int8 : TypeIdentifier
 341 |   int8 = tid' "int8"
 342 |
 343 |   export
 344 |   int16 : TypeIdentifier
 345 |   int16 = tid' "int16"
 346 |
 347 |   export
 348 |   int32 : TypeIdentifier
 349 |   int32 = tid' "int32"
 350 |
 351 |   export
 352 |   int64 : TypeIdentifier
 353 |   int64 = tid' "int64"
 354 |
 355 |   export
 356 |   uint : TypeIdentifier
 357 |   uint = tid' "uint"
 358 |
 359 |   export
 360 |   uint8 : TypeIdentifier
 361 |   uint8 = tid' "uint8"
 362 |
 363 |   export
 364 |   uint16 : TypeIdentifier
 365 |   uint16 = tid' "uint16"
 366 |
 367 |   export
 368 |   uint32 : TypeIdentifier
 369 |   uint32 = tid' "uint32"
 370 |
 371 |   export
 372 |   uint64 : TypeIdentifier
 373 |   uint64 = tid' "uint64"
 374 |
 375 |   export
 376 |   uintptr : TypeIdentifier
 377 |   uintptr = tid' "uintptr"
 378 |
 379 |   export
 380 |   byte : TypeIdentifier
 381 |   byte = tid' "byte"
 382 |
 383 |   export
 384 |   rune : TypeIdentifier
 385 |   rune = tid' "rune"
 386 |
 387 |   export
 388 |   float32 : TypeIdentifier
 389 |   float32 = tid' "float32"
 390 |
 391 |   export
 392 |   float64 : TypeIdentifier
 393 |   float64 = tid' "float64"
 394 |
 395 |   export
 396 |   complex64 : TypeIdentifier
 397 |   complex64 = tid' "complex64"
 398 |
 399 |   export
 400 |   complex128 : TypeIdentifier
 401 |   complex128 = tid' "complex128"
 402 |
 403 | namespace Declaration
 404 |   export
 405 |   func :
 406 |     (name : String) ->
 407 |     FieldList ps ->
 408 |     FieldList rs ->
 409 |     { 0 sts : List Type } ->
 410 |     { auto 0 ok : All Statement sts } ->
 411 |     HList sts ->
 412 |     FuncDeclaration [] [] ps rs sts
 413 |   func name ps rs sts = MkFuncDeclaration Nothing [] (id_ name) (MkFunctionType [] ps rs) (MkBlockStatement sts)
 414 |
 415 |   export
 416 |   types :
 417 |     NonEmpty es =>
 418 |     All Specification es =>
 419 |     HList es ->
 420 |     GenericDeclaration MkType es
 421 |   types es = MkGenericDeclaration Nothing Type' es
 422 |
 423 |   export
 424 |   type :
 425 |     GoType t =>
 426 |     String ->
 427 |     FieldList ts ->
 428 |     t ->
 429 |     TypeSpec ts t
 430 |   type name typeParams t = MkTypeSpec Nothing (id_ name) typeParams t Nothing
 431 |
 432 |   export
 433 |   consts :
 434 |     NonEmpty es =>
 435 |     All Specification es =>
 436 |     HList es ->
 437 |     GenericDeclaration MkConst es
 438 |   consts es = MkGenericDeclaration Nothing Const es
 439 |
 440 |   export
 441 |   const_ :
 442 |     GoType t =>
 443 |     All Expression es =>
 444 |     (is : List Identifier) ->
 445 |     {auto 0 ok : NonEmpty is} ->
 446 |     t ->
 447 |     HList es ->
 448 |     ValueSpec t es
 449 |   const_ (i::is) t es = MkValueSpec Nothing (i:::is) (Just t) es Nothing
 450 |
 451 |   export
 452 |   const' :
 453 |     All Expression es =>
 454 |     (is : List Identifier) ->
 455 |     {auto 0 ok : NonEmpty is} ->
 456 |     HList es ->
 457 |     ValueSpec BadType es
 458 |   const' (i::is) es = MkValueSpec Nothing (i:::is) Nothing es Nothing
 459 |
 460 |   export
 461 |   vars :
 462 |     NonEmpty es =>
 463 |     All Specification es =>
 464 |     HList es ->
 465 |     GenericDeclaration MkVar es
 466 |   vars es = MkGenericDeclaration Nothing Var es
 467 |
 468 |   export
 469 |   var' :
 470 |     All Expression es =>
 471 |     (is : List Identifier) ->
 472 |     {auto 0 ok : NonEmpty is} ->
 473 |     HList es ->
 474 |     ValueSpec BadType es
 475 |   var' (i::is) es = MkValueSpec Nothing (i:::is) Nothing es Nothing
 476 |
 477 |   export
 478 |   var :
 479 |     GoType t =>
 480 |     All Expression es =>
 481 |     (is : List Identifier) ->
 482 |     {auto 0 ok : NonEmpty is} ->
 483 |     t ->
 484 |     HList es ->
 485 |     ValueSpec t es
 486 |   var (i::is) t es = MkValueSpec Nothing (i:::is) (Just t) es Nothing
 487 |
 488 | namespace Statement
 489 |
 490 |   export
 491 |   block :
 492 |     All Statement ts =>
 493 |     HList ts ->
 494 |     BlockStatement ts
 495 |   block = MkBlockStatement
 496 |
 497 |   export
 498 |   expr : Expression e => e -> ExpressionStatement e
 499 |   expr e = MkExpressionStatement Nothing e Nothing
 500 |
 501 |   export
 502 |   decl : Declaration d => d -> DeclarationStatement d
 503 |   decl d = MkDeclarationStatement d
 504 |
 505 |   export
 506 |   label :
 507 |     Statement s =>
 508 |     String ->
 509 |     s ->
 510 |     LabeledStatement s
 511 |   label str s = MkLabeledStatement (id_ str) s
 512 |
 513 |   export
 514 |   defer :
 515 |     CallExpression f as e ->
 516 |     DeferStatement f as e
 517 |   defer c = MkDeferStatement c
 518 |
 519 |   export
 520 |   return :
 521 |     All Expression es =>
 522 |     HList es ->
 523 |     ReturnStatement es
 524 |   return es = MkReturnStatement Nothing es
 525 |
 526 |   export
 527 |   continue :
 528 |     String ->
 529 |     BranchStatement MkContinue
 530 |   continue label = MkBranchStatement IsContinue $ Just $ id_ label
 531 |
 532 |   export
 533 |   continue_ : BranchStatement MkContinue
 534 |   continue_ = MkBranchStatement IsContinue Nothing
 535 |
 536 |   export
 537 |   for_ :
 538 |     Statement i =>
 539 |     Expression c =>
 540 |     Statement p =>
 541 |     All Statement sts =>
 542 |     i ->
 543 |     c ->
 544 |     p ->
 545 |     HList sts ->
 546 |     ForStatement i c p sts
 547 |   for_ i c p sts = MkForStatement (Just i) (Just c) (Just p) (MkBlockStatement sts)
 548 |
 549 |   export
 550 |   forever :
 551 |     All Statement sts =>
 552 |     HList sts ->
 553 |     ForStatement BadStatement BadExpression BadStatement sts
 554 |   forever sts = MkForStatement Nothing Nothing Nothing $ MkBlockStatement sts
 555 |
 556 |   export
 557 |   while :
 558 |     Expression c =>
 559 |     All Statement sts =>
 560 |     c ->
 561 |     HList sts ->
 562 |     ForStatement BadStatement c BadStatement sts
 563 |   while c sts = MkForStatement Nothing (Just c) Nothing $ MkBlockStatement sts
 564 |
 565 |   export
 566 |   rangeKV :
 567 |     Expression r =>
 568 |     All Statement sts =>
 569 |     (key : String) ->
 570 |     (value : String) ->
 571 |     r ->
 572 |     HList sts ->
 573 |     KeyValueRangeStatement Identifier Identifier MkDefine r sts
 574 |   rangeKV k v r sts = MkKeyValueRangeStatement (id_ k) (id_ v) ItIsDefine r $ MkBlockStatement sts
 575 |
 576 |   export
 577 |   rangeV :
 578 |     Expression r =>
 579 |     All Statement sts =>
 580 |     (value : String) ->
 581 |     r ->
 582 |     HList sts ->
 583 |     ValueRangeStatement Identifier MkDefine r sts
 584 |   rangeV v r sts = MkValueRangeStatement (id_ v) ItIsDefine r $ MkBlockStatement sts
 585 |
 586 |   export
 587 |   range :
 588 |     Expression r =>
 589 |     All Statement sts =>
 590 |     r ->
 591 |     HList sts ->
 592 |     RangeStatement r sts
 593 |   range r sts = MkRangeStatement r $ MkBlockStatement sts
 594 |
 595 |   export
 596 |   if_ :
 597 |     Expression c =>
 598 |     All Statement sts =>
 599 |     c ->
 600 |     HList sts ->
 601 |     IfStatement BadStatement c sts BadStatement
 602 |   if_ c sts = MkIfStatement Nothing c (MkBlockStatement sts) Nothing
 603 |
 604 |   export
 605 |   ifS :
 606 |     Statement i =>
 607 |     Expression c =>
 608 |     All Statement sts =>
 609 |     i ->
 610 |     c ->
 611 |     HList sts ->
 612 |     IfStatement i c sts BadStatement
 613 |   ifS i c sts = MkIfStatement (Just i) c (MkBlockStatement sts) Nothing
 614 |
 615 |   export
 616 |   ifE :
 617 |     Expression c =>
 618 |     All Statement sts =>
 619 |     Statement e =>
 620 |     c ->
 621 |     HList sts ->
 622 |     e ->
 623 |     IfStatement BadStatement c sts e
 624 |   ifE c sts e = MkIfStatement Nothing c (MkBlockStatement sts) (Just e)
 625 |
 626 |   export
 627 |   ifSE :
 628 |     Statement i =>
 629 |     Expression c =>
 630 |     All Statement sts =>
 631 |     Statement e =>
 632 |     i ->
 633 |     c ->
 634 |     HList sts ->
 635 |     e ->
 636 |     IfStatement i c sts e
 637 |   ifSE i c sts e = MkIfStatement (Just i) c (MkBlockStatement sts) (Just e)
 638 |
 639 |   export
 640 |   switchS :
 641 |     Statement i =>
 642 |     Expression e =>
 643 |     All Statement sts =>
 644 |     All IsCaseClause sts =>
 645 |     i ->
 646 |     e ->
 647 |     HList sts ->
 648 |     SwitchStatement i e sts
 649 |   switchS i e sts = MkSwitchStatement (Just i) (Just e) (MkBlockStatement sts)
 650 |
 651 |   export
 652 |   switch :
 653 |     Expression e =>
 654 |     All Statement sts =>
 655 |     All IsCaseClause sts =>
 656 |     e ->
 657 |     HList sts ->
 658 |     SwitchStatement BadStatement e sts
 659 |   switch e sts = MkSwitchStatement Nothing (Just e) (MkBlockStatement sts)
 660 |
 661 |   export
 662 |   switch' :
 663 |     All Statement sts =>
 664 |     All IsCaseClause sts =>
 665 |     HList sts ->
 666 |     SwitchStatement BadStatement BadExpression sts
 667 |   switch' sts = MkSwitchStatement Nothing Nothing (MkBlockStatement sts)
 668 |
 669 |   export
 670 |   case_ :
 671 |     All Expression es =>
 672 |     All Statement sts =>
 673 |     NonEmpty sts =>
 674 |     HList es ->
 675 |     HList sts ->
 676 |     CaseClause es sts
 677 |   case_ es sts = MkCaseClause es sts
 678 |
 679 |   export
 680 |   default_ :
 681 |     All Statement sts =>
 682 |     NonEmpty sts =>
 683 |     HList sts ->
 684 |     CaseClause [] sts
 685 |   default_ sts = MkCaseClause [] sts
 686 |
 687 | export
 688 | paren :
 689 |   Expression e =>
 690 |   e ->
 691 |   ParenExpression e
 692 | paren = MkParenExpression
 693 |
 694 | export
 695 | call :
 696 |   Expression fn =>
 697 |   fn ->
 698 |   { 0 args : List Type } ->
 699 |   { auto 0 argsOk : All Expression args } ->
 700 |   HList args ->
 701 |   CallExpression fn args BadExpression
 702 | call fn args = MkCallExpression fn args Nothing
 703 |
 704 | export
 705 | cast_ :
 706 |   GoType t =>
 707 |   Expression e =>
 708 |   t ->
 709 |   e ->
 710 |   CastExpression t e
 711 | cast_ = MkCastExpression
 712 |
 713 | export
 714 | typeAssert :
 715 |   Expression e =>
 716 |   GoType t =>
 717 |   e ->
 718 |   t ->
 719 |   TypeAssertExpression e t
 720 | typeAssert e t = MkTypeAssertExpression e t
 721 |
 722 | export
 723 | make :
 724 |   GoType t =>
 725 |   All Expression es =>
 726 |   t ->
 727 |   HList es ->
 728 |   MakeExpression t es
 729 | make t es = MkMakeExpression t es
 730 |
 731 | export
 732 | index :
 733 |   Expression e =>
 734 |   Expression i =>
 735 |   e ->
 736 |   i ->
 737 |   IndexExpression e i
 738 | index e i = MkIndexExpression e i
 739 |
 740 | export
 741 | slice :
 742 |   Expression e =>
 743 |   Expression l =>
 744 |   Expression h =>
 745 |   Expression m =>
 746 |   e ->
 747 |   l ->
 748 |   h ->
 749 |   m ->
 750 |   SliceExpression e l h m
 751 | slice e l h m = MkSliceExpression e (Just l) (Just h) (Just m)
 752 |
 753 | export
 754 | sliceLH :
 755 |   Expression e =>
 756 |   Expression l =>
 757 |   Expression h =>
 758 |   e ->
 759 |   l ->
 760 |   h ->
 761 |   SliceExpression e l h BadExpression
 762 | sliceLH e l h = MkSliceExpression e (Just l) (Just h) Nothing
 763 |
 764 | export
 765 | sliceL :
 766 |   Expression e =>
 767 |   Expression l =>
 768 |   e ->
 769 |   l ->
 770 |   SliceExpression e l BadExpression BadExpression
 771 | sliceL e l = MkSliceExpression e (Just l) Nothing Nothing
 772 |
 773 | export
 774 | sliceH :
 775 |   Expression e =>
 776 |   Expression h =>
 777 |   e ->
 778 |   h ->
 779 |   SliceExpression e BadExpression h BadExpression
 780 | sliceH e h = MkSliceExpression e Nothing (Just h) Nothing
 781 |
 782 | export
 783 | slice' :
 784 |   Expression e =>
 785 |   e ->
 786 |   SliceExpression e BadExpression BadExpression BadExpression
 787 | slice' e = MkSliceExpression e Nothing Nothing Nothing
 788 |
 789 | export
 790 | inc :
 791 |   Expression e =>
 792 |   e ->
 793 |   IncDecStatement e MkInc
 794 | inc e = MkIncDecStatement e Inc
 795 |
 796 | export
 797 | dec :
 798 |   Expression e =>
 799 |   e ->
 800 |   IncDecStatement e MkDec
 801 | dec e = MkIncDecStatement e Dec
 802 |
 803 | export
 804 | minus' :
 805 |   Expression e =>
 806 |   e ->
 807 |   UnaryExpression e
 808 | minus' e = MkUnaryExpression MkSub e
 809 |
 810 | export
 811 | (/./) :
 812 |   Expression e =>
 813 |   e ->
 814 |   String ->
 815 |   SelectorExpression e
 816 | (/./) e f = MkSelectorExpression e $ id_ f
 817 |
 818 | export
 819 | (/:/) :
 820 |   Expression e1 =>
 821 |   Expression e2 =>
 822 |   e1 ->
 823 |   e2 ->
 824 |   KeyValueExpression e1 e2
 825 | (/:/) e1 e2 = MkKeyValueExpression e1 e2
 826 |
 827 | export infixl 3 /./, /:/
 828 |
 829 | export
 830 | (/==/) :
 831 |   Expression e1 =>
 832 |   Expression e2 =>
 833 |   e1 ->
 834 |   e2 ->
 835 |   BinaryExpression e1 e2
 836 | (/==/) e1 e2 = MkBinaryExpression e1 MkEql e2
 837 |
 838 | export
 839 | (/!=/) :
 840 |   Expression e1 =>
 841 |   Expression e2 =>
 842 |   e1 ->
 843 |   e2 ->
 844 |   BinaryExpression e1 e2
 845 | (/!=/) e1 e2 = MkBinaryExpression e1 MkNotEql e2
 846 |
 847 | export
 848 | (/</) :
 849 |   Expression e1 =>
 850 |   Expression e2 =>
 851 |   e1 ->
 852 |   e2 ->
 853 |   BinaryExpression e1 e2
 854 | (/</) e1 e2 = MkBinaryExpression e1 MkLess e2
 855 |
 856 | export
 857 | (/<=/) :
 858 |   Expression e1 =>
 859 |   Expression e2 =>
 860 |   e1 ->
 861 |   e2 ->
 862 |   BinaryExpression e1 e2
 863 | (/<=/) e1 e2 = MkBinaryExpression e1 MkLessThanOrEqual e2
 864 |
 865 | export
 866 | (/>/) :
 867 |   Expression e1 =>
 868 |   Expression e2 =>
 869 |   e1 ->
 870 |   e2 ->
 871 |   BinaryExpression e1 e2
 872 | (/>/) e1 e2 = MkBinaryExpression e1 MkGreater e2
 873 |
 874 | export
 875 | (/>=/) :
 876 |   Expression e1 =>
 877 |   Expression e2 =>
 878 |   e1 ->
 879 |   e2 ->
 880 |   BinaryExpression e1 e2
 881 | (/>=/) e1 e2 = MkBinaryExpression e1 MkGreaterThanOrEqual e2
 882 |
 883 | export infixl 7 /==/, /!=/, /</, /<=/, />/, />=/
 884 |
 885 | export
 886 | (/+/) :
 887 |   Expression e1 =>
 888 |   Expression e2 =>
 889 |   e1 ->
 890 |   e2 ->
 891 |   BinaryExpression e1 e2
 892 | (/+/) e1 e2 = MkBinaryExpression e1 MkAdd e2
 893 |
 894 | export
 895 | (/-/) :
 896 |   Expression e1 =>
 897 |   Expression e2 =>
 898 |   e1 ->
 899 |   e2 ->
 900 |   BinaryExpression e1 e2
 901 | (/-/) e1 e2 = MkBinaryExpression e1 MkSub e2
 902 |
 903 | export
 904 | (/|/) :
 905 |   Expression e1 =>
 906 |   Expression e2 =>
 907 |   e1 ->
 908 |   e2 ->
 909 |   BinaryExpression e1 e2
 910 | (/|/) e1 e2 = MkBinaryExpression e1 MkOr e2
 911 |
 912 | export
 913 | (/^/) :
 914 |   Expression e1 =>
 915 |   Expression e2 =>
 916 |   e1 ->
 917 |   e2 ->
 918 |   BinaryExpression e1 e2
 919 | (/^/) e1 e2 = MkBinaryExpression e1 MkXor e2
 920 |
 921 | export infixl 8 /+/, /-/, /|/, /^/
 922 |
 923 | export
 924 | (/*/) :
 925 |   Expression e1 =>
 926 |   Expression e2 =>
 927 |   e1 ->
 928 |   e2 ->
 929 |   BinaryExpression e1 e2
 930 | (/*/) e1 e2 = MkBinaryExpression e1 MkMul e2
 931 |
 932 | export
 933 | (///) :
 934 |   Expression e1 =>
 935 |   Expression e2 =>
 936 |   e1 ->
 937 |   e2 ->
 938 |   BinaryExpression e1 e2
 939 | (///) e1 e2 = MkBinaryExpression e1 MkQuo e2
 940 |
 941 | export
 942 | (/%/) :
 943 |   Expression e1 =>
 944 |   Expression e2 =>
 945 |   e1 ->
 946 |   e2 ->
 947 |   BinaryExpression e1 e2
 948 | (/%/) e1 e2 = MkBinaryExpression e1 MkRem e2
 949 |
 950 | export
 951 | (/<</) :
 952 |   Expression e1 =>
 953 |   Expression e2 =>
 954 |   e1 ->
 955 |   e2 ->
 956 |   BinaryExpression e1 e2
 957 | (/<</) e1 e2 = MkBinaryExpression e1 MkShl e2
 958 |
 959 | export
 960 | (/>>/) :
 961 |   Expression e1 =>
 962 |   Expression e2 =>
 963 |   e1 ->
 964 |   e2 ->
 965 |   BinaryExpression e1 e2
 966 | (/>>/) e1 e2 = MkBinaryExpression e1 MkShr e2
 967 |
 968 | export
 969 | (/&/) :
 970 |   Expression e1 =>
 971 |   Expression e2 =>
 972 |   e1 ->
 973 |   e2 ->
 974 |   BinaryExpression e1 e2
 975 | (/&/) e1 e2 = MkBinaryExpression e1 MkAnd e2
 976 |
 977 | export infixl 9 /*/, ///, /%/, /<</, />>/, /&/
 978 |
 979 | export
 980 | (/:=/) :
 981 |   All Expression ls =>
 982 |   All Expression rs =>
 983 |   NonEmpty ls =>
 984 |   NonEmpty rs =>
 985 |   HList ls ->
 986 |   HList rs ->
 987 |   AssignmentStatement ls rs
 988 | (/:=/) ls rs = MkAssignmentStatement Nothing ls MkDefine rs Nothing
 989 |
 990 | export
 991 | (/=/) :
 992 |   All Expression ls =>
 993 |   All Expression rs =>
 994 |   NonEmpty ls =>
 995 |   NonEmpty rs =>
 996 |   HList ls ->
 997 |   HList rs ->
 998 |   AssignmentStatement ls rs
 999 | (/=/) ls rs = MkAssignmentStatement Nothing ls MkAssign rs Nothing
1000 |
1001 | export
1002 | (/+=/) :
1003 |   All Expression ls =>
1004 |   All Expression rs =>
1005 |   NonEmpty ls =>
1006 |   NonEmpty rs =>
1007 |   HList ls ->
1008 |   HList rs ->
1009 |   AssignmentStatement ls rs
1010 | (/+=/) ls rs = MkAssignmentStatement Nothing ls MkAddAssign rs Nothing
1011 |
1012 | export
1013 | (/-=/) :
1014 |   All Expression ls =>
1015 |   All Expression rs =>
1016 |   NonEmpty ls =>
1017 |   NonEmpty rs =>
1018 |   HList ls ->
1019 |   HList rs ->
1020 |   AssignmentStatement ls rs
1021 | (/-=/) ls rs = MkAssignmentStatement Nothing ls MkSubAssign rs Nothing
1022 |
1023 | export infixl 7 /:=/, /=/, /+=/, /-=/
1024 |
1025 | export
1026 | ptrOf :
1027 |   Expression e =>
1028 |   e ->
1029 |   UnaryExpression e
1030 | ptrOf e = MkUnaryExpression MkAnd e
1031 |
1032 | export
1033 | star :
1034 |   Expression e =>
1035 |   e ->
1036 |   StarExpression e
1037 | star e = MkStarExpression e
1038 |