mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 14:54:47 +00:00
Merge branch 'trunk' into more-tea
This commit is contained in:
commit
3d9b82e35e
18 changed files with 188 additions and 184 deletions
|
@ -1,7 +1,7 @@
|
|||
interface Defaults
|
||||
exposes []
|
||||
imports [
|
||||
Map.{ Map },
|
||||
Dict.{ Dict },
|
||||
Set.{ Set },
|
||||
Num.{ Num, Int, Float }
|
||||
]
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
interface Map2
|
||||
interface Dict2
|
||||
exposes [ isEmpty, map ]
|
||||
imports []
|
||||
|
||||
isEmpty : Map * * -> Bool
|
||||
isEmpty : Dict * * -> Bool
|
||||
|
||||
## Convert each key and value in the #Map to something new, by calling a conversion
|
||||
## Convert each key and value in the #Dict to something new, by calling a conversion
|
||||
## function on each of them. Then return a new #Map of the converted keys and values.
|
||||
##
|
||||
## >>> Map.map {{ 3.14 => "pi", 1.0 => "one" }} \{ key, value } -> { key:
|
||||
## >>> Dict.map {{ 3.14 => "pi", 1.0 => "one" }} \{ key, value } -> { key:
|
||||
##
|
||||
## >>> Map.map {[ "", "a", "bc" ]} Str.isEmpty
|
||||
## >>> Dict.map {[ "", "a", "bc" ]} Str.isEmpty
|
||||
##
|
||||
## `map` functions like this are common in Roc, and they all work similarly.
|
||||
## See for example #Result.map, #List.map, and #Set.map.
|
|
@ -3,7 +3,7 @@ use roc_module::ident::TagName;
|
|||
use roc_module::symbol::Symbol;
|
||||
use roc_region::all::Region;
|
||||
use roc_types::builtin_aliases::{
|
||||
bool_type, float_type, int_type, list_type, map_type, num_type, ordering_type, result_type,
|
||||
bool_type, dict_type, float_type, int_type, list_type, num_type, ordering_type, result_type,
|
||||
set_type, str_type,
|
||||
};
|
||||
use roc_types::solved_types::SolvedType;
|
||||
|
@ -30,7 +30,7 @@ pub fn standard_stdlib() -> StdLib {
|
|||
applies: vec![
|
||||
Symbol::LIST_LIST,
|
||||
Symbol::SET_SET,
|
||||
Symbol::MAP_MAP,
|
||||
Symbol::DICT_DICT,
|
||||
Symbol::STR_STR,
|
||||
]
|
||||
.into_iter()
|
||||
|
@ -614,39 +614,43 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
|||
top_level_function(vec![list_type(flex(TVAR1))], Box::new(bool_type())),
|
||||
);
|
||||
|
||||
// Map module
|
||||
// Dict module
|
||||
|
||||
// empty : Map k v
|
||||
add_type(Symbol::MAP_EMPTY, map_type(flex(TVAR1), flex(TVAR2)));
|
||||
// empty : Dict k v
|
||||
add_type(Symbol::DICT_EMPTY, dict_type(flex(TVAR1), flex(TVAR2)));
|
||||
|
||||
// singleton : k, v -> Map k v
|
||||
// singleton : k, v -> Dict k v
|
||||
add_type(
|
||||
Symbol::MAP_SINGLETON,
|
||||
Symbol::DICT_SINGLETON,
|
||||
top_level_function(
|
||||
vec![flex(TVAR1), flex(TVAR2)],
|
||||
Box::new(map_type(flex(TVAR1), flex(TVAR2))),
|
||||
Box::new(dict_type(flex(TVAR1), flex(TVAR2))),
|
||||
),
|
||||
);
|
||||
|
||||
// get : Map k v, k -> Result v [ KeyNotFound ]*
|
||||
// get : Dict k v, k -> Result v [ KeyNotFound ]*
|
||||
let key_not_found = SolvedType::TagUnion(
|
||||
vec![(TagName::Global("KeyNotFound".into()), vec![])],
|
||||
Box::new(SolvedType::Wildcard),
|
||||
);
|
||||
|
||||
add_type(
|
||||
Symbol::MAP_GET,
|
||||
Symbol::DICT_GET,
|
||||
top_level_function(
|
||||
vec![map_type(flex(TVAR1), flex(TVAR2)), flex(TVAR1)],
|
||||
vec![dict_type(flex(TVAR1), flex(TVAR2)), flex(TVAR1)],
|
||||
Box::new(result_type(flex(TVAR2), key_not_found)),
|
||||
),
|
||||
);
|
||||
|
||||
add_type(
|
||||
Symbol::MAP_INSERT,
|
||||
Symbol::DICT_INSERT,
|
||||
top_level_function(
|
||||
vec![map_type(flex(TVAR1), flex(TVAR2)), flex(TVAR1), flex(TVAR2)],
|
||||
Box::new(map_type(flex(TVAR1), flex(TVAR2))),
|
||||
vec![
|
||||
dict_type(flex(TVAR1), flex(TVAR2)),
|
||||
flex(TVAR1),
|
||||
flex(TVAR2),
|
||||
],
|
||||
Box::new(dict_type(flex(TVAR1), flex(TVAR2))),
|
||||
),
|
||||
);
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ pub fn uniq_stdlib() -> StdLib {
|
|||
Symbol::ATTR_ATTR,
|
||||
Symbol::LIST_LIST,
|
||||
Symbol::SET_SET,
|
||||
Symbol::MAP_MAP,
|
||||
Symbol::DICT_DICT,
|
||||
Symbol::STR_STR,
|
||||
]
|
||||
.into_iter()
|
||||
|
@ -831,18 +831,18 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
|||
)
|
||||
});
|
||||
|
||||
// Map module
|
||||
// Dict module
|
||||
|
||||
// empty : Attr * (Map k v)
|
||||
add_type(Symbol::MAP_EMPTY, {
|
||||
// empty : Attr * (Dict k v)
|
||||
add_type(Symbol::DICT_EMPTY, {
|
||||
let_tvars! { star, k , v };
|
||||
map_type(star, k, v)
|
||||
dict_type(star, k, v)
|
||||
});
|
||||
|
||||
// singleton : k, v -> Attr * (Map k v)
|
||||
add_type(Symbol::MAP_SINGLETON, {
|
||||
// singleton : k, v -> Attr * (Dict k v)
|
||||
add_type(Symbol::DICT_SINGLETON, {
|
||||
let_tvars! { star, k , v };
|
||||
unique_function(vec![flex(k), flex(v)], map_type(star, k, v))
|
||||
unique_function(vec![flex(k), flex(v)], dict_type(star, k, v))
|
||||
});
|
||||
|
||||
let key_not_found = SolvedType::Apply(
|
||||
|
@ -856,10 +856,10 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
|||
],
|
||||
);
|
||||
|
||||
// get : Attr (* | u) (Map (Attr * key) (Attr u val))
|
||||
// get : Attr (* | u) (Dict (Attr * key) (Attr u val))
|
||||
// , Attr * key
|
||||
// -> Attr * (Result (Attr u val) [ KeyNotFound ]*)
|
||||
add_type(Symbol::MAP_GET, {
|
||||
add_type(Symbol::DICT_GET, {
|
||||
let_tvars! { u, key, val, star1, star2, star3, star4 };
|
||||
|
||||
unique_function(
|
||||
|
@ -869,7 +869,7 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
|||
vec![
|
||||
container(star1, vec![u]),
|
||||
SolvedType::Apply(
|
||||
Symbol::MAP_MAP,
|
||||
Symbol::DICT_DICT,
|
||||
vec![attr_type(star2, key), attr_type(u, val)],
|
||||
),
|
||||
],
|
||||
|
@ -889,11 +889,11 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
|||
)
|
||||
});
|
||||
|
||||
// insert : Attr * (Map key value)
|
||||
// insert : Attr * (Dict key value)
|
||||
// , key
|
||||
// , value
|
||||
// , Attr * (Map key value)
|
||||
add_type(Symbol::MAP_INSERT, {
|
||||
// , Attr * (Dict key value)
|
||||
add_type(Symbol::DICT_INSERT, {
|
||||
let_tvars! { star1, star2, key, value };
|
||||
|
||||
unique_function(
|
||||
|
@ -902,7 +902,7 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
|||
Symbol::ATTR_ATTR,
|
||||
vec![
|
||||
flex(star1),
|
||||
SolvedType::Apply(Symbol::MAP_MAP, vec![flex(key), flex(value)]),
|
||||
SolvedType::Apply(Symbol::DICT_DICT, vec![flex(key), flex(value)]),
|
||||
],
|
||||
),
|
||||
flex(key),
|
||||
|
@ -912,7 +912,7 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
|||
Symbol::ATTR_ATTR,
|
||||
vec![
|
||||
flex(star2),
|
||||
SolvedType::Apply(Symbol::MAP_MAP, vec![flex(key), flex(value)]),
|
||||
SolvedType::Apply(Symbol::DICT_DICT, vec![flex(key), flex(value)]),
|
||||
],
|
||||
),
|
||||
)
|
||||
|
@ -1267,12 +1267,12 @@ fn set_type(u: VarId, a: VarId) -> SolvedType {
|
|||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn map_type(u: VarId, key: VarId, value: VarId) -> SolvedType {
|
||||
fn dict_type(u: VarId, key: VarId, value: VarId) -> SolvedType {
|
||||
SolvedType::Apply(
|
||||
Symbol::ATTR_ATTR,
|
||||
vec![
|
||||
flex(u),
|
||||
SolvedType::Apply(Symbol::MAP_MAP, vec![flex(key), flex(value)]),
|
||||
SolvedType::Apply(Symbol::DICT_DICT, vec![flex(key), flex(value)]),
|
||||
],
|
||||
)
|
||||
}
|
||||
|
|
|
@ -158,7 +158,7 @@ pub fn basic_type_from_layout<'ctx>(
|
|||
Float64 => context.f64_type().as_basic_type_enum(),
|
||||
Float32 => context.f32_type().as_basic_type_enum(),
|
||||
Float16 => context.f16_type().as_basic_type_enum(),
|
||||
Map(_, _) | EmptyMap => panic!("TODO layout_to_basic_type for Builtin::Map"),
|
||||
Dict(_, _) | EmptyDict => panic!("TODO layout_to_basic_type for Builtin::Dict"),
|
||||
Set(_) | EmptySet => panic!("TODO layout_to_basic_type for Builtin::Set"),
|
||||
List(_, _) | Str | EmptyStr => collection(context, ptr_bytes).into(),
|
||||
EmptyList => BasicTypeEnum::StructType(collection(context, ptr_bytes)),
|
||||
|
|
|
@ -397,7 +397,7 @@ fn decrement_refcount_builtin<'a, 'ctx, 'env>(
|
|||
}
|
||||
todo!();
|
||||
}
|
||||
Map(key_layout, value_layout) => {
|
||||
Dict(key_layout, value_layout) => {
|
||||
if key_layout.contains_refcounted() || value_layout.contains_refcounted() {
|
||||
// TODO decrement all values
|
||||
}
|
||||
|
@ -498,7 +498,7 @@ fn increment_refcount_builtin<'a, 'ctx, 'env>(
|
|||
}
|
||||
todo!();
|
||||
}
|
||||
Map(key_layout, value_layout) => {
|
||||
Dict(key_layout, value_layout) => {
|
||||
if key_layout.contains_refcounted() || value_layout.contains_refcounted() {
|
||||
// TODO decrement all values
|
||||
}
|
||||
|
|
|
@ -1206,11 +1206,11 @@ mod gen_primitives {
|
|||
|
||||
NodeColor : [ Red, Black ]
|
||||
|
||||
Dict k v : [ Node NodeColor k v (Dict k v) (Dict k v), Empty ]
|
||||
RedBlackTree k v : [ Node NodeColor k v (RedBlackTree k v) (RedBlackTree k v), Empty ]
|
||||
|
||||
Key k : Num k
|
||||
|
||||
insert : Key k, v, Dict (Key k) v -> Dict (Key k) v
|
||||
insert : Key k, v, RedBlackTree (Key k) v -> RedBlackTree (Key k) v
|
||||
insert = \key, value, dict ->
|
||||
when insertHelp key value dict is
|
||||
Node Red k v l r ->
|
||||
|
@ -1219,7 +1219,7 @@ mod gen_primitives {
|
|||
x ->
|
||||
x
|
||||
|
||||
insertHelp : (Key k), v, Dict (Key k) v -> Dict (Key k) v
|
||||
insertHelp : (Key k), v, RedBlackTree (Key k) v -> RedBlackTree (Key k) v
|
||||
insertHelp = \key, value, dict ->
|
||||
when dict is
|
||||
Empty ->
|
||||
|
@ -1238,7 +1238,7 @@ mod gen_primitives {
|
|||
GT ->
|
||||
balance nColor nKey nValue nLeft (insertHelp key value nRight)
|
||||
|
||||
balance : NodeColor, k, v, Dict k v, Dict k v -> Dict k v
|
||||
balance : NodeColor, k, v, RedBlackTree k v, RedBlackTree k v -> RedBlackTree k v
|
||||
balance = \color, key, value, left, right ->
|
||||
when right is
|
||||
Node Red rK rV rLeft rRight ->
|
||||
|
@ -1267,7 +1267,7 @@ mod gen_primitives {
|
|||
_ ->
|
||||
Node color key value left right
|
||||
|
||||
main : Dict I64 {}
|
||||
main : RedBlackTree I64 {}
|
||||
main =
|
||||
insert 0 {} Empty
|
||||
"#
|
||||
|
@ -1288,9 +1288,9 @@ mod gen_primitives {
|
|||
|
||||
NodeColor : [ Red, Black ]
|
||||
|
||||
Dict k : [ Node NodeColor k (Dict k) (Dict k), Empty ]
|
||||
RedBlackTree k : [ Node NodeColor k (RedBlackTree k) (RedBlackTree k), Empty ]
|
||||
|
||||
# balance : NodeColor, k, Dict k, Dict k -> Dict k
|
||||
# balance : NodeColor, k, RedBlackTree k, RedBlackTree k -> RedBlackTree k
|
||||
balance = \color, key, left, right ->
|
||||
when right is
|
||||
Node Red rK rLeft rRight ->
|
||||
|
@ -1308,7 +1308,7 @@ mod gen_primitives {
|
|||
_ ->
|
||||
Empty
|
||||
|
||||
main : Dict I64
|
||||
main : RedBlackTree I64
|
||||
main =
|
||||
balance Red 0 Empty Empty
|
||||
"#
|
||||
|
@ -1325,13 +1325,13 @@ mod gen_primitives {
|
|||
r#"
|
||||
app "test" provides [ main ] to "./platform"
|
||||
|
||||
Dict k : [ Node k (Dict k) (Dict k), Empty ]
|
||||
RedBlackTree k : [ Node k (RedBlackTree k) (RedBlackTree k), Empty ]
|
||||
|
||||
balance : k, Dict k -> Dict k
|
||||
balance : k, RedBlackTree k -> RedBlackTree k
|
||||
balance = \key, left ->
|
||||
Node key left Empty
|
||||
|
||||
main : Dict I64
|
||||
main : RedBlackTree I64
|
||||
main =
|
||||
balance 0 Empty
|
||||
"#
|
||||
|
@ -1357,9 +1357,9 @@ mod gen_primitives {
|
|||
|
||||
NodeColor : [ Red, Black ]
|
||||
|
||||
Dict k v : [ Node NodeColor k v (Dict k v) (Dict k v), Empty ]
|
||||
RedBlackTree k v : [ Node NodeColor k v (RedBlackTree k v) (RedBlackTree k v), Empty ]
|
||||
|
||||
# balance : NodeColor, k, v, Dict k v, Dict k v -> Dict k v
|
||||
# balance : NodeColor, k, v, RedBlackTree k v, RedBlackTree k v -> RedBlackTree k v
|
||||
balance = \color, key, value, left, right ->
|
||||
when right is
|
||||
Node Red rK rV rLeft rRight ->
|
||||
|
@ -1378,7 +1378,7 @@ mod gen_primitives {
|
|||
_ ->
|
||||
Empty
|
||||
|
||||
main : Dict I64 I64
|
||||
main : RedBlackTree I64 I64
|
||||
main =
|
||||
balance Red 0 0 Empty Empty
|
||||
"#
|
||||
|
@ -1397,9 +1397,9 @@ mod gen_primitives {
|
|||
|
||||
NodeColor : [ Red, Black ]
|
||||
|
||||
Dict k v : [ Node NodeColor k v (Dict k v) (Dict k v), Empty ]
|
||||
RedBlackTree k v : [ Node NodeColor k v (RedBlackTree k v) (RedBlackTree k v), Empty ]
|
||||
|
||||
balance : NodeColor, k, v, Dict k v, Dict k v -> Dict k v
|
||||
balance : NodeColor, k, v, RedBlackTree k v, RedBlackTree k v -> RedBlackTree k v
|
||||
balance = \color, key, value, left, right ->
|
||||
when right is
|
||||
Node Red rK rV rLeft rRight ->
|
||||
|
@ -1428,7 +1428,7 @@ mod gen_primitives {
|
|||
_ ->
|
||||
Node color key value left right
|
||||
|
||||
main : Dict I64 I64
|
||||
main : RedBlackTree I64 I64
|
||||
main =
|
||||
balance Red 0 0 Empty Empty
|
||||
"#
|
||||
|
|
|
@ -8,8 +8,8 @@ interface AStar
|
|||
Model position :
|
||||
{ evaluated : Set position
|
||||
, openSet : Set position
|
||||
, costs : Map.Map position F64
|
||||
, cameFrom : Map.Map position position
|
||||
, costs : Dict.Dict position F64
|
||||
, cameFrom : Dict.Dict position position
|
||||
}
|
||||
|
||||
|
||||
|
@ -17,8 +17,8 @@ initialModel : position -> Model position
|
|||
initialModel = \start ->
|
||||
{ evaluated : Set.empty
|
||||
, openSet : Set.singleton start
|
||||
, costs : Map.singleton start 0.0
|
||||
, cameFrom : Map.empty
|
||||
, costs : Dict.singleton start 0.0
|
||||
, cameFrom : Dict.empty
|
||||
}
|
||||
|
||||
|
||||
|
@ -26,7 +26,7 @@ cheapestOpen : (position -> F64), Model position -> Result position [ KeyNotFoun
|
|||
cheapestOpen = \costFunction, model ->
|
||||
|
||||
folder = \position, resSmallestSoFar ->
|
||||
when Map.get model.costs position is
|
||||
when Dict.get model.costs position is
|
||||
Err e ->
|
||||
Err e
|
||||
|
||||
|
@ -47,9 +47,9 @@ cheapestOpen = \costFunction, model ->
|
|||
|
||||
|
||||
|
||||
reconstructPath : Map position position, position -> List position
|
||||
reconstructPath : Dict position position, position -> List position
|
||||
reconstructPath = \cameFrom, goal ->
|
||||
when Map.get cameFrom goal is
|
||||
when Dict.get cameFrom goal is
|
||||
Err KeyNotFound ->
|
||||
[]
|
||||
|
||||
|
@ -58,9 +58,9 @@ reconstructPath = \cameFrom, goal ->
|
|||
|
||||
updateCost : position, position, Model position -> Model position
|
||||
updateCost = \current, neighbour, model ->
|
||||
newCameFrom = Map.insert model.cameFrom neighbour current
|
||||
newCameFrom = Dict.insert model.cameFrom neighbour current
|
||||
|
||||
newCosts = Map.insert model.costs neighbour distanceTo
|
||||
newCosts = Dict.insert model.costs neighbour distanceTo
|
||||
|
||||
distanceTo = reconstructPath newCameFrom neighbour
|
||||
|> List.len
|
||||
|
@ -68,7 +68,7 @@ updateCost = \current, neighbour, model ->
|
|||
|
||||
newModel = { model & costs : newCosts , cameFrom : newCameFrom }
|
||||
|
||||
when Map.get model.costs neighbour is
|
||||
when Dict.get model.costs neighbour is
|
||||
Err KeyNotFound ->
|
||||
newModel
|
||||
|
||||
|
|
|
@ -242,15 +242,15 @@ mod test_load {
|
|||
"RBTree",
|
||||
indoc!(
|
||||
r#"
|
||||
interface RBTree exposes [ Dict, empty ] imports []
|
||||
interface RBTree exposes [ RedBlackTree, empty ] imports []
|
||||
|
||||
# The color of a node. Leaves are considered Black.
|
||||
NodeColor : [ Red, Black ]
|
||||
|
||||
Dict k v : [ Node NodeColor k v (Dict k v) (Dict k v), Empty ]
|
||||
RedBlackTree k v : [ Node NodeColor k v (RedBlackTree k v) (RedBlackTree k v), Empty ]
|
||||
|
||||
# Create an empty dictionary.
|
||||
empty : Dict k v
|
||||
empty : RedBlackTree k v
|
||||
empty =
|
||||
Empty
|
||||
"#
|
||||
|
@ -265,7 +265,7 @@ mod test_load {
|
|||
imports [ RBTree ]
|
||||
provides [ main ] to blah
|
||||
|
||||
empty : RBTree.Dict I64 I64
|
||||
empty : RBTree.RedBlackTree I64 I64
|
||||
empty = RBTree.empty
|
||||
|
||||
main = empty
|
||||
|
@ -424,7 +424,7 @@ mod test_load {
|
|||
hashmap! {
|
||||
"findPath" => "{ costFunction : position, position -> F64, end : position, moveFunction : position -> Set position, start : position } -> Result (List position) [ KeyNotFound ]*",
|
||||
"initialModel" => "position -> Model position",
|
||||
"reconstructPath" => "Map position position, position -> List position",
|
||||
"reconstructPath" => "Dict position position, position -> List position",
|
||||
"updateCost" => "position, position, Model position -> Model position",
|
||||
"cheapestOpen" => "(position -> F64), Model position -> Result position [ KeyNotFound ]*",
|
||||
"astar" => "(position, position -> F64), (position -> Set position), position, Model position -> [ Err [ KeyNotFound ]*, Ok (List position) ]*",
|
||||
|
|
|
@ -69,7 +69,7 @@ impl ModuleName {
|
|||
pub const STR: &'static str = "Str";
|
||||
pub const NUM: &'static str = "Num";
|
||||
pub const LIST: &'static str = "List";
|
||||
pub const MAP: &'static str = "Map";
|
||||
pub const DICT: &'static str = "Dict";
|
||||
pub const SET: &'static str = "Set";
|
||||
pub const RESULT: &'static str = "Result";
|
||||
|
||||
|
|
|
@ -835,13 +835,13 @@ define_builtins! {
|
|||
0 RESULT_RESULT: "Result" imported // the Result.Result type alias
|
||||
1 RESULT_MAP: "map"
|
||||
}
|
||||
6 MAP: "Map" => {
|
||||
0 MAP_MAP: "Map" imported // the Map.Map type alias
|
||||
1 MAP_AT_MAP: "@Map" // the Map.@Map private tag
|
||||
2 MAP_EMPTY: "empty"
|
||||
3 MAP_SINGLETON: "singleton"
|
||||
4 MAP_GET: "get"
|
||||
5 MAP_INSERT: "insert"
|
||||
6 DICT: "Dict" => {
|
||||
0 DICT_DICT: "Dict" imported // the Dict.Dict type alias
|
||||
1 DICT_AT_DICT: "@Dict" // the Dict.@Dict private tag
|
||||
2 DICT_EMPTY: "empty"
|
||||
3 DICT_SINGLETON: "singleton"
|
||||
4 DICT_GET: "get"
|
||||
5 DICT_INSERT: "insert"
|
||||
}
|
||||
7 SET: "Set" => {
|
||||
0 SET_SET: "Set" imported // the Set.Set type alias
|
||||
|
|
|
@ -317,12 +317,12 @@ pub enum Builtin<'a> {
|
|||
Float32,
|
||||
Float16,
|
||||
Str,
|
||||
Map(&'a Layout<'a>, &'a Layout<'a>),
|
||||
Dict(&'a Layout<'a>, &'a Layout<'a>),
|
||||
Set(&'a Layout<'a>),
|
||||
List(MemoryMode, &'a Layout<'a>),
|
||||
EmptyStr,
|
||||
EmptyList,
|
||||
EmptyMap,
|
||||
EmptyDict,
|
||||
EmptySet,
|
||||
}
|
||||
|
||||
|
@ -667,8 +667,8 @@ impl<'a> Builtin<'a> {
|
|||
|
||||
/// Number of machine words in an empty one of these
|
||||
pub const STR_WORDS: u32 = 2;
|
||||
pub const MAP_WORDS: u32 = 6;
|
||||
pub const SET_WORDS: u32 = Builtin::MAP_WORDS; // Set is an alias for Map with {} for value
|
||||
pub const DICT_WORDS: u32 = 6;
|
||||
pub const SET_WORDS: u32 = Builtin::DICT_WORDS; // Set is an alias for Dict with {} for value
|
||||
pub const LIST_WORDS: u32 = 2;
|
||||
|
||||
/// Layout of collection wrapper for List and Str - a struct of (pointer, length).
|
||||
|
@ -693,7 +693,7 @@ impl<'a> Builtin<'a> {
|
|||
Float32 => Builtin::F32_SIZE,
|
||||
Float16 => Builtin::F16_SIZE,
|
||||
Str | EmptyStr => Builtin::STR_WORDS * pointer_size,
|
||||
Map(_, _) | EmptyMap => Builtin::MAP_WORDS * pointer_size,
|
||||
Dict(_, _) | EmptyDict => Builtin::DICT_WORDS * pointer_size,
|
||||
Set(_) | EmptySet => Builtin::SET_WORDS * pointer_size,
|
||||
List(_, _) | EmptyList => Builtin::LIST_WORDS * pointer_size,
|
||||
}
|
||||
|
@ -718,7 +718,7 @@ impl<'a> Builtin<'a> {
|
|||
Float32 => align_of::<f32>() as u32,
|
||||
Float16 => align_of::<i16>() as u32,
|
||||
Str | EmptyStr => pointer_size,
|
||||
Map(_, _) | EmptyMap => pointer_size,
|
||||
Dict(_, _) | EmptyDict => pointer_size,
|
||||
Set(_) | EmptySet => pointer_size,
|
||||
List(_, _) | EmptyList => pointer_size,
|
||||
}
|
||||
|
@ -729,8 +729,8 @@ impl<'a> Builtin<'a> {
|
|||
|
||||
match self {
|
||||
Int128 | Int64 | Int32 | Int16 | Int8 | Int1 | Float128 | Float64 | Float32
|
||||
| Float16 | EmptyStr | EmptyMap | EmptyList | EmptySet => true,
|
||||
Str | Map(_, _) | Set(_) | List(_, _) => false,
|
||||
| Float16 | EmptyStr | EmptyDict | EmptyList | EmptySet => true,
|
||||
Str | Dict(_, _) | Set(_) | List(_, _) => false,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -740,13 +740,13 @@ impl<'a> Builtin<'a> {
|
|||
|
||||
match self {
|
||||
Int128 | Int64 | Int32 | Int16 | Int8 | Int1 | Float128 | Float64 | Float32
|
||||
| Float16 | EmptyStr | EmptyMap | EmptyList | EmptySet => false,
|
||||
| Float16 | EmptyStr | EmptyDict | EmptyList | EmptySet => false,
|
||||
List(mode, element_layout) => match mode {
|
||||
MemoryMode::Refcounted => true,
|
||||
MemoryMode::Unique => element_layout.contains_refcounted(),
|
||||
},
|
||||
|
||||
Str | Map(_, _) | Set(_) => true,
|
||||
Str | Dict(_, _) | Set(_) => true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -447,9 +447,9 @@ mod test_reporting {
|
|||
these names seem close though:
|
||||
|
||||
baz
|
||||
Map
|
||||
Str
|
||||
main
|
||||
F64
|
||||
"#
|
||||
),
|
||||
)
|
||||
|
@ -1374,7 +1374,7 @@ mod test_reporting {
|
|||
Bool
|
||||
F64
|
||||
Num
|
||||
Map
|
||||
Set
|
||||
"#
|
||||
),
|
||||
)
|
||||
|
@ -1830,7 +1830,7 @@ mod test_reporting {
|
|||
f
|
||||
F64
|
||||
Num
|
||||
Map
|
||||
Set
|
||||
"#
|
||||
),
|
||||
)
|
||||
|
@ -3534,8 +3534,8 @@ mod test_reporting {
|
|||
|
||||
Bool
|
||||
Num
|
||||
Map
|
||||
Set
|
||||
Str
|
||||
"#
|
||||
),
|
||||
)
|
||||
|
@ -3928,10 +3928,10 @@ mod test_reporting {
|
|||
# The color of a node. Leaves are considered Black.
|
||||
NodeColor : [ Red, Black ]
|
||||
|
||||
Dict k v : [ Node NodeColor k v (Dict k v) (Dict k v), Empty ]
|
||||
RBTree k v : [ Node NodeColor k v (RBTree k v) (RBTree k v), Empty ]
|
||||
|
||||
# Create an empty dictionary.
|
||||
empty : Dict k v
|
||||
empty : RBTree k v
|
||||
empty =
|
||||
Empty
|
||||
|
||||
|
|
|
@ -2508,10 +2508,10 @@ mod solve_expr {
|
|||
infer_eq_without_problem(
|
||||
indoc!(
|
||||
r#"
|
||||
Map.insert
|
||||
Dict.insert
|
||||
"#
|
||||
),
|
||||
"Map a b, a, b -> Map a b",
|
||||
"Dict a b, a, b -> Dict a b",
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -2592,9 +2592,9 @@ mod solve_expr {
|
|||
infer_eq_without_problem(
|
||||
indoc!(
|
||||
r#"
|
||||
reconstructPath : Map position position, position -> List position
|
||||
reconstructPath : Dict position position, position -> List position
|
||||
reconstructPath = \cameFrom, goal ->
|
||||
when Map.get cameFrom goal is
|
||||
when Dict.get cameFrom goal is
|
||||
Err KeyNotFound ->
|
||||
[]
|
||||
|
||||
|
@ -2604,7 +2604,7 @@ mod solve_expr {
|
|||
reconstructPath
|
||||
"#
|
||||
),
|
||||
"Map position position, position -> List position",
|
||||
"Dict position position, position -> List position",
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -3101,22 +3101,22 @@ mod solve_expr {
|
|||
# The color of a node. Leaves are considered Black.
|
||||
NodeColor : [ Red, Black ]
|
||||
|
||||
Dict k v : [ Node NodeColor k v (Dict k v) (Dict k v), Empty ]
|
||||
RBTree k v : [ Node NodeColor k v (RBTree k v) (RBTree k v), Empty ]
|
||||
|
||||
# Create an empty dictionary.
|
||||
empty : Dict k v
|
||||
empty : RBTree k v
|
||||
empty =
|
||||
Empty
|
||||
|
||||
foo : Dict I64 I64
|
||||
foo : RBTree I64 I64
|
||||
foo = empty
|
||||
|
||||
main : Dict I64 I64
|
||||
main : RBTree I64 I64
|
||||
main =
|
||||
foo
|
||||
"#
|
||||
),
|
||||
"Dict I64 I64",
|
||||
"RBTree I64 I64",
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -3131,21 +3131,21 @@ mod solve_expr {
|
|||
r#"
|
||||
app "test" provides [ main ] to "./platform"
|
||||
|
||||
Dict k : [ Node k (Dict k), Empty ]
|
||||
RBTree k : [ Node k (RBTree k), Empty ]
|
||||
|
||||
balance : Dict k -> Dict k
|
||||
balance : RBTree k -> RBTree k
|
||||
balance = \left ->
|
||||
when left is
|
||||
Node _ Empty -> Empty
|
||||
|
||||
_ -> Empty
|
||||
|
||||
main : Dict {}
|
||||
main : RBTree {}
|
||||
main =
|
||||
balance Empty
|
||||
"#
|
||||
),
|
||||
"Dict {}",
|
||||
"RBTree {}",
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -3158,9 +3158,9 @@ mod solve_expr {
|
|||
|
||||
NodeColor : [ Red, Black ]
|
||||
|
||||
Dict k v : [ Node NodeColor k v (Dict k v) (Dict k v), Empty ]
|
||||
RBTree k v : [ Node NodeColor k v (RBTree k v) (RBTree k v), Empty ]
|
||||
|
||||
moveRedLeft : Dict k v -> Dict k v
|
||||
moveRedLeft : RBTree k v -> RBTree k v
|
||||
moveRedLeft = \dict ->
|
||||
when dict is
|
||||
# Node clr k v (Node lClr lK lV lLeft lRight) (Node rClr rK rV ((Node Red rlK rlV rlL rlR) as rLeft) rRight) ->
|
||||
|
@ -3196,7 +3196,7 @@ mod solve_expr {
|
|||
_ ->
|
||||
dict
|
||||
|
||||
balance : NodeColor, k, v, Dict k v, Dict k v -> Dict k v
|
||||
balance : NodeColor, k, v, RBTree k v, RBTree k v -> RBTree k v
|
||||
balance = \color, key, value, left, right ->
|
||||
when right is
|
||||
Node Red rK rV rLeft rRight ->
|
||||
|
@ -3228,7 +3228,7 @@ mod solve_expr {
|
|||
|
||||
Key k : Num k
|
||||
|
||||
removeHelpEQGT : Key k, Dict (Key k) v -> Dict (Key k) v
|
||||
removeHelpEQGT : Key k, RBTree (Key k) v -> RBTree (Key k) v
|
||||
removeHelpEQGT = \targetKey, dict ->
|
||||
when dict is
|
||||
Node color key value left right ->
|
||||
|
@ -3245,7 +3245,7 @@ mod solve_expr {
|
|||
Empty ->
|
||||
Empty
|
||||
|
||||
getMin : Dict k v -> Dict k v
|
||||
getMin : RBTree k v -> RBTree k v
|
||||
getMin = \dict ->
|
||||
when dict is
|
||||
# Node _ _ _ ((Node _ _ _ _ _) as left) _ ->
|
||||
|
@ -3258,7 +3258,7 @@ mod solve_expr {
|
|||
dict
|
||||
|
||||
|
||||
moveRedRight : Dict k v -> Dict k v
|
||||
moveRedRight : RBTree k v -> RBTree k v
|
||||
moveRedRight = \dict ->
|
||||
when dict is
|
||||
Node clr k v (Node lClr lK lV (Node Red llK llV llLeft llRight) lRight) (Node rClr rK rV rLeft rRight) ->
|
||||
|
@ -3291,7 +3291,7 @@ mod solve_expr {
|
|||
dict
|
||||
|
||||
|
||||
removeHelpPrepEQGT : Key k, Dict (Key k) v, NodeColor, (Key k), v, Dict (Key k) v, Dict (Key k) v -> Dict (Key k) v
|
||||
removeHelpPrepEQGT : Key k, RBTree (Key k) v, NodeColor, (Key k), v, RBTree (Key k) v, RBTree (Key k) v -> RBTree (Key k) v
|
||||
removeHelpPrepEQGT = \_, dict, color, key, value, left, right ->
|
||||
when left is
|
||||
Node Red lK lV lLeft lRight ->
|
||||
|
@ -3314,7 +3314,7 @@ mod solve_expr {
|
|||
dict
|
||||
|
||||
|
||||
removeMin : Dict k v -> Dict k v
|
||||
removeMin : RBTree k v -> RBTree k v
|
||||
removeMin = \dict ->
|
||||
when dict is
|
||||
Node color key value left right ->
|
||||
|
@ -3342,7 +3342,7 @@ mod solve_expr {
|
|||
_ ->
|
||||
Empty
|
||||
|
||||
removeHelp : Key k, Dict (Key k) v -> Dict (Key k) v
|
||||
removeHelp : Key k, RBTree (Key k) v -> RBTree (Key k) v
|
||||
removeHelp = \targetKey, dict ->
|
||||
when dict is
|
||||
Empty ->
|
||||
|
@ -3370,12 +3370,12 @@ mod solve_expr {
|
|||
removeHelpEQGT targetKey (removeHelpPrepEQGT targetKey dict color key value left right)
|
||||
|
||||
|
||||
main : Dict I64 I64
|
||||
main : RBTree I64 I64
|
||||
main =
|
||||
removeHelp 1 Empty
|
||||
"#
|
||||
),
|
||||
"Dict I64 I64",
|
||||
"RBTree I64 I64",
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -3386,9 +3386,9 @@ mod solve_expr {
|
|||
r#"
|
||||
app "test" provides [ main ] to "./platform"
|
||||
|
||||
Dict k : [ Node k (Dict k) (Dict k), Empty ]
|
||||
RBTree k : [ Node k (RBTree k) (RBTree k), Empty ]
|
||||
|
||||
removeHelp : Num k, Dict (Num k) -> Dict (Num k)
|
||||
removeHelp : Num k, RBTree (Num k) -> RBTree (Num k)
|
||||
removeHelp = \targetKey, dict ->
|
||||
when dict is
|
||||
Empty ->
|
||||
|
@ -3410,12 +3410,12 @@ mod solve_expr {
|
|||
Empty
|
||||
|
||||
|
||||
main : Dict I64
|
||||
main : RBTree I64
|
||||
main =
|
||||
removeHelp 1 Empty
|
||||
"#
|
||||
),
|
||||
"Dict I64",
|
||||
"RBTree I64",
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -3428,9 +3428,9 @@ mod solve_expr {
|
|||
|
||||
NodeColor : [ Red, Black ]
|
||||
|
||||
Dict k v : [ Node NodeColor k v (Dict k v) (Dict k v), Empty ]
|
||||
RBTree k v : [ Node NodeColor k v (RBTree k v) (RBTree k v), Empty ]
|
||||
|
||||
removeHelp : Num k, Dict (Num k) v -> Dict (Num k) v
|
||||
removeHelp : Num k, RBTree (Num k) v -> RBTree (Num k) v
|
||||
removeHelp = \targetKey, dict ->
|
||||
when dict is
|
||||
Empty ->
|
||||
|
@ -3459,13 +3459,13 @@ mod solve_expr {
|
|||
|
||||
Key k : Num k
|
||||
|
||||
balance : NodeColor, k, v, Dict k v, Dict k v -> Dict k v
|
||||
balance : NodeColor, k, v, RBTree k v, RBTree k v -> RBTree k v
|
||||
|
||||
moveRedLeft : Dict k v -> Dict k v
|
||||
moveRedLeft : RBTree k v -> RBTree k v
|
||||
|
||||
removeHelpPrepEQGT : Key k, Dict (Key k) v, NodeColor, (Key k), v, Dict (Key k) v, Dict (Key k) v -> Dict (Key k) v
|
||||
removeHelpPrepEQGT : Key k, RBTree (Key k) v, NodeColor, (Key k), v, RBTree (Key k) v, RBTree (Key k) v -> RBTree (Key k) v
|
||||
|
||||
removeHelpEQGT : Key k, Dict (Key k) v -> Dict (Key k) v
|
||||
removeHelpEQGT : Key k, RBTree (Key k) v -> RBTree (Key k) v
|
||||
removeHelpEQGT = \targetKey, dict ->
|
||||
when dict is
|
||||
Node color key value left right ->
|
||||
|
@ -3482,16 +3482,16 @@ mod solve_expr {
|
|||
Empty ->
|
||||
Empty
|
||||
|
||||
getMin : Dict k v -> Dict k v
|
||||
getMin : RBTree k v -> RBTree k v
|
||||
|
||||
removeMin : Dict k v -> Dict k v
|
||||
removeMin : RBTree k v -> RBTree k v
|
||||
|
||||
main : Dict I64 I64
|
||||
main : RBTree I64 I64
|
||||
main =
|
||||
removeHelp 1 Empty
|
||||
"#
|
||||
),
|
||||
"Dict I64 I64",
|
||||
"RBTree I64 I64",
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -3540,18 +3540,18 @@ mod solve_expr {
|
|||
r#"
|
||||
app "test" provides [ main ] to "./platform"
|
||||
|
||||
Dict k : [ Node k (Dict k) (Dict k), Empty ]
|
||||
RBTree k : [ Node k (RBTree k) (RBTree k), Empty ]
|
||||
|
||||
balance : k, Dict k -> Dict k
|
||||
balance : k, RBTree k -> RBTree k
|
||||
balance = \key, left ->
|
||||
Node key left Empty
|
||||
|
||||
main : Dict I64
|
||||
main : RBTree I64
|
||||
main =
|
||||
balance 0 Empty
|
||||
"#
|
||||
),
|
||||
"Dict I64",
|
||||
"RBTree I64",
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -3562,20 +3562,20 @@ mod solve_expr {
|
|||
r#"
|
||||
app "test" provides [ main ] to "./platform"
|
||||
|
||||
Dict k : [ Node k (Dict k) (Dict k), Empty ]
|
||||
RBTree k : [ Node k (RBTree k) (RBTree k), Empty ]
|
||||
|
||||
node = \x,y,z -> Node x y z
|
||||
|
||||
balance : k, Dict k -> Dict k
|
||||
balance : k, RBTree k -> RBTree k
|
||||
balance = \key, left ->
|
||||
node key left Empty
|
||||
|
||||
main : Dict I64
|
||||
main : RBTree I64
|
||||
main =
|
||||
balance 0 Empty
|
||||
"#
|
||||
),
|
||||
"Dict I64",
|
||||
"RBTree I64",
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -3588,9 +3588,9 @@ mod solve_expr {
|
|||
|
||||
NodeColor : [ Red, Black ]
|
||||
|
||||
Dict k v : [ Node NodeColor k v (Dict k v) (Dict k v), Empty ]
|
||||
RBTree k v : [ Node NodeColor k v (RBTree k v) (RBTree k v), Empty ]
|
||||
|
||||
balance : NodeColor, k, v, Dict k v, Dict k v -> Dict k v
|
||||
balance : NodeColor, k, v, RBTree k v, RBTree k v -> RBTree k v
|
||||
balance = \color, key, value, left, right ->
|
||||
when right is
|
||||
Node Red rK rV rLeft rRight ->
|
||||
|
@ -3619,12 +3619,12 @@ mod solve_expr {
|
|||
_ ->
|
||||
Node color key value left right
|
||||
|
||||
main : Dict I64 I64
|
||||
main : RBTree I64 I64
|
||||
main =
|
||||
balance Red 0 0 Empty Empty
|
||||
"#
|
||||
),
|
||||
"Dict I64 I64",
|
||||
"RBTree I64 I64",
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -3636,9 +3636,9 @@ mod solve_expr {
|
|||
r#"
|
||||
app Test provides [ main ] imports []
|
||||
|
||||
Dict k : [ Node k (Dict k) (Dict k), Empty ]
|
||||
RBTree k : [ Node k (RBTree k) (RBTree k), Empty ]
|
||||
|
||||
balance : k, Dict k -> Dict k
|
||||
balance : k, RBTree k -> RBTree k
|
||||
balance = \key, left ->
|
||||
when left is
|
||||
Node _ _ lRight ->
|
||||
|
@ -3648,12 +3648,12 @@ mod solve_expr {
|
|||
Empty
|
||||
|
||||
|
||||
main : Dict I64
|
||||
main : RBTree I64
|
||||
main =
|
||||
balance 0 Empty
|
||||
"#
|
||||
),
|
||||
"Dict I64",
|
||||
"RBTree I64",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2397,24 +2397,24 @@ mod solve_uniq_expr {
|
|||
|
||||
#[test]
|
||||
fn map_empty() {
|
||||
infer_eq("Map.empty", "Attr * (Map * *)");
|
||||
infer_eq("Dict.empty", "Attr * (Dict * *)");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn map_singelton() {
|
||||
infer_eq("Map.singleton", "Attr * (a, b -> Attr * (Map a b))");
|
||||
infer_eq("Dict.singleton", "Attr * (a, b -> Attr * (Dict a b))");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn map_get() {
|
||||
infer_eq("Map.get", "Attr * (Attr (* | c) (Map (Attr * a) (Attr c b)), Attr * a -> Attr * (Result (Attr c b) (Attr * [ KeyNotFound ]*)))");
|
||||
infer_eq("Dict.get", "Attr * (Attr (* | c) (Dict (Attr * a) (Attr c b)), Attr * a -> Attr * (Result (Attr c b) (Attr * [ KeyNotFound ]*)))");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn map_insert() {
|
||||
infer_eq(
|
||||
"Map.insert",
|
||||
"Attr * (Attr * (Map a b), a, b -> Attr * (Map a b))",
|
||||
"Dict.insert",
|
||||
"Attr * (Attr * (Dict a b), a, b -> Attr * (Dict a b))",
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -2747,9 +2747,9 @@ mod solve_uniq_expr {
|
|||
infer_eq(
|
||||
indoc!(
|
||||
r#"
|
||||
reconstructPath : Map position position, position -> List position
|
||||
reconstructPath : Dict position position, position -> List position
|
||||
reconstructPath = \cameFrom, goal ->
|
||||
when Map.get cameFrom goal is
|
||||
when Dict.get cameFrom goal is
|
||||
Err KeyNotFound ->
|
||||
[]
|
||||
|
||||
|
@ -2759,7 +2759,7 @@ mod solve_uniq_expr {
|
|||
reconstructPath
|
||||
"#
|
||||
),
|
||||
"Attr Shared (Attr Shared (Map (Attr * position) (Attr Shared position)), Attr Shared position -> Attr * (List (Attr Shared position)))"
|
||||
"Attr Shared (Attr Shared (Dict (Attr * position) (Attr Shared position)), Attr Shared position -> Attr * (List (Attr Shared position)))"
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -2772,15 +2772,15 @@ mod solve_uniq_expr {
|
|||
r#"
|
||||
Model position : { evaluated : Set position
|
||||
, openSet : Set position
|
||||
, costs : Map.Map position F64
|
||||
, cameFrom : Map.Map position position
|
||||
, costs : Dict.Dict position F64
|
||||
, cameFrom : Dict.Dict position position
|
||||
}
|
||||
|
||||
cheapestOpen : (position -> F64), Model position -> Result position [ KeyNotFound ]*
|
||||
cheapestOpen = \costFunction, model ->
|
||||
|
||||
folder = \position, resSmallestSoFar ->
|
||||
when Map.get model.costs position is
|
||||
when Dict.get model.costs position is
|
||||
Err e ->
|
||||
Err e
|
||||
|
||||
|
@ -2815,13 +2815,13 @@ mod solve_uniq_expr {
|
|||
r#"
|
||||
Model position : { evaluated : Set position
|
||||
, openSet : Set position
|
||||
, costs : Map.Map position F64
|
||||
, cameFrom : Map.Map position position
|
||||
, costs : Dict.Dict position F64
|
||||
, cameFrom : Dict.Dict position position
|
||||
}
|
||||
|
||||
reconstructPath : Map position position, position -> List position
|
||||
reconstructPath : Dict position position, position -> List position
|
||||
reconstructPath = \cameFrom, goal ->
|
||||
when Map.get cameFrom goal is
|
||||
when Dict.get cameFrom goal is
|
||||
Err KeyNotFound ->
|
||||
[]
|
||||
|
||||
|
@ -2830,9 +2830,9 @@ mod solve_uniq_expr {
|
|||
|
||||
updateCost : position, position, Model position -> Model position
|
||||
updateCost = \current, neighbour, model ->
|
||||
newCameFrom = Map.insert model.cameFrom neighbour current
|
||||
newCameFrom = Dict.insert model.cameFrom neighbour current
|
||||
|
||||
newCosts = Map.insert model.costs neighbour distanceTo
|
||||
newCosts = Dict.insert model.costs neighbour distanceTo
|
||||
|
||||
distanceTo = reconstructPath newCameFrom neighbour
|
||||
|> List.len
|
||||
|
@ -2840,7 +2840,7 @@ mod solve_uniq_expr {
|
|||
|
||||
newModel = { model & costs : newCosts , cameFrom : newCameFrom }
|
||||
|
||||
when Map.get model.costs neighbour is
|
||||
when Dict.get model.costs neighbour is
|
||||
Err KeyNotFound ->
|
||||
newModel
|
||||
|
||||
|
@ -2867,8 +2867,8 @@ mod solve_uniq_expr {
|
|||
r#"
|
||||
Model position : { evaluated : Set position
|
||||
, openSet : Set position
|
||||
, costs : Map.Map position F64
|
||||
, cameFrom : Map.Map position position
|
||||
, costs : Dict.Dict position F64
|
||||
, cameFrom : Dict.Dict position position
|
||||
}
|
||||
|
||||
|
||||
|
@ -2876,8 +2876,8 @@ mod solve_uniq_expr {
|
|||
initialModel = \start ->
|
||||
{ evaluated : Set.empty
|
||||
, openSet : Set.singleton start
|
||||
, costs : Map.singleton start 0.0
|
||||
, cameFrom : Map.empty
|
||||
, costs : Dict.singleton start 0.0
|
||||
, cameFrom : Dict.empty
|
||||
}
|
||||
|
||||
|
||||
|
@ -2885,7 +2885,7 @@ mod solve_uniq_expr {
|
|||
cheapestOpen = \costFunction, model ->
|
||||
|
||||
folder = \position, resSmallestSoFar ->
|
||||
when Map.get model.costs position is
|
||||
when Dict.get model.costs position is
|
||||
Err e ->
|
||||
Err e
|
||||
|
||||
|
@ -2906,9 +2906,9 @@ mod solve_uniq_expr {
|
|||
|> Result.map (\x -> x.position)
|
||||
|
||||
|
||||
reconstructPath : Map position position, position -> List position
|
||||
reconstructPath : Dict position position, position -> List position
|
||||
reconstructPath = \cameFrom, goal ->
|
||||
when Map.get cameFrom goal is
|
||||
when Dict.get cameFrom goal is
|
||||
Err KeyNotFound ->
|
||||
[]
|
||||
|
||||
|
@ -2918,9 +2918,9 @@ mod solve_uniq_expr {
|
|||
|
||||
updateCost : position, position, Model position -> Model position
|
||||
updateCost = \current, neighbour, model ->
|
||||
newCameFrom = Map.insert model.cameFrom neighbour current
|
||||
newCameFrom = Dict.insert model.cameFrom neighbour current
|
||||
|
||||
newCosts = Map.insert model.costs neighbour distanceTo
|
||||
newCosts = Dict.insert model.costs neighbour distanceTo
|
||||
|
||||
distanceTo =
|
||||
reconstructPath newCameFrom neighbour
|
||||
|
@ -2929,7 +2929,7 @@ mod solve_uniq_expr {
|
|||
|
||||
newModel = { model & costs : newCosts , cameFrom : newCameFrom }
|
||||
|
||||
when Map.get model.costs neighbour is
|
||||
when Dict.get model.costs neighbour is
|
||||
Err KeyNotFound ->
|
||||
newModel
|
||||
|
||||
|
|
|
@ -247,8 +247,8 @@ pub fn set_type(a: SolvedType) -> SolvedType {
|
|||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn map_type(key: SolvedType, value: SolvedType) -> SolvedType {
|
||||
SolvedType::Apply(Symbol::MAP_MAP, vec![key, value])
|
||||
pub fn dict_type(key: SolvedType, value: SolvedType) -> SolvedType {
|
||||
SolvedType::Apply(Symbol::DICT_DICT, vec![key, value])
|
||||
}
|
||||
|
||||
fn single_private_tag(symbol: Symbol, type_arguments: Vec<SolvedType>) -> SolvedType {
|
||||
|
|
|
@ -150,7 +150,7 @@ pub enum Type {
|
|||
actual: Box<Type>,
|
||||
},
|
||||
RecursiveTagUnion(Variable, Vec<(TagName, Vec<Type>)>, Box<Type>),
|
||||
/// Applying a type to some arguments (e.g. Map.Map String Int)
|
||||
/// Applying a type to some arguments (e.g. Dict.Dict String Int)
|
||||
Apply(Symbol, Vec<Type>),
|
||||
/// Boolean type used in uniqueness inference
|
||||
Boolean(boolean_algebra::Bool),
|
||||
|
|
|
@ -48,7 +48,7 @@ fn main() {
|
|||
generate(
|
||||
vec![
|
||||
PathBuf::from(r"../compiler/builtins/docs/Bool.roc"),
|
||||
PathBuf::from(r"../compiler/builtins/docs/Map.roc"),
|
||||
PathBuf::from(r"../compiler/builtins/docs/Dict.roc"),
|
||||
// Not working
|
||||
// PathBuf::from(r"../compiler/builtins/docs/List.roc"),
|
||||
// Not working
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue