Unison provides a variety of data types for managing collections of values. We'll show the basics of how to create instances of common collection types here.
One of the common things you'll be doing as a Unison programmer is managing ordered collections of one type or another. One of Unison's native data structures for this is
List,which we can create between square brackets.
desserts : [Text]
desserts = ["Eclair", "Peach cobbler", "Ice cream"]
Lists can only contain values of one type at a time, and areeagerly evaluated.
data.Maptype is Unison's way of mapping unique keys to values.
You can create a map with a single object with
Map.singleton 1 "a"where
1is the key and
"a"is the value associated with that key.
What's printed above for a
data.Mapmight look more complicated than it really is.
internal.Tipare just thedata constructorsfor
data.Map.You'll likely be working with Maps through functions in the base library instead of dealing with these terms directly. Check out a few
data.Mapmanipulation functions with
find base.Mapin the UCM.
You can explore these types and more of other collection apisin the