Here’s the translation of the given code into Idris along with an explanation.
Switch statements express conditionals across many branches.
Here’s a basic case.
You can use commas to separate multiple expressions in the same case statement. We use the optional default case in this example as well.
case without an expression is an alternate way to express if/else logic. Here we also show how the case expressions can be non-constants.
A type case compares types instead of values. You can use this to discover the type of an interface value. In this example, the variable t will have the type corresponding to its clause.
Running the code will produce the expected outputs based on the conditions specified.