mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-16 07:34:45 +03:00
c28133b7d9
- Renaming of the string overload interface - Added test cases for both string and integer literals overload
22 lines
408 B
Idris
22 lines
408 B
Idris
import Data.Maybe
|
|
|
|
%default total
|
|
|
|
FromString Int where
|
|
fromString x = cast x
|
|
|
|
test1 : Int
|
|
test1 = "42"
|
|
|
|
test2 : Int
|
|
test2 = "abc"
|
|
|
|
convert : String -> Maybe Bool
|
|
convert "True" = Just True
|
|
convert "False" = Just False
|
|
convert _ = Nothing
|
|
|
|
fromString : (str : String) -> {auto prf : IsJust (convert str)} -> Bool
|
|
fromString str {prf} with (convert str)
|
|
fromString str {prf = ItIsJust} | (Just ret) = ret
|