Dependent types in knitting
I am wondering if it is possible in Ilm to do something like dependent input, for example in Elm:
isQuestion : String -> Type
isQuestion (sentence) with (endsWith "?" sentence)
| True = Question
| False = Statement
Is there a library that will allow me to achieve a similar effect by typing?
+3
Tristan greeno
source
to share
1 answer
You can do something similar with union types.
type Sentence
= Question String
| Statement String
isQuestion : String -> Sentence
isQuestion sentence =
case endsWith "?" sentence of
True -> Question sentence
False -> Statement sentence
+6
farmio
source
to share