loading...

re: BuckleScript and association lists VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Could you get the values out of your book reviews map in your previous post using this technique?
 

If you mean get values from the actual map, then no. Maps and lists are completely different types.

However, you can create an association list that would have the same functionality of the map:

let reviews = [(book1, review1), (book2, review2),...etc];

Because the books are records, you wouldn’t be able to use the (===) function to look them up; you’ll have to provide a custom equality function. That would probably look similar to the comparison function we used in the previous post, but it would have to return a boolean instead of an integer.

Belt.List.getAssoc(reviews, someBook, bookEqualsFn);
/* returns option(review) */
code of conduct - report abuse