Skip to content

Commit

Permalink
gambling: ignore new operator from prelude without able to try it
Browse files Browse the repository at this point in the history
  • Loading branch information
kbertalan committed Jun 8, 2024
1 parent c354d8b commit 9bb761b
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 16 deletions.
3 changes: 3 additions & 0 deletions src/Go/AST/Combinators.idr
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import public Data.List.Quantifiers
import public Go.AST
import public Go.Token

%hide Prelude.Ops.infixl.(|>)
%hide Prelude.(|>)

export
(|>) : a -> (a -> b) -> b
(|>) a fn = fn a
Expand Down
12 changes: 7 additions & 5 deletions src/Idris2/Compiler/Go.idr
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ import Idris2.Compiler.Go.Support.Gen

import Libraries.Utils.Path

%hide Prelude.Ops.infixl.(|>)
%hide Prelude.(|>)

namespace GoExp

public export
Expand Down Expand Up @@ -111,7 +114,7 @@ namespace Usage
used name (NmDelay _ _ exp) = used name exp
used name (NmConCase _ condition [MkNConAlt _ _ _ xs exp] Nothing) =
(used name condition && any (flip used exp) xs) || used name exp
used name (NmConCase _ exp alts mDef) = used name exp || usedConAlts name alts || fromMaybe False (used name <$> mDef)
used name (NmConCase _ exp alts mDef) = used name exp || usedConAlts name alts || fromMaybe False (used name <$> mDef)
used name (NmConstCase _ exp alts mDef) = used name exp || usedConstAlts name alts || fromMaybe False (used name <$> mDef)
used name (NmPrimVal _ cst) = False
used name (NmErased _) = False
Expand Down Expand Up @@ -184,7 +187,7 @@ goPrimConst ctx (B64 m) = MkGoExp $ cast_ uint64 $ MkBasicLiteral MkInt $ show m
goPrimConst ctx (Str str) = MkGoExp $ stringL str
goPrimConst ctx (Ch c) = MkGoExp $ charL c
goPrimConst ctx (Db dbl) = MkGoExp $ floatL dbl
goPrimConst ctx (PrT pty) =
goPrimConst ctx (PrT pty) =
let tyName = case pty of
IntType => "IntTypeValue"
Int8Type => "Int8TypeValue"
Expand Down Expand Up @@ -850,7 +853,7 @@ goTailCallFnBody ctx tag args alts =
cap = capFromAlts alts 1
in [ id_ tcVarName ] /:=/ [ intL tag ]
:: decl (vars [ var [ id_ tcArgName ] (array (intL cap) (tid' "any")) [] ])
:: assignValues 0 args
:: assignValues 0 args
[ label tcLabelName $ while (id_ tcVarName /!=/ intL 0) sts
, return [ id_ tcArgName `index` intL 0 ]
]
Expand Down Expand Up @@ -888,7 +891,7 @@ goTailCallFnBody ctx tag args alts =
assignValues n (name :: ns) rest =
([ id_ tcArgName `index` intL n ] /=/ [ id_ $ value $ goName name]) :: assignValues (n+1) ns rest

goLog :
goLog :
{auto c : Ref Ctxt Defs} ->
Nat ->
String ->
Expand Down Expand Up @@ -1285,4 +1288,3 @@ compileGo outDir outFile defs exp = do

goLog 5 "completed \{show outFile}"
pure Nothing

4 changes: 3 additions & 1 deletion tests/tour/basics14/Basics14.idr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ module Basics14
import Go.AST.Printer as Go
import Go.AST.Combinators as Go

%hide Prelude.Ops.infixl.(|>)
%hide Prelude.(|>)

main : IO ()
main = do
let src = file "type-conversions.go"
Expand All @@ -17,4 +20,3 @@ main = do
Right () <- printFile "build/go" src
| Left e => putStrLn $ show e
pure ()

4 changes: 3 additions & 1 deletion tests/tour/basics16/Basics16.idr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ module Basics16
import Go.AST.Printer as Go
import Go.AST.Combinators as Go

%hide Prelude.Ops.infixl.(|>)
%hide Prelude.(|>)

main : IO ()
main = do
let src = file "numeric-constants.go"
Expand Down Expand Up @@ -30,4 +33,3 @@ main = do
Right () <- printFile "build/go" src
| Left e => putStrLn $ show e
pure ()

4 changes: 3 additions & 1 deletion tests/tour/flowcontrol7/FlowControl7.idr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ module FlowControl7
import Go.AST.Printer as Go
import Go.AST.Combinators as Go

%hide Prelude.Ops.infixl.(|>)
%hide Prelude.(|>)

main : IO ()
main = do
let src = file "if-and-else.go"
Expand All @@ -28,4 +31,3 @@ main = do
Right () <- printFile "build/go" src
| Left e => putStrLn $ show e
pure ()

4 changes: 3 additions & 1 deletion tests/tour/flowcontrol9/FlowControl9.idr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ module FlowControl9
import Go.AST.Printer as Go
import Go.AST.Combinators as Go

%hide Prelude.Ops.infixl.(|>)
%hide Prelude.(|>)

main : IO ()
main = do
let src = file "switch.go"
Expand Down Expand Up @@ -31,4 +34,3 @@ main = do
Right () <- printFile "build/go" src
| Left e => putStrLn $ show e
pure ()

4 changes: 3 additions & 1 deletion tests/tour/moretypes1/MoreTypes1.idr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ module MoreTypes1
import Go.AST.Printer as Go
import Go.AST.Combinators as Go

%hide Prelude.Ops.infixl.(|>)
%hide Prelude.(|>)

main : IO ()
main = do
let src = file "pointers.go"
Expand Down Expand Up @@ -30,4 +33,3 @@ main = do
Right () <- printFile "build/go" src
| Left e => putStrLn $ show e
pure ()

6 changes: 4 additions & 2 deletions tests/tour/moretypes11/MoreTypes11.idr
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ module MoreTypes11
import Go.AST.Printer as Go
import Go.AST.Combinators as Go

%hide Prelude.Ops.infixl.(|>)
%hide Prelude.(|>)

main : IO ()
main = do
let src = file "slice-len-cap.go"
(package "main")
[ import_ "fmt" ]
[ func "main" [] void
[ [ id_ "s" ] /:=/ [ compositL (array' int)
[ [ id_ "s" ] /:=/ [ compositL (array' int)
[ intL 2
, intL 3
, intL 5
Expand Down Expand Up @@ -41,4 +44,3 @@ main = do
Right () <- printFile "build/go" src
| Left e => putStrLn $ show e
pure ()

4 changes: 3 additions & 1 deletion tests/tour/moretypes14/MoreTypes14.idr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ module MoreTypes14
import Go.AST.Printer as Go
import Go.AST.Combinators as Go

%hide Prelude.Ops.infixl.(|>)
%hide Prelude.(|>)

main : IO ()
main = do
let src = file "slices-of-slice.go"
Expand Down Expand Up @@ -38,4 +41,3 @@ main = do
Right () <- printFile "build/go" src
| Left e => putStrLn $ show e
pure ()

4 changes: 3 additions & 1 deletion tests/tour/moretypes15/MoreTypes15.idr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ module MoreTypes15
import Go.AST.Printer as Go
import Go.AST.Combinators as Go

%hide Prelude.Ops.infixl.(|>)
%hide Prelude.(|>)

main : IO ()
main = do
let src = file "append.go"
Expand Down Expand Up @@ -34,4 +37,3 @@ main = do
Right () <- printFile "build/go" src
| Left e => putStrLn $ show e
pure ()

4 changes: 3 additions & 1 deletion tests/tour/moretypes17/MoreTypes17.idr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ module MoreTypes17
import Go.AST.Printer as Go
import Go.AST.Combinators as Go

%hide Prelude.Ops.infixl.(|>)
%hide Prelude.(|>)

main : IO ()
main = do
let src = file "range-continued.go"
Expand All @@ -23,4 +26,3 @@ main = do
Right () <- printFile "build/go" src
| Left e => putStrLn $ show e
pure ()

4 changes: 3 additions & 1 deletion tests/tour/moretypes5/MoreTypes5.idr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ module MoreTypes5
import Go.AST.Printer as Go
import Go.AST.Combinators as Go

%hide Prelude.Ops.infixl.(|>)
%hide Prelude.(|>)

main : IO ()
main = do
let src = file "struct-literals.go"
Expand Down Expand Up @@ -31,4 +34,3 @@ main = do
Right () <- printFile "build/go" src
| Left e => putStrLn $ show e
pure ()

0 comments on commit 9bb761b

Please sign in to comment.