mirror of
https://github.com/unisonweb/unison.git
synced 2024-09-11 10:35:57 +03:00
Merge pull request #1427 from stew/new-Int-operations
add three new operations to Int
This commit is contained in:
commit
4b20ca7768
@ -40,3 +40,4 @@ The format for this list: name, GitHub handle, and then optional blurb about wha
|
||||
* Moses Alexander (@moses-alexander)
|
||||
* Andre Popovitch (@anchpop)
|
||||
* Daniël Heres (@Dandandan)
|
||||
* Stew O'Connor (@stew)
|
||||
|
@ -241,29 +241,35 @@ builtinsSrc =
|
||||
, B "Int.signum" $ int --> int
|
||||
, B "Int.negate" $ int --> int
|
||||
, B "Int.mod" $ int --> int --> int
|
||||
, B "Int.pow" $ int --> nat --> int
|
||||
, B "Int.shiftLeft" $ int --> nat --> int
|
||||
, B "Int.shiftRight" $ int --> nat --> int
|
||||
, B "Int.truncate0" $ int --> nat
|
||||
, B "Int.toText" $ int --> text
|
||||
, B "Int.fromText" $ text --> optional int
|
||||
, B "Int.toFloat" $ int --> float
|
||||
|
||||
, B "Nat.+" $ nat --> nat --> nat
|
||||
, B "Nat.drop" $ nat --> nat --> nat
|
||||
, B "Nat.sub" $ nat --> nat --> int
|
||||
, B "Nat.*" $ nat --> nat --> nat
|
||||
, B "Nat.+" $ nat --> nat --> nat
|
||||
, B "Nat./" $ nat --> nat --> nat
|
||||
, B "Nat.mod" $ nat --> nat --> nat
|
||||
, B "Nat.<" $ nat --> nat --> boolean
|
||||
, B "Nat.>" $ nat --> nat --> boolean
|
||||
, B "Nat.<=" $ nat --> nat --> boolean
|
||||
, B "Nat.>=" $ nat --> nat --> boolean
|
||||
, B "Nat.==" $ nat --> nat --> boolean
|
||||
, B "Nat.>" $ nat --> nat --> boolean
|
||||
, B "Nat.>=" $ nat --> nat --> boolean
|
||||
, B "Nat.drop" $ nat --> nat --> nat
|
||||
, B "Nat.fromText" $ text --> optional nat
|
||||
, B "Nat.increment" $ nat --> nat
|
||||
, B "Nat.isEven" $ nat --> boolean
|
||||
, B "Nat.isOdd" $ nat --> boolean
|
||||
, B "Nat.mod" $ nat --> nat --> nat
|
||||
, B "Nat.pow" $ nat --> nat --> nat
|
||||
, B "Nat.shiftLeft" $ nat --> nat --> nat
|
||||
, B "Nat.shiftRight" $ nat --> nat --> nat
|
||||
, B "Nat.sub" $ nat --> nat --> int
|
||||
, B "Nat.toFloat" $ nat --> float
|
||||
, B "Nat.toInt" $ nat --> int
|
||||
, B "Nat.toText" $ nat --> text
|
||||
, B "Nat.fromText" $ text --> optional nat
|
||||
, B "Nat.toFloat" $ nat --> float
|
||||
|
||||
, B "Float.+" $ float --> float --> float
|
||||
, B "Float.-" $ float --> float --> float
|
||||
|
@ -209,10 +209,12 @@ data IR' ann z
|
||||
| AddI z z | SubI z z | MultI z z | DivI z z
|
||||
| GtI z z | LtI z z | GtEqI z z | LtEqI z z | EqI z z
|
||||
| SignumI z | NegateI z | Truncate0I z | ModI z z
|
||||
| PowI z z | ShiftLI z z | ShiftRI z z
|
||||
-- Nats
|
||||
| AddN z z | DropN z z | SubN z z | MultN z z | DivN z z
|
||||
| GtN z z | LtN z z | GtEqN z z | LtEqN z z | EqN z z
|
||||
| ModN z z | ToIntN z
|
||||
| ModN z z | ToIntN z | PowN z z | ShiftLN z z | ShiftRN z z
|
||||
|
||||
-- Floats
|
||||
| AddF z z | SubF z z | MultF z z | DivF z z
|
||||
| GtF z z | LtF z z | GtEqF z z | LtEqF z z | EqF z z
|
||||
@ -277,6 +279,9 @@ prettyIR ppe prettyE prettyCont = pir
|
||||
NegateI a -> P.parenthesize $ "NegateI" `P.hang` P.spaced [pz a]
|
||||
Truncate0I a -> P.parenthesize $ "Truncate0I" `P.hang` P.spaced [pz a]
|
||||
ModI a b -> P.parenthesize $ "ModI" `P.hang` P.spaced [pz a, pz b]
|
||||
PowI a b -> P.parenthesize $ "PowI" `P.hang` P.spaced [pz a, pz b]
|
||||
ShiftRI a b -> P.parenthesize $ "ShiftRI" `P.hang` P.spaced [pz a, pz b]
|
||||
ShiftLI a b -> P.parenthesize $ "ShiftLI" `P.hang` P.spaced [pz a, pz b]
|
||||
|
||||
AddN a b -> P.parenthesize $ "AddN" `P.hang` P.spaced [pz a, pz b]
|
||||
SubN a b -> P.parenthesize $ "SubN" `P.hang` P.spaced [pz a, pz b]
|
||||
@ -290,6 +295,9 @@ prettyIR ppe prettyE prettyCont = pir
|
||||
EqN a b -> P.parenthesize $ "EqN" `P.hang` P.spaced [pz a, pz b]
|
||||
ModN a b -> P.parenthesize $ "ModN" `P.hang` P.spaced [pz a, pz b]
|
||||
ToIntN a -> P.parenthesize $ "ToIntN" `P.hang` P.spaced [pz a]
|
||||
PowN a b -> P.parenthesize $ "PowN" `P.hang` P.spaced [pz a, pz b]
|
||||
ShiftLN a b -> P.parenthesize $ "ShiftLN" `P.hang` P.spaced [pz a, pz b]
|
||||
ShiftRN a b -> P.parenthesize $ "ShiftRN" `P.hang` P.spaced [pz a, pz b]
|
||||
|
||||
AddF a b -> P.parenthesize $ "AddF" `P.hang` P.spaced [pz a, pz b]
|
||||
SubF a b -> P.parenthesize $ "SubF" `P.hang` P.spaced [pz a, pz b]
|
||||
@ -673,6 +681,9 @@ boundVarsIR = \case
|
||||
NegateI _ -> mempty
|
||||
Truncate0I _ -> mempty
|
||||
ModI _ _ -> mempty
|
||||
PowI _ _ -> mempty
|
||||
ShiftRI _ _ -> mempty
|
||||
ShiftLI _ _ -> mempty
|
||||
AddN _ _ -> mempty
|
||||
DropN _ _ -> mempty
|
||||
SubN _ _ -> mempty
|
||||
@ -684,6 +695,9 @@ boundVarsIR = \case
|
||||
LtEqN _ _ -> mempty
|
||||
EqN _ _ -> mempty
|
||||
ModN _ _ -> mempty
|
||||
PowN _ _ -> mempty
|
||||
ShiftLN _ _ -> mempty
|
||||
ShiftRN _ _ -> mempty
|
||||
ToIntN _ -> mempty
|
||||
AddF _ _ -> mempty
|
||||
SubF _ _ -> mempty
|
||||
@ -725,6 +739,9 @@ decompileIR stack = \case
|
||||
NegateI x -> builtin "Int.negate" [x]
|
||||
Truncate0I x -> builtin "Int.truncate0" [x]
|
||||
ModI x y -> builtin "Int.mod" [x,y]
|
||||
PowI x y -> builtin "Int.pow" [x,y]
|
||||
ShiftRI x y -> builtin "Int.shiftRight" [x,y]
|
||||
ShiftLI x y -> builtin "Int.shiftLeft" [x,y]
|
||||
AddN x y -> builtin "Nat.+" [x,y]
|
||||
DropN x y -> builtin "Nat.drop" [x,y]
|
||||
SubN x y -> builtin "Nat.sub" [x,y]
|
||||
@ -737,6 +754,9 @@ decompileIR stack = \case
|
||||
EqN x y -> builtin "Nat.==" [x,y]
|
||||
ModN x y -> builtin "Nat.mod" [x,y]
|
||||
ToIntN x -> builtin "Nat.toInt" [x]
|
||||
PowN x y -> builtin "Nat.pow" [x,y]
|
||||
ShiftRN x y -> builtin "Nat.shiftRight" [x,y]
|
||||
ShiftLN x y -> builtin "Nat.shiftLeft" [x,y]
|
||||
AddF x y -> builtin "Float.+" [x,y]
|
||||
SubF x y -> builtin "Float.-" [x,y]
|
||||
MultF x y -> builtin "Float.*" [x,y]
|
||||
@ -891,6 +911,9 @@ builtins = Map.fromList $ arity0 <> arityN
|
||||
, ("Int.negate", 1, NegateI (Slot 0))
|
||||
, ("Int.truncate0", 1, Truncate0I (Slot 0))
|
||||
, ("Int.mod", 2, ModI (Slot 1) (Slot 0))
|
||||
, ("Int.pow", 2, PowI (Slot 1) (Slot 0))
|
||||
, ("Int.shiftLeft", 2, ShiftLI (Slot 1) (Slot 0))
|
||||
, ("Int.shiftRight", 2, ShiftRI (Slot 1) (Slot 0))
|
||||
, ("Int.isEven", 1, let' var (ModI (Slot 0) (Val (I 2)))
|
||||
(EqI (Val (I 0)) (Slot 0)))
|
||||
, ("Int.isOdd", 1, let' var (ModI (Slot 0) (Val (I 2)))
|
||||
@ -909,6 +932,9 @@ builtins = Map.fromList $ arity0 <> arityN
|
||||
, ("Nat.==", 2, EqN (Slot 1) (Slot 0))
|
||||
, ("Nat.increment", 1, AddN (Val (N 1)) (Slot 0))
|
||||
, ("Nat.mod", 2, ModN (Slot 1) (Slot 0))
|
||||
, ("Nat.pow", 2, PowN (Slot 1) (Slot 0))
|
||||
, ("Nat.shiftLeft", 2, ShiftLN (Slot 1) (Slot 0))
|
||||
, ("Nat.shiftRight", 2, ShiftRN (Slot 1) (Slot 0))
|
||||
, ("Nat.isEven", 1, let' var (ModN (Slot 0) (Val (N 2)))
|
||||
(EqN (Val (N 0)) (Slot 0)))
|
||||
, ("Nat.isOdd", 1, let' var (ModN (Slot 0) (Val (N 2)))
|
||||
|
@ -15,6 +15,7 @@ module Unison.Runtime.Rt1 where
|
||||
import Unison.Prelude
|
||||
|
||||
import Data.Bifunctor (second)
|
||||
import Data.Bits (shiftR, shiftL)
|
||||
import Data.IORef
|
||||
import Unison.Runtime.IR (pattern CompilationEnv, pattern Req)
|
||||
import Unison.Runtime.IR hiding (CompilationEnv, IR, Req, Value, Z)
|
||||
@ -512,6 +513,9 @@ run ioHandler env ir = do
|
||||
NegateI i -> do x <- ati size i m; done (I (negate x))
|
||||
Truncate0I i -> do x <- ati size i m; done (N (fromIntegral (truncate0 x)))
|
||||
ModI i j -> do x <- ati size i m; y <- ati size j m; done (I (x `mod` y))
|
||||
PowI i j -> do x <- ati size i m; y <- atn size j m; done (I (x ^ y))
|
||||
ShiftRI i j -> do x <- ati size i m; y <- atn size j m; done (I (x `shiftR` (fromIntegral y)))
|
||||
ShiftLI i j -> do x <- ati size i m; y <- atn size j m; done (I (x `shiftL` (fromIntegral y)))
|
||||
|
||||
AddN i j -> do x <- atn size i m; y <- atn size j m; done (N (x + y))
|
||||
-- cast to `Int` and subtract
|
||||
@ -523,6 +527,9 @@ run ioHandler env ir = do
|
||||
MultN i j -> do x <- atn size i m; y <- atn size j m; done (N (x * y))
|
||||
DivN i j -> do x <- atn size i m; y <- atn size j m; done (N (x `div` y))
|
||||
ModN i j -> do x <- atn size i m; y <- atn size j m; done (N (x `mod` y))
|
||||
PowN i j -> do x <- atn size i m; y <- atn size j m; done (N (fromIntegral (x ^ y)))
|
||||
ShiftRN i j -> do x <- atn size i m; y <- atn size j m; done (N (fromIntegral (x `shiftR` (fromIntegral y))))
|
||||
ShiftLN i j -> do x <- atn size i m; y <- atn size j m; done (N (fromIntegral (x `shiftL` (fromIntegral y))))
|
||||
ToIntN i -> do x <- atn size i m; done (I (fromIntegral x))
|
||||
GtN i j -> do x <- atn size i m; y <- atn size j m; done (B (x > y))
|
||||
GtEqN i j -> do x <- atn size i m; y <- atn size j m; done (B (x >= y))
|
||||
|
20
unison-src/tests/methodical/int.u
Normal file
20
unison-src/tests/methodical/int.u
Normal file
@ -0,0 +1,20 @@
|
||||
use Int increment isEven isOdd signum negate mod pow shiftLeft shiftRight truncate0 toText fromText toFloat
|
||||
|
||||
withDefault : Optional a -> a -> a
|
||||
withDefault opt d = match opt with
|
||||
Some x -> x
|
||||
None -> d
|
||||
|
||||
> (increment +3,
|
||||
isEven +3,
|
||||
isOdd +3,
|
||||
signum +3,
|
||||
negate +3,
|
||||
mod +10 +3,
|
||||
pow +10 3,
|
||||
shiftLeft +7 2,
|
||||
shiftRight +7 2,
|
||||
truncate0 +3,
|
||||
withDefault (fromText "3x") -1,
|
||||
withDefault (fromText "+3") -1,
|
||||
toFloat +3)
|
13
unison-src/tests/methodical/int.ur
Normal file
13
unison-src/tests/methodical/int.ur
Normal file
@ -0,0 +1,13 @@
|
||||
(+4,
|
||||
false,
|
||||
true,
|
||||
+1,
|
||||
-3,
|
||||
+1,
|
||||
+1000,
|
||||
+28,
|
||||
+1,
|
||||
3,
|
||||
-1,
|
||||
+3,
|
||||
3.0)
|
20
unison-src/tests/methodical/nat.u
Normal file
20
unison-src/tests/methodical/nat.u
Normal file
@ -0,0 +1,20 @@
|
||||
use Nat drop fromText increment isEven isOdd mod pow shiftLeft shiftRight sub toFloat toInt toText
|
||||
|
||||
withDefault : Optional a -> a -> a
|
||||
withDefault opt d = match opt with
|
||||
Some x -> x
|
||||
None -> d
|
||||
|
||||
> (withDefault (fromText "3") 0,
|
||||
drop 3 2,
|
||||
increment 3,
|
||||
isEven 3,
|
||||
isOdd 3,
|
||||
mod 10 3,
|
||||
pow 10 3,
|
||||
shiftLeft 7 2,
|
||||
shiftRight 7 2,
|
||||
sub 3 2,
|
||||
toFloat 3,
|
||||
toInt 3,
|
||||
toText 3)
|
13
unison-src/tests/methodical/nat.ur
Normal file
13
unison-src/tests/methodical/nat.ur
Normal file
@ -0,0 +1,13 @@
|
||||
(3,
|
||||
1,
|
||||
4,
|
||||
false,
|
||||
true,
|
||||
1,
|
||||
1000,
|
||||
28,
|
||||
1,
|
||||
+1,
|
||||
3.0,
|
||||
+3,
|
||||
"3")
|
@ -94,80 +94,86 @@ Let's try it!
|
||||
74. Int.lteq : Int -> Int -> Boolean
|
||||
75. Int.mod : Int -> Int -> Int
|
||||
76. Int.negate : Int -> Int
|
||||
77. Int.signum : Int -> Int
|
||||
78. Int.toFloat : Int -> Float
|
||||
79. Int.toText : Int -> Text
|
||||
80. Int.truncate0 : Int -> Nat
|
||||
81. unique type Link
|
||||
82. builtin type Link.Term
|
||||
83. Link.Term : Term -> Link
|
||||
84. builtin type Link.Type
|
||||
85. Link.Type : Type -> Link
|
||||
86. builtin type List
|
||||
87. List.++ : [a] -> [a] -> [a]
|
||||
88. List.+: : a -> [a] -> [a]
|
||||
89. List.:+ : [a] -> a -> [a]
|
||||
90. List.at : Nat -> [a] -> Optional a
|
||||
91. List.cons : a -> [a] -> [a]
|
||||
92. List.drop : Nat -> [a] -> [a]
|
||||
93. List.empty : [a]
|
||||
94. List.size : [a] -> Nat
|
||||
95. List.snoc : [a] -> a -> [a]
|
||||
96. List.take : Nat -> [a] -> [a]
|
||||
97. builtin type Nat
|
||||
98. Nat.* : Nat -> Nat -> Nat
|
||||
99. Nat.+ : Nat -> Nat -> Nat
|
||||
100. Nat./ : Nat -> Nat -> Nat
|
||||
101. Nat.drop : Nat -> Nat -> Nat
|
||||
102. Nat.eq : Nat -> Nat -> Boolean
|
||||
103. Nat.fromText : Text -> Optional Nat
|
||||
104. Nat.gt : Nat -> Nat -> Boolean
|
||||
105. Nat.gteq : Nat -> Nat -> Boolean
|
||||
106. Nat.increment : Nat -> Nat
|
||||
107. Nat.isEven : Nat -> Boolean
|
||||
108. Nat.isOdd : Nat -> Boolean
|
||||
109. Nat.lt : Nat -> Nat -> Boolean
|
||||
110. Nat.lteq : Nat -> Nat -> Boolean
|
||||
111. Nat.mod : Nat -> Nat -> Nat
|
||||
112. Nat.sub : Nat -> Nat -> Int
|
||||
113. Nat.toFloat : Nat -> Float
|
||||
114. Nat.toInt : Nat -> Int
|
||||
115. Nat.toText : Nat -> Text
|
||||
116. type Optional a
|
||||
117. Optional.None : Optional a
|
||||
118. Optional.Some : a -> Optional a
|
||||
119. builtin type Request
|
||||
120. unique type Test.Result
|
||||
121. Test.Result.Fail : Text -> Result
|
||||
122. Test.Result.Ok : Text -> Result
|
||||
123. builtin type Text
|
||||
124. Text.!= : Text -> Text -> Boolean
|
||||
125. Text.++ : Text -> Text -> Text
|
||||
126. Text.drop : Nat -> Text -> Text
|
||||
127. Text.empty : Text
|
||||
128. Text.eq : Text -> Text -> Boolean
|
||||
129. Text.fromCharList : [Char] -> Text
|
||||
130. Text.gt : Text -> Text -> Boolean
|
||||
131. Text.gteq : Text -> Text -> Boolean
|
||||
132. Text.lt : Text -> Text -> Boolean
|
||||
133. Text.lteq : Text -> Text -> Boolean
|
||||
134. Text.size : Text -> Nat
|
||||
135. Text.take : Nat -> Text -> Text
|
||||
136. Text.toCharList : Text -> [Char]
|
||||
137. Text.uncons : Text -> Optional (Char, Text)
|
||||
138. Text.unsnoc : Text -> Optional (Text, Char)
|
||||
139. type Tuple a b
|
||||
140. Tuple.Cons : a -> b -> Tuple a b
|
||||
141. type Unit
|
||||
142. Unit.Unit : ()
|
||||
143. Universal.< : a -> a -> Boolean
|
||||
144. Universal.<= : a -> a -> Boolean
|
||||
145. Universal.== : a -> a -> Boolean
|
||||
146. Universal.> : a -> a -> Boolean
|
||||
147. Universal.>= : a -> a -> Boolean
|
||||
148. Universal.compare : a -> a -> Int
|
||||
149. bug : a -> b
|
||||
150. todo : a -> b
|
||||
77. Int.pow : Int -> Nat -> Int
|
||||
78. Int.shiftLeft : Int -> Nat -> Int
|
||||
79. Int.shiftRight : Int -> Nat -> Int
|
||||
80. Int.signum : Int -> Int
|
||||
81. Int.toFloat : Int -> Float
|
||||
82. Int.toText : Int -> Text
|
||||
83. Int.truncate0 : Int -> Nat
|
||||
84. unique type Link
|
||||
85. builtin type Link.Term
|
||||
86. Link.Term : Term -> Link
|
||||
87. builtin type Link.Type
|
||||
88. Link.Type : Type -> Link
|
||||
89. builtin type List
|
||||
90. List.++ : [a] -> [a] -> [a]
|
||||
91. List.+: : a -> [a] -> [a]
|
||||
92. List.:+ : [a] -> a -> [a]
|
||||
93. List.at : Nat -> [a] -> Optional a
|
||||
94. List.cons : a -> [a] -> [a]
|
||||
95. List.drop : Nat -> [a] -> [a]
|
||||
96. List.empty : [a]
|
||||
97. List.size : [a] -> Nat
|
||||
98. List.snoc : [a] -> a -> [a]
|
||||
99. List.take : Nat -> [a] -> [a]
|
||||
100. builtin type Nat
|
||||
101. Nat.* : Nat -> Nat -> Nat
|
||||
102. Nat.+ : Nat -> Nat -> Nat
|
||||
103. Nat./ : Nat -> Nat -> Nat
|
||||
104. Nat.drop : Nat -> Nat -> Nat
|
||||
105. Nat.eq : Nat -> Nat -> Boolean
|
||||
106. Nat.fromText : Text -> Optional Nat
|
||||
107. Nat.gt : Nat -> Nat -> Boolean
|
||||
108. Nat.gteq : Nat -> Nat -> Boolean
|
||||
109. Nat.increment : Nat -> Nat
|
||||
110. Nat.isEven : Nat -> Boolean
|
||||
111. Nat.isOdd : Nat -> Boolean
|
||||
112. Nat.lt : Nat -> Nat -> Boolean
|
||||
113. Nat.lteq : Nat -> Nat -> Boolean
|
||||
114. Nat.mod : Nat -> Nat -> Nat
|
||||
115. Nat.pow : Nat -> Nat -> Nat
|
||||
116. Nat.shiftLeft : Nat -> Nat -> Nat
|
||||
117. Nat.shiftRight : Nat -> Nat -> Nat
|
||||
118. Nat.sub : Nat -> Nat -> Int
|
||||
119. Nat.toFloat : Nat -> Float
|
||||
120. Nat.toInt : Nat -> Int
|
||||
121. Nat.toText : Nat -> Text
|
||||
122. type Optional a
|
||||
123. Optional.None : Optional a
|
||||
124. Optional.Some : a -> Optional a
|
||||
125. builtin type Request
|
||||
126. unique type Test.Result
|
||||
127. Test.Result.Fail : Text -> Result
|
||||
128. Test.Result.Ok : Text -> Result
|
||||
129. builtin type Text
|
||||
130. Text.!= : Text -> Text -> Boolean
|
||||
131. Text.++ : Text -> Text -> Text
|
||||
132. Text.drop : Nat -> Text -> Text
|
||||
133. Text.empty : Text
|
||||
134. Text.eq : Text -> Text -> Boolean
|
||||
135. Text.fromCharList : [Char] -> Text
|
||||
136. Text.gt : Text -> Text -> Boolean
|
||||
137. Text.gteq : Text -> Text -> Boolean
|
||||
138. Text.lt : Text -> Text -> Boolean
|
||||
139. Text.lteq : Text -> Text -> Boolean
|
||||
140. Text.size : Text -> Nat
|
||||
141. Text.take : Nat -> Text -> Text
|
||||
142. Text.toCharList : Text -> [Char]
|
||||
143. Text.uncons : Text -> Optional (Char, Text)
|
||||
144. Text.unsnoc : Text -> Optional (Text, Char)
|
||||
145. type Tuple a b
|
||||
146. Tuple.Cons : a -> b -> Tuple a b
|
||||
147. type Unit
|
||||
148. Unit.Unit : ()
|
||||
149. Universal.< : a -> a -> Boolean
|
||||
150. Universal.<= : a -> a -> Boolean
|
||||
151. Universal.== : a -> a -> Boolean
|
||||
152. Universal.> : a -> a -> Boolean
|
||||
153. Universal.>= : a -> a -> Boolean
|
||||
154. Universal.compare : a -> a -> Int
|
||||
155. bug : a -> b
|
||||
156. todo : a -> b
|
||||
|
||||
|
||||
.builtin> alias.many 94-104 .mylib
|
||||
@ -177,16 +183,16 @@ Let's try it!
|
||||
Added definitions:
|
||||
|
||||
1. builtin type Nat
|
||||
2. List.size : [a] -> Nat
|
||||
3. List.snoc : [a] -> a -> [a]
|
||||
4. List.take : Nat -> [a] -> [a]
|
||||
5. Nat.* : Nat -> Nat -> Nat
|
||||
6. Nat.+ : Nat -> Nat -> Nat
|
||||
7. Nat./ : Nat -> Nat -> Nat
|
||||
8. Nat.drop : Nat -> Nat -> Nat
|
||||
9. Nat.eq : Nat -> Nat -> Boolean
|
||||
10. Nat.fromText : Text -> Optional Nat
|
||||
11. Nat.gt : Nat -> Nat -> Boolean
|
||||
2. List.cons : a -> [a] -> [a]
|
||||
3. List.drop : Nat -> [a] -> [a]
|
||||
4. List.empty : [a]
|
||||
5. List.size : [a] -> Nat
|
||||
6. List.snoc : [a] -> a -> [a]
|
||||
7. List.take : Nat -> [a] -> [a]
|
||||
8. Nat.* : Nat -> Nat -> Nat
|
||||
9. Nat.+ : Nat -> Nat -> Nat
|
||||
10. Nat./ : Nat -> Nat -> Nat
|
||||
11. Nat.drop : Nat -> Nat -> Nat
|
||||
|
||||
Tip: You can use `undo` or `reflog` to undo this change.
|
||||
|
||||
@ -253,27 +259,27 @@ I want to incorporate a few more from another namespace:
|
||||
3. List.any : (a ->{𝕖} Boolean) ->{𝕖} [a] ->{𝕖} Boolean
|
||||
4. List.chunk : Nat -> [a] -> [[a]]
|
||||
5. List.chunksOf : Nat -> [a] -> [[a]]
|
||||
6. List.dropWhile : (a ->{𝕖} Boolean) ->{𝕖} [a] ->{𝕖} [a]
|
||||
7. List.first : [a] -> Optional a
|
||||
8. List.init : [a] -> Optional [a]
|
||||
9. List.intersperse : a -> [a] -> [a]
|
||||
10. List.isEmpty : [a] -> Boolean
|
||||
11. List.last : [a] -> Optional a
|
||||
12. List.replicate : Nat -> a -> [a]
|
||||
13. List.size : [a] -> Nat
|
||||
14. List.snoc : [a] -> a -> [a]
|
||||
15. List.splitAt : Nat -> [a] -> ([a], [a])
|
||||
16. List.tail : [a] -> Optional [a]
|
||||
17. List.take : Nat -> [a] -> [a]
|
||||
18. List.takeWhile : (a ->{𝕖} Boolean) -> [a] ->{𝕖} [a]
|
||||
19. builtin type Nat
|
||||
20. Nat.* : Nat -> Nat -> Nat
|
||||
21. Nat.+ : Nat -> Nat -> Nat
|
||||
22. Nat./ : Nat -> Nat -> Nat
|
||||
23. Nat.drop : Nat -> Nat -> Nat
|
||||
24. Nat.eq : Nat -> Nat -> Boolean
|
||||
25. Nat.fromText : Text -> Optional Nat
|
||||
26. Nat.gt : Nat -> Nat -> Boolean
|
||||
6. List.cons : a -> [a] -> [a]
|
||||
7. List.drop : Nat -> [a] -> [a]
|
||||
8. List.dropWhile : (a ->{𝕖} Boolean) ->{𝕖} [a] ->{𝕖} [a]
|
||||
9. List.empty : [a]
|
||||
10. List.first : [a] -> Optional a
|
||||
11. List.init : [a] -> Optional [a]
|
||||
12. List.intersperse : a -> [a] -> [a]
|
||||
13. List.isEmpty : [a] -> Boolean
|
||||
14. List.last : [a] -> Optional a
|
||||
15. List.replicate : Nat -> a -> [a]
|
||||
16. List.size : [a] -> Nat
|
||||
17. List.snoc : [a] -> a -> [a]
|
||||
18. List.splitAt : Nat -> [a] -> ([a], [a])
|
||||
19. List.tail : [a] -> Optional [a]
|
||||
20. List.take : Nat -> [a] -> [a]
|
||||
21. List.takeWhile : (a ->{𝕖} Boolean) -> [a] ->{𝕖} [a]
|
||||
22. builtin type Nat
|
||||
23. Nat.* : Nat -> Nat -> Nat
|
||||
24. Nat.+ : Nat -> Nat -> Nat
|
||||
25. Nat./ : Nat -> Nat -> Nat
|
||||
26. Nat.drop : Nat -> Nat -> Nat
|
||||
|
||||
|
||||
```
|
||||
|
@ -21,13 +21,13 @@ The `builtins.merge` command adds the known builtins to a `builtin` subnamespace
|
||||
10. Float (builtin type)
|
||||
11. Float/ (36 definitions)
|
||||
12. Int (builtin type)
|
||||
13. Int/ (19 definitions)
|
||||
13. Int/ (22 definitions)
|
||||
14. Link (type)
|
||||
15. Link/ (4 definitions)
|
||||
16. List (builtin type)
|
||||
17. List/ (10 definitions)
|
||||
18. Nat (builtin type)
|
||||
19. Nat/ (18 definitions)
|
||||
19. Nat/ (21 definitions)
|
||||
20. Optional (type)
|
||||
21. Optional/ (2 definitions)
|
||||
22. Request (builtin type)
|
||||
|
@ -23,7 +23,7 @@ Technically, the definitions all exist, but they have no names. `builtins.merge`
|
||||
|
||||
.foo> ls
|
||||
|
||||
1. builtin/ (150 definitions)
|
||||
1. builtin/ (156 definitions)
|
||||
|
||||
```
|
||||
And for a limited time, you can get even more builtin goodies:
|
||||
@ -35,7 +35,7 @@ And for a limited time, you can get even more builtin goodies:
|
||||
|
||||
.foo> ls
|
||||
|
||||
1. builtin/ (316 definitions)
|
||||
1. builtin/ (322 definitions)
|
||||
|
||||
```
|
||||
More typically, you'd start out by pulling `base.
|
||||
|
@ -112,13 +112,13 @@ We can also delete the fork if we're done with it. (Don't worry, it's still in t
|
||||
Note: The most recent namespace hash is immediately below this
|
||||
message.
|
||||
|
||||
⊙ #tklmrocnqt
|
||||
⊙ #1knda118ml
|
||||
|
||||
- Deletes:
|
||||
|
||||
feature1.y
|
||||
|
||||
⊙ #1rn4ods0ce
|
||||
⊙ #dufp8qeq3n
|
||||
|
||||
+ Adds / updates:
|
||||
|
||||
@ -129,26 +129,26 @@ We can also delete the fork if we're done with it. (Don't worry, it's still in t
|
||||
Original name New name(s)
|
||||
feature1.y master.y
|
||||
|
||||
⊙ #vj242er6kb
|
||||
⊙ #v94vprvf7f
|
||||
|
||||
+ Adds / updates:
|
||||
|
||||
feature1.y
|
||||
|
||||
⊙ #43nhdcu440
|
||||
⊙ #f166mvv1hb
|
||||
|
||||
> Moves:
|
||||
|
||||
Original name New name
|
||||
x master.x
|
||||
|
||||
⊙ #5khd8vn0j3
|
||||
⊙ #971j7jvcsa
|
||||
|
||||
+ Adds / updates:
|
||||
|
||||
x
|
||||
|
||||
⊙ #h8t86n0gqk
|
||||
⊙ #rdkmqee7e3
|
||||
|
||||
+ Adds / updates:
|
||||
|
||||
@ -178,8 +178,10 @@ We can also delete the fork if we're done with it. (Don't worry, it's still in t
|
||||
builtin.Int.fromText builtin.Int.gt builtin.Int.gteq
|
||||
builtin.Int.increment builtin.Int.isEven builtin.Int.isOdd
|
||||
builtin.Int.lt builtin.Int.lteq builtin.Int.mod
|
||||
builtin.Int.negate builtin.Int.signum builtin.Int.toFloat
|
||||
builtin.Int.toText builtin.Int.truncate0 builtin.Link
|
||||
builtin.Int.negate builtin.Int.pow builtin.Int.shiftLeft
|
||||
builtin.Int.shiftRight builtin.Int.signum
|
||||
builtin.Int.toFloat builtin.Int.toText
|
||||
builtin.Int.truncate0 builtin.Link
|
||||
builtin.Link.Term##Link.Term builtin.Link.Term#quh#0
|
||||
builtin.Link.Type##Link.Type builtin.Link.Type#quh#1
|
||||
builtin.List builtin.List.++ builtin.List.+:
|
||||
@ -190,7 +192,8 @@ We can also delete the fork if we're done with it. (Don't worry, it's still in t
|
||||
builtin.Nat.eq builtin.Nat.fromText builtin.Nat.gt
|
||||
builtin.Nat.gteq builtin.Nat.increment builtin.Nat.isEven
|
||||
builtin.Nat.isOdd builtin.Nat.lt builtin.Nat.lteq
|
||||
builtin.Nat.mod builtin.Nat.sub builtin.Nat.toFloat
|
||||
builtin.Nat.mod builtin.Nat.pow builtin.Nat.shiftLeft
|
||||
builtin.Nat.shiftRight builtin.Nat.sub builtin.Nat.toFloat
|
||||
builtin.Nat.toInt builtin.Nat.toText builtin.Optional
|
||||
builtin.Optional.None builtin.Optional.Some
|
||||
builtin.Request builtin.Test.Result
|
||||
|
@ -59,16 +59,16 @@ y = 2
|
||||
most recent, along with the command that got us there. Try:
|
||||
|
||||
`fork 2 .old`
|
||||
`fork #equ6ou4ulg .old` to make an old namespace
|
||||
`fork #dajtoef205 .old` to make an old namespace
|
||||
accessible again,
|
||||
|
||||
`reset-root #equ6ou4ulg` to reset the root namespace and
|
||||
`reset-root #dajtoef205` to reset the root namespace and
|
||||
its history to that of the
|
||||
specified namespace.
|
||||
|
||||
1. #1tmi5vg64m : add
|
||||
2. #equ6ou4ulg : add
|
||||
3. #h8t86n0gqk : builtins.merge
|
||||
1. #kac7fmh0ja : add
|
||||
2. #dajtoef205 : add
|
||||
3. #rdkmqee7e3 : builtins.merge
|
||||
4. #7asfbtqmoj : (initial reflogged namespace)
|
||||
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user