Skip to content

Commit 348a087

Browse files
authored
Merge pull request #5647 from unisonweb/revert-5639-cp/runtime-function-replacements
Revert "More runtime function replacements for Map, Set, Multimap"
2 parents ce019ea + 85df4de commit 348a087

File tree

3 files changed

+2
-67
lines changed

3 files changed

+2
-67
lines changed

unison-runtime/src/Unison/Runtime/Builtin.hs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,16 +1282,8 @@ declareForeigns = do
12821282
declareForeign Untracked 2 Map_lookup
12831283
declareForeign Untracked 1 Map_fromList
12841284
declareForeign Untracked 2 Map_eq
1285-
declareForeign Untracked 2 Map_union
1286-
declareForeign Untracked 2 Map_intersect
1287-
declareForeign Untracked 1 Map_toList
12881285
declareForeign Untracked 2 List_range
12891286
declareForeign Untracked 1 List_sort
1290-
declareForeign Untracked 1 Multimap_fromList
1291-
declareForeign Untracked 1 Set_fromList
1292-
declareForeign Untracked 2 Set_union
1293-
declareForeign Untracked 2 Set_intersect
1294-
declareForeign Untracked 1 Set_toList
12951287

12961288
foreignDeclResults :: (Map ForeignFunc (Sandbox, SuperNormal Symbol))
12971289
foreignDeclResults =

unison-runtime/src/Unison/Runtime/Foreign/Function.hs

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -878,32 +878,15 @@ foreignCallHelper = \case
878878
evaluate $ Map.fromList l
879879
Map_eq -> mkForeign $ \(l :: Map Val Val, r :: Map Val Val) ->
880880
pure $ l == r
881-
Map_union -> mkForeign $ \(l :: Map Val Val, r :: Map Val Val) ->
882-
evaluate $ Map.union l r
883-
Map_intersect -> mkForeign $ \(l :: Map Val Val, r :: Map Val Val) ->
884-
evaluate $ Map.intersection l r
885-
Map_toList -> mkForeign $ \(m :: Map Val Val) ->
886-
evaluate . forceListSpine $ Map.toList m
887881
List_range -> mkForeign $ \(m :: Word64, n :: Word64) ->
888882
let sz
889883
| m < n = fromIntegral $ n - m
890884
| otherwise = 0
891885
mk i = NatVal $ m + fromIntegral i
892-
in evaluate . forceListSpine $ Sq.fromFunction sz mk
886+
force s = foldl (\u x -> x `seq` u) s s
887+
in evaluate . force $ Sq.fromFunction sz mk
893888
List_sort -> mkForeign $ \(l :: Seq Val) -> pure $ Sq.unstableSort l
894-
Multimap_fromList -> mkForeign $ \(l :: [(Val, Val)]) -> do
895-
let listVals = l <&> \(k, v) -> (k, Sq.singleton v)
896-
evaluate $ Map.fromListWith (<>) listVals
897-
Set_fromList -> mkForeign $ \(l :: [Val]) -> do
898-
evaluate $ Map.fromList $ zip l (repeat ())
899-
Set_union -> mkForeign $ \(l :: Map Val (), r :: Map Val ()) ->
900-
evaluate $ Map.union l r
901-
Set_intersect -> mkForeign $ \(l :: Map Val (), r :: Map Val ()) ->
902-
evaluate $ Map.intersection l r
903-
Set_toList -> mkForeign $ \(s :: Map Val ()) ->
904-
evaluate . forceListSpine $ Map.keys s
905889
where
906-
forceListSpine xs = foldl (\u x -> x `seq` u) xs xs
907890
chop = reverse . dropWhile isPathSeparator . reverse
908891

909892
hostPreference :: Maybe Util.Text.Text -> SYS.HostPreference
@@ -2100,30 +2083,6 @@ functionReplacementList =
21002083
( "005mc1fq7ojq72c238qlm2rspjgqo2furjodf28icruv316odu6du",
21012084
Map_fromList
21022085
),
2103-
( "01qqpul0ttlgjhr5i2gtmdr2uarns2hbtnjpipmk1575ipkrlug42",
2104-
Map_union
2105-
),
2106-
( "00c363e340il8q0fai6peiv3586o931nojj98qfek09hg1tjkm9ma",
2107-
Map_intersect
2108-
),
2109-
( "03pjq0jijrr7ebf6s3tuqi4d5hi5mrv19nagp7ql2j9ltm55c32ek",
2110-
Map_toList
2111-
),
2112-
( "03putoun7i5n0lhf8iu990u9p08laklnp668i170dka2itckmadlq",
2113-
Multimap_fromList
2114-
),
2115-
( "03q6giac0qlva6u4mja29tr7mv0jqnsugk8paibatdrns8lhqqb92",
2116-
Set_fromList
2117-
),
2118-
( "03362vaalqq28lcrmmsjhha637is312j01jme3juj980ugd93up28",
2119-
Set_union
2120-
),
2121-
( "01lm6ejo31na1ti6u85bv0klliefll7q0c0da2qnefvcrq1l8rlqe",
2122-
Set_intersect
2123-
),
2124-
( "01p7ot36tg62na408mnk1psve6rc7fog30gv6n7thkrv6t3na2gdm",
2125-
Set_toList
2126-
),
21272086
( "03c559iihi2vj0qps6cln48nv31ajup2srhas4pd05b9k46ds8jvk",
21282087
Map_eq
21292088
),

unison-runtime/src/Unison/Runtime/Foreign/Function/Type.hs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -260,16 +260,8 @@ data ForeignFunc
260260
| Map_lookup
261261
| Map_fromList
262262
| Map_eq
263-
| Map_union
264-
| Map_intersect
265-
| Map_toList
266263
| List_range
267264
| List_sort
268-
| Multimap_fromList
269-
| Set_fromList
270-
| Set_union
271-
| Set_intersect
272-
| Set_toList
273265
deriving (Show, Eq, Ord, Enum, Bounded)
274266

275267
foreignFuncBuiltinName :: ForeignFunc -> Text
@@ -526,13 +518,5 @@ foreignFuncBuiltinName = \case
526518
Map_lookup -> "Map.lookup"
527519
Map_fromList -> "Map.fromList"
528520
Map_eq -> "Map.=="
529-
Map_union -> "Map.union"
530-
Map_intersect -> "Map.intersect"
531-
Map_toList -> "Map.toList"
532521
List_range -> "List.range"
533522
List_sort -> "List.sort"
534-
Multimap_fromList -> "Multimap.fromList"
535-
Set_fromList -> "Set.fromList"
536-
Set_union -> "Set.union"
537-
Set_intersect -> "Set.intersect"
538-
Set_toList -> "Set.toList"

0 commit comments

Comments
 (0)