I'm wondering if it's possible to do some sort of dependent typing like the following in Elm, like you can in Idris:
isQuestion : String -> Type
isQuestion (sentence) with (endsWith "?" sentence)
| True = Question
| False = Statement
Is there a library that will let me achieve a similar effect via typing?
You could do something alike with union types.
type Sentence
= Question String
| Statement String
isQuestion : String -> Sentence
isQuestion sentence =
case endsWith "?" sentence of
True -> Question sentence
False -> Statement sentence
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With