Skip to content

Commit 6bb436a

Browse files
committed
Fix examples/set.gr
1 parent 83bee7d commit 6bb436a

File tree

4 files changed

+31
-9
lines changed

4 files changed

+31
-9
lines changed

examples/set.gr

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,4 @@ example =
1616
[contacts] : (List String) [{Contacts}] = getContacts
1717
in [Cons location contacts]
1818

19-
non-example : (List String) [{Contacts}]
20-
non-example =
21-
let [location] : String [{Location}] = getLocation;
22-
[contacts] : (List String) [{Contacts}] = getContacts
23-
in [Cons location contacts]
19+
-- see frontend/tests/cases/negative/simple/set.gr for a failing example

frontend/src/Language/Granule/Checker/Constraints/SymbolicGrades.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ import Language.Granule.Checker.Constraints.SynTree
1111
import Language.Granule.Syntax.Type
1212

1313
import GHC.Generics (Generic)
14+
import GHC.Stack (HasCallStack)
1415
import Data.SBV hiding (kindOf, name, symbolic)
1516
import qualified Data.SBV.Set as S
1617

17-
solverError :: String -> a
18+
solverError :: HasCallStack => String -> a
1819
solverError = error
1920

2021
-- Symbolic grades, for coeffects and indices

frontend/src/Language/Granule/Checker/Kinding.hs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,14 @@ synthKindWithConfiguration s config (TyApp (TyCon (internalName -> "Set")) t) =
317317
-- otherwise kind of the set depends on the kind of the elements
318318
k -> return (k, subst, TyApp (TyCon (mkId "Set")) t')
319319

320+
synthKindWithConfiguration s config (TyApp (TyCon (internalName -> "SetOp")) t) = do
321+
(k, subst, t') <- synthKindWithConfiguration s config t
322+
case k of
323+
-- For set over type, default to the kind being Effect
324+
Type 0 -> return (keffect, subst, TyApp (TyCon (mkId "SetOp")) t')
325+
-- otherwise kind of the set depends on the kind of the elements
326+
k -> return (k, subst, TyApp (TyCon (mkId "SetOp")) t')
327+
320328
-- KChkS_app
321329
--
322330
-- t1 => k1 -> k2 t2 <= k1
@@ -1298,9 +1306,9 @@ requiresSolver s ty = do
12981306
Right _ ->
12991307
-- avoid putting sets into the solver as the solver is weak on this
13001308
-- TODO: consider something better here
1301-
case isSet ty of
1302-
Just _ -> putChecker >> return False
1303-
Nothing ->
1309+
-- case isSet ty of
1310+
-- Just _ -> putChecker >> return False
1311+
-- Nothing ->
13041312
putChecker >> return True
13051313

13061314
instance Unifiable Substitutors where
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
language GradedBase
2+
3+
data List a = Cons a (List a) | Nil
4+
5+
data Privilege = Camera | Contacts | Location | Microphone
6+
7+
getLocation : String [{Location}]
8+
getLocation = ["051.28°N 001.08°E"]
9+
10+
getContacts : (List String) [{Contacts}]
11+
getContacts = [Cons "Alice" (Cons "Bob" (Cons "Carol" Nil))]
12+
13+
non-example : (List String) [{Contacts}]
14+
non-example =
15+
let [location] : String [{Location}] = getLocation;
16+
[contacts] : (List String) [{Contacts}] = getContacts
17+
in [Cons location contacts]

0 commit comments

Comments
 (0)