Skip to content
Discussion options

You must be logged in to vote

Hello. This is due to how opaque types work. They are only opaque outside of their definition scope (like in a different file) and that's why the example is split in two code samples (tho it might be useful to add a reminder about this scope mechanism).

Here is a working version in Scastie. Since it (Scastie) does not support multiple files, I wrapped the types in an object:

import io.github.iltotore.iron.*
import io.github.iltotore.iron.constraint.numeric.Positive

object types:
  opaque type Temperature = Double :| Positive
  object Temperature extends RefinedTypeOps[Double, Positive, Temperature]

  opaque type Moisture = Double :| Positive
  object Moisture extends RefinedTypeOps[Double

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Anoia
Comment options

Answer selected by Anoia
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants