Idris2/tests/idris2/interface029/ForwardImpl1.idr
Steve Dunham 03d6c5f637
[ new ] Handle forward declarations of implementations (#2668)
Co-authored-by: G. Allais <guillaume.allais@ens-lyon.org>
2022-09-20 21:08:50 +01:00

24 lines
567 B
Idris

interface Pretty a where
pretty : a -> String
data Bar : Type -> Type
data Foo a = FNil | FCons a (Bar a)
data Bar a = BNil | BCons a (Foo a)
Pretty a => Pretty (Foo a)
implementation Pretty a => Pretty (Bar a) where
pretty (BNil) = "Nil"
pretty (BCons a f) = "\{pretty a} :: \{pretty f}"
implementation Pretty a => Pretty (Foo a) where
pretty (FNil) = "Nil"
pretty (FCons a f) = "\{pretty a} :: \{pretty f}"
implementation Pretty String where
pretty a = a
main : IO ()
main = putStrLn $ pretty (BCons "1" (FCons "2" (BCons "3" FNil)))