mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-16 07:34:45 +03:00
05f28724ed
Co-authored-by: Guillaume ALLAIS <guillaume.allais@ens-lyon.org>
22 lines
347 B
Idris
22 lines
347 B
Idris
data Foo = A | B | C
|
|
|
|
Eq Foo where
|
|
A == A = True
|
|
B == B = True
|
|
C == C = True
|
|
_ == _ = False
|
|
|
|
interface Read a where
|
|
readPrefix : String -> Maybe (a, String)
|
|
|
|
read : String -> Maybe a
|
|
read str = case readPrefix str of
|
|
Just (a, "") => pure a
|
|
Nothing => Nothing
|
|
|
|
Read Foo where
|
|
|
|
read "A" = A
|
|
read "B" = B
|
|
read "C" = C
|