mirror of
https://codeberg.org/ProgramSnail/lang_2023.git
synced 2025-12-05 22:48:42 +00:00
fixes, builtin function fixes, deep copy, string access
This commit is contained in:
parent
3af0772da6
commit
9aaac90ef6
13 changed files with 450 additions and 152 deletions
|
|
@ -1,9 +1,9 @@
|
|||
basic (Float : #Ord #Div)
|
||||
basic (Int : #Ord #IDiv)
|
||||
basic (String : #Ord)
|
||||
basic (Char : #Ord #Enum)
|
||||
basic (Bool : #Ord)
|
||||
basic Unit
|
||||
basic (Float : #Ord #Div #Show)
|
||||
basic (Int : #Ord #IDiv #Show)
|
||||
basic (String : #Ord #Show #CharContainer)
|
||||
basic (Char : #Ord #Show)
|
||||
basic (Bool : #Ord #Show)
|
||||
basic (Unit : #Show)
|
||||
|
||||
//
|
||||
|
||||
|
|
@ -35,6 +35,12 @@ def ( || ) : x y =
|
|||
|
||||
//
|
||||
|
||||
typeclass CharContainer =
|
||||
& var size : -> Int
|
||||
& var at : Int -> Char
|
||||
|
||||
//
|
||||
|
||||
typeclass Move =
|
||||
& var ( <- ) : Move -> Unit // TODO
|
||||
|
||||
|
|
@ -142,11 +148,11 @@ namespace var Ord {
|
|||
typeclass Show =
|
||||
& var show : -> String
|
||||
|
||||
typeclass Read =
|
||||
& var read : String -> Read
|
||||
// typeclass Read = // TODO
|
||||
// & var read : String -> Read
|
||||
|
||||
typeclass DebugShow =
|
||||
& debug_show : -> String
|
||||
// typeclass DebugShow = // TODO
|
||||
// & debug_show : -> String
|
||||
|
||||
//
|
||||
|
||||
|
|
@ -171,6 +177,12 @@ typeclass Enum =
|
|||
|
||||
//
|
||||
|
||||
decl print : String -> Unit
|
||||
decl scan : -> String
|
||||
decl random : -> Int // TODO
|
||||
|
||||
//
|
||||
|
||||
// // bad
|
||||
// typeclass Functor 'A =
|
||||
// & fmap 'B ('F : (#Functor 'B)) : ('A -> 'B) -> Functor -> 'F
|
||||
|
|
@ -189,22 +201,21 @@ decl ( -- ) : Int -> Int -> Int_0
|
|||
def ( -- ) : begin end = {
|
||||
var current = begin
|
||||
return (while current < end do {
|
||||
; current += 1
|
||||
bring current - 1
|
||||
//; current += 1
|
||||
//bring current - 1
|
||||
bring 1
|
||||
})
|
||||
}
|
||||
|
||||
decl print : String -> Unit
|
||||
decl scan : -> String
|
||||
|
||||
decl func : String -> Int
|
||||
def func : s = {
|
||||
decl func : String -> Int -> Int
|
||||
def func : s i = {
|
||||
; print: s
|
||||
; print: (i.show:)
|
||||
return 5
|
||||
}
|
||||
|
||||
exec main {
|
||||
for i in 0--9 do func: "abacaba"
|
||||
for i in 0--9 do func: "abacaba" i
|
||||
; print: ({
|
||||
if true then bring scan: else { ; print: "aaa" }
|
||||
bring "nothing"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue