Idris-dev/test/proof010/proof010.idr
Edwin Brady 3034fb619c Remove argument ordering hack in elaborator
This used to be needed because the elaborator wasn't good at going back
and patching up things that didn't work right, but now it just gets in
the way and causes all sorts of other problems. This tidies up
elaboration/unification a bit more.
2015-05-17 00:46:16 +01:00

38 lines
951 B
Idris

data MyShow : Type -> Type where
ShowInstance : (show : a -> String) -> MyShow a
myshow : {auto inst : MyShow a} -> a -> String
myshow {inst = ShowInstance show} x1 = show x1
%hint
showNat : MyShow Nat
showNat = ShowInstance show
%hint
showFn : MyShow (a -> b)
showFn = ShowInstance (\x => "<< function >>")
%hint
showBools : MyShow (Bool, Bool)
showBools = ShowInstance (\x => "some bools")
%hint
showStuff : MyShow a -> MyShow b -> MyShow (a, b)
showStuff sa sb = ShowInstance showPair
where
showPair : (a, b) -> String
showPair (x, y) = myshow x ++ ", " ++ myshow y
testShow : List (Bool, Bool) -> String
testShow [] = ""
testShow (x :: xs) = myshow x ++ "\n" ++ testShow xs
testShow2 : List (Nat, Int -> Int) -> String
testShow2 [] = ""
testShow2 (x :: xs) = myshow x ++ "\n" ++ testShow2 xs
main : IO ()
main = do putStrLn $ testShow2 [(2, (+1)), (3, abs)]
putStrLn $ testShow [(True, False), (False, True)]