renamed some builtins, ran harder program; problem with local data decls

This commit is contained in:
Arya Irani 2018-06-05 18:02:04 -04:00
parent 41ba5c10c5
commit 64ddd5d02d
3 changed files with 20 additions and 8 deletions

View File

@ -59,8 +59,8 @@ builtins = Map.fromList $
, ("Int64.>=", "Int64 -> Int64 -> Boolean")
, ("Int64.==", "Int64 -> Int64 -> Boolean")
, ("Int64.increment", "Int64 -> Int64")
, ("Int64.isEven", "Int64 -> Boolean")
, ("Int64.isOdd", "Int64 -> Boolean")
, ("Int64.is-even", "Int64 -> Boolean")
, ("Int64.is-odd", "Int64 -> Boolean")
, ("Int64.signum", "Int64 -> Int64")
, ("Int64.negate", "Int64 -> Int64")
@ -75,8 +75,8 @@ builtins = Map.fromList $
, ("UInt64.>=", "UInt64 -> UInt64 -> Boolean")
, ("UInt64.==", "UInt64 -> UInt64 -> Boolean")
, ("UInt64.increment", "UInt64 -> UInt64")
, ("UInt64.isEven", "UInt64 -> Boolean")
, ("UInt64.isOdd", "UInt64 -> Boolean")
, ("UInt64.is-even", "UInt64 -> Boolean")
, ("UInt64.is-odd", "UInt64 -> Boolean")
, ("Float.+", "Float -> Float -> Float")
, ("Float.-", "Float -> Float -> Float")
@ -103,11 +103,12 @@ builtins = Map.fromList $
, ("Text.>", "Text -> Text -> Boolean")
, ("Stream.empty", "forall a . Stream a")
, ("Stream.from-int64", "Int64 -> Stream Int64")
, ("Stream.cons", "forall a . a -> Stream a -> Stream a")
, ("Stream.take", "forall a . UInt64 -> Stream a -> Stream a")
, ("Stream.drop", "forall a . UInt64 -> Stream a -> Stream a")
, ("Stream.map", "forall a b . (a -> b) -> Stream a -> Stream b")
, ("Stream.foldLeft", "forall a b . b -> (b -> a -> b) -> Stream a -> b")
, ("Stream.fold-left", "forall a b . b -> (b -> a -> b) -> Stream a -> b")
, ("Sequence.empty", "forall a . Sequence a")
, ("Sequence.cons", "forall a . a -> Sequence a -> Sequence a")

View File

@ -22,7 +22,7 @@ object Builtins {
// Stream.fromInt : Integer -> Stream Integer
val Stream_fromInt = // Stream.iterate(unison 0)(Integer_inc)
fp_z("Stream.fromInt", "n", Stream.fromUnison)
fp_z("Stream.from-int64", "n", Stream.fromUnison)
// Stream.cons : a -> Stream a -> Stream a
val Stream_cons =
@ -45,7 +45,7 @@ object Builtins {
// Stream.foldLeft : b -> (b -> a -> b) -> Stream a -> b
val Stream_foldLeft =
fppp_p("Stream.foldLeft", "acc", "f", "stream",
fppp_p("Stream.fold-left", "acc", "f", "stream",
(acc: Value, f: Value, s: Stream[Value]) =>
s.foldLeft(acc)(
UnisonToScala.toUnboxed2(f.asInstanceOf[Lambda])(env))

View File

@ -8,4 +8,15 @@ Optional.isEmpty o = case o of
increment x = x +_UInt64 1
increment 3
(|>) : forall a . a -> (a -> b) -> b
a |> f = f a
{-
Stream.from-int64 -3
|> Stream.take 10
|> Stream.fold-left 0 (+_Int64)
|> Optional.Some
|> Optional.isEmpty
-}
Optional.Some 1