Stream: beginners

Topic: Type Alias vs Opaque Types


view this post on Zulip Brian Teague (Feb 20 2024 at 18:47):

I was testing returning a specific type for a function, and it required using an Opaque type vs a type alias. Why is this?

Point := { x: Str, y: Str, z: Str }

toPoint : Num a, Num b, Num c -> Point
toPoint = \a, b, c -> @Point { x: Num.toStr a, y: Num.toStr b, z: Num.toStr c }

vs

Point : { x: Str, y: Str, z: Str }

toPoint : Num a, Num b, Num c -> Point
toPoint = \a, b, c -> { x: Num.toStr a, y: Num.toStr b, z: Num.toStr c } #how to say this is type Point?

view this post on Zulip Brian Teague (Feb 20 2024 at 18:56):

I thought I would be able to create a function that returns a type alias Point like in Haskell.

view this post on Zulip Anton (Feb 20 2024 at 18:57):

I can run the second snippet, can you further specify your issue?

view this post on Zulip Brian Teague (Feb 20 2024 at 18:59):

Never mind, the second example worked. I was getting a compile error earlier, and apparently fixed it while typing up this example :rolling_on_the_floor_laughing:


Last updated: Jul 06 2025 at 12:14 UTC