Skip to content

Commit

Permalink
Added type mismatch example
Browse files Browse the repository at this point in the history
  • Loading branch information
SophieBosio committed Mar 2, 2024
1 parent 9f7125c commit b1b6bd5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
11 changes: 11 additions & 0 deletions examples/errors/TypeMismatch.con
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
func :: Integer -> Boolean .
func x y = x + y .

adt IntList = Nil | Cons Integer IntList .

list :: IntList .
list = Const { True, Cons { False, Nil } } .


malformed :: IntList .
malformed = Const { True, Cons { False, Cons { Nil } } } .
29 changes: 15 additions & 14 deletions src/PropertyEngine.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ module PropertyEngine where
import Syntax
import PartialEvaluator (partiallyEvaluate)

import Control.Monad (foldM_)
import Control.Monad.Reader
import Data.SBV

Expand Down Expand Up @@ -53,21 +52,23 @@ generateFormula property = runReader (translate property) property


-- Constraint generation
translate :: Term Type -> Formula SBool
translate (Equal t0 t1 _) =
do t0' <- translate t0
t1' <- translate t1
return $ t0' .== t1'
translate (Lt t0 t1 _) =
do t0' <- translate t0
t1' <- translate t1
return $ t0' .< t1'
translate (Gt t0 t1 _) =
do t0' <- translate t0
t1' <- translate t1
return $ t0' .> t1'
-- translate :: Term Type -> Formula (SBV (Term Type))
-- translate (Equal t0 t1 _) =
-- do t0' <- translate t0
-- t1' <- translate t1
-- return $ t0' .== t1'
-- translate (Lt t0 t1 _) =
-- do t0' <- translate t0
-- t1' <- translate t1
-- return $ t0' .< t1'
-- translate (Gt t0 t1 _) =
-- do t0' <- translate t0
-- t1' <- translate t1
-- return $ t0' .> t1'
-- translate (Lambda x t0 a) =
-- translate (Application t1 t2 _) =
translate :: Term Type -> Formula (SBool)

Check warning on line 70 in src/PropertyEngine.hs

View workflow job for this annotation

GitHub Actions / hlint

Warning in translate in module PropertyEngine: Redundant bracket ▫︎ Found: "(SBool)" ▫︎ Perhaps: "SBool"
translate = undefined


-- Utility
Expand Down

0 comments on commit b1b6bd5

Please sign in to comment.