shithub: MicroHs

Download patch

ref: c6e8e33dc429495ac8a20e9a5d40f4ea2ceb787a
parent: 581fb546cf42e1d63f56ac724aeb8b871de8251e
author: Lennart Augustsson <lennart@augustsson.net>
date: Sun Dec 29 07:41:26 EST 2024

Test coerce

--- a/tests/Coerce.hs
+++ b/tests/Coerce.hs
@@ -13,10 +13,14 @@
 toInts :: (Coercible a Int) => [a] -> [Int]
 toInts = coerce
 
+casbs :: (Coercible a b) => [a] -> [b]
+casbs = coerce
+
 main :: IO ()
 main = do
   print (toInt (NT 5))
   print (toInts [NT 1, NT 2] :: [Int])
+  print (casbs [NT 1, NT 2, NT 3] :: [Int])
   print (coerce (List [3::Int, 4]) :: [Int])
   print (coerce (List [NT 5, NT 6]) :: [NT])
   print (coerce (List [NT 7, NT 8]) :: [Int])
--- /dev/null
+++ b/tests/Coerce.ref
@@ -1,0 +1,6 @@
+5
+[1,2]
+[1,2,3]
+[3,4]
+[NT 5,NT 6]
+[7,8]
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -79,6 +79,7 @@
 	$(TMHS) OrPat      && $(EVAL) > OrPat.out      && diff OrPat.ref OrPat.out
 	$(TMHS) PartRed    && $(EVAL) > PartRed.out    && diff PartRed.ref PartRed.out
 	$(TMHS) PatSyn     && $(EVAL) > PatSyn.out     && diff PatSyn.ref PatSyn.out
+	$(TMHS) Coerce     && $(EVAL) > Coerce.out     && diff Coerce.ref Coerce.out
 
 errtest:
 	sh errtester.sh $(MHS) < errmsg.test