Idris2/tests/idris2/basic042/LiteralsString.idr
Giuseppe Lomurno c28133b7d9 Renamed IsString to FromString
- Renaming of the string overload interface
- Added test cases for both string and integer literals overload
2020-08-05 02:33:05 +02:00

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