ref: 45b40d4c2058c3fa7da800b342c21edd5081ed2f
parent: 2bb134465b02b4fb4c3070d6b8780d095ca3d8a5
author: Lennart Augustsson <lennart.augustsson@epicgames.com>
date: Sun Nov 26 07:15:43 EST 2023
Add a test for constraint variables.
--- a/MicroHs.cabal
+++ b/MicroHs.cabal
@@ -1,6 +1,6 @@
cabal-version: 3.0
name: MicroHs
-version: 0.8.3.0
+version: 0.8.4.0
synopsis: A compiler for a subset of Haskell
license: Apache-2.0
license-file: LICENSE
--- a/generated/mhs.c
+++ b/generated/mhs.c
@@ -6991,7 +6991,7 @@
41,41,32,95,49,52,54,41,41,41,32,40,95,51,54,52,32,35,48,41,
41,41,32,40,40,65,32,58,49,48,51,49,32,34,118,53,46,49,92,49,
48,38,34,41,32,40,40,65,32,58,49,48,51,50,32,34,48,46,56,46,
-51,46,48,34,41,32,40,40,65,32,58,49,48,51,51,32,40,40,40,95,
+52,46,48,34,41,32,40,40,65,32,58,49,48,51,51,32,40,40,40,95,
51,50,32,95,49,53,48,52,41,32,95,49,52,55,55,41,32,40,40,66,
32,40,40,95,51,50,32,95,49,53,48,52,41,32,40,95,49,52,56,48,
32,34,77,72,83,68,73,82,34,41,41,41,32,40,40,40,67,39,32,66,
--- a/lib/AllOfLib.hs
+++ b/lib/AllOfLib.hs
@@ -15,6 +15,7 @@
import Data.Char
import Data.Char_Type
import Data.Complex
+import Data.Constraint
import Data.Double
import Data.Either
import Data.Enum
--- /dev/null
+++ b/lib/Data/Constraint.hs
@@ -1,0 +1,6 @@
+-- Copyright 2023 Lennart Augustsson
+-- See LICENSE file for full license.
+module Data.Constraint(module Data.Constraint) where
+-- A very, very minimal version of the constraints package
+
+data Dict (c :: Constraint) = c => Dict
--- a/src/MicroHs/Main.hs
+++ b/src/MicroHs/Main.hs
@@ -27,7 +27,7 @@
combVersion = "v5.1\n"
mhsVersion :: String
-mhsVersion = "0.8.3.0"
+mhsVersion = "0.8.4.0"
main :: IO ()
main = do
--- /dev/null
+++ b/tests/Dict.hs
@@ -1,0 +1,15 @@
+module Dict(module Dict) where
+import Prelude
+import Data.Constraint
+
+fac :: forall a . (Num a, Eq a) => a -> a
+fac n = if n == 0 then 1 else n * fac(n - 1)
+
+facD :: forall a . Dict (Num a, Eq a) -> a -> a
+facD Dict = fac
+
+dictInt :: Dict (Num Int, Eq Int)
+dictInt = Dict
+
+main :: IO ()
+main = print $ facD dictInt 10
--- /dev/null
+++ b/tests/Dict.ref
@@ -1,0 +1,1 @@
+3628800
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -33,6 +33,7 @@
$(MHS) Exists && $(EVAL) > Exists.out && diff Exists.ref Exists.out
$(MHS) TypeEq && $(EVAL) > TypeEq.out && diff TypeEq.ref TypeEq.out
$(MHS) Sieve && $(EVAL) > Sieve.out && diff Sieve.ref Sieve.out
+ $(MHS) Dict && $(EVAL) > Dict.out && diff Dict.ref Dict.out
errtest:
sh errtester.sh < errmsg.test
--
⑨