forked from omelkonian/agda-minimal-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compile one argument identity function (#10)
* test existing code creating moduleHeader * module header is proper Rust comment * fix non-compiling Test.agda example - add test.Test module * handle module name and brackets * handle function name, brackets around body, raw body * handle data type definition as enum - name, brackets and raw clauses * update examples Hello and Test with new handling of functions and data types * simplify Hello.agda enum + function on enum * extract functions for hande functions, handle data type, handle module * handle enums * use bracket, rename handleX to compileX * use bracket, rename handleX to compileX - fix unit tests * use bracket, rename handleX to compileX - fix unit tests 2 * extract PrettyPrintingUtils and ToRustCompiler; common types between ToRustCompiler and Backed are in CommonTypes * add typeSeparator and argList for pretty printing * compile singe argument function - argument name, its argument, function result type and single variable result body * compile singe argument function - add return * compile singe argument function - update Hello example * compile singe argument function - add comments for further improvements * proper function return type; rename to be more in-line with Rust naming style * fix function return types (broke during rebase) * change to lowercase names * remove empty lines * fix use module name instead of first directory * RustExpr to separate pretty printing from traverse Agda internals (#18) * add RustExpr to separate pretty printing and creating expression from Agda internals * rename after refactor to RustExpr * rename after refactor to RustExpr - fix * swap unless to when * Revert "RustExpr to separate pretty printing from traverse Agda internals (#18)" (#19) This reverts commit 2f56f9a.
- Loading branch information
Showing
10 changed files
with
169 additions
and
42 deletions.
There are no files selected for viewing
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
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
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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,52 @@ | ||
module test.hello where | ||
|
||
-- simple record type | ||
data Rgb : Set where | ||
Red Green Blue : Rgb | ||
{-# COMPILE AGDA2RUST Rgb #-} | ||
data TheRgb : Set where | ||
Red Green Blue : TheRgb | ||
{-# COMPILE AGDA2RUST TheRgb #-} | ||
|
||
-- simple function | ||
-- idRgb : Rgb → Rgb | ||
-- idRgb x = x | ||
-- {-# COMPILE AGDA2RUST idRgb #-} | ||
idRgb : TheRgb → TheRgb | ||
idRgb rgbArg = rgbArg | ||
{-# COMPILE AGDA2RUST idRgb #-} | ||
|
||
data TheWeekDay : Set where | ||
Monday Tuesday Wednesday Thursday Friday Saturday Sunday : TheWeekDay | ||
{-# COMPILE AGDA2RUST TheWeekDay #-} | ||
|
||
-- asFriday : TheRgb → TheWeekDay | ||
-- asFriday rgbArg = Friday -- TODO compile body | ||
-- {-# COMPILE AGDA2RUST asFriday #-} | ||
|
||
-- TODO multiple clauses | ||
-- day-color : TheWeekDay → TheRgb | ||
-- day-color Saturday = green | ||
-- day-color Sunday = blue | ||
-- day-color _ = red | ||
-- {-# COMPILE AGDA2RUST day-color #-} | ||
|
||
-- TODO multiple arguments | ||
-- ≡Days? : TheWeekDay → TheWeekDay → TheRgb | ||
-- ≡Days? Saturday Saturday = green | ||
-- ≡Days? Sunday Sunday = blue | ||
-- ≡Days? _ _ = red | ||
-- {-# COMPILE AGDA2RUST ≡Days? #-} | ||
|
||
-- TODO polymorphic types | ||
|
||
-- TODO Data.Bool | ||
-- TODO if expressions, and, or | ||
|
||
-- TODO Data.Nat | ||
-- TODO arithmetic expressions | ||
|
||
-- TODO Lists | ||
|
||
-- TODO Data.String | ||
-- TODO borrow types | ||
|
||
-- TODO Data.Product | ||
|
||
-- TODO Data.Sum | ||
|
||
-- recursive functions |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
mod hello { | ||
enum TheRgb { | ||
Red, Green, Blue | ||
} | ||
pub fn idRgb(rgbArg: TheRgb) -> TheRgb { | ||
return rgbArg | ||
} | ||
|
||
enum TheWeekDay { | ||
Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday | ||
} | ||
|
||
} |
File renamed without changes.
Empty file.