mirror of
https://github.com/ilyakooo0/Idris-dev.git
synced 2024-11-15 01:25:05 +03:00
3034fb619c
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.
38 lines
951 B
Idris
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)]
|
|
|