Commit 1638122c authored by simonpj's avatar simonpj
Browse files

[project @ 2002-04-02 13:48:41 by simonpj]

Context-simplification loop tests
parent d8d8a65a
......@@ -103,3 +103,4 @@ test "tcfail102" { vtcf("") }
test "tcfail103" { vtcf("") }
test "tcfail104" { vtcf("") }
test "tcfail105" { vtcf("") }
test "tcfail106" { vtcf("") }
-- This one risked building a recursive dictionary rather than
-- failing, in GHC before 5.03. Actually, 5.02 managed it ok,
-- but I think more by luck than good judgement.
module ShouldFail where
class S a
class S a => C a where { opc :: a -> a }
class S b => D b where { opd :: b -> b }
instance C Int where
opc = opd
instance D Int where
opd = opc
tcfail106.hs:10:
No instance for (S Int)
arising from the instance declaration at tcfail106.hs:10
In the instance declaration for `C Int'
tcfail106.hs:13:
No instance for (S Int)
arising from the instance declaration at tcfail106.hs:13
In the instance declaration for `D Int'
......@@ -28,3 +28,4 @@ test "tcrun017" { vtr("", "", "") }
test "tcrun018" { vtr("", "", "") }
test "tcrun019" { vtr("", "", "") }
test "tcrun020" { vtr("", "", "") }
test "tcrun021" { vtr("-package data", "", "") }
{-# OPTIONS -fglasgow-exts #-}
-- This bizarre program failed because TcSimplify built a loop of
-- dictionaries, due to an obscure bug in the way in which superclasses
-- were added
module Main where
import List
import FiniteMap
class (Ord oid) => Object o oid | o -> oid where
data Access oid
class (Object o oid) => SecurityModel model o oid | model -> o
class (SecurityModel model o oid) => SecurityPolicy policy model o oid where
checkAccess :: policy -> model -> Access oid -> Bool
checkAccess _ _ _ = True
checkModel :: policy -> model -> Bool
checkModel _ _ = True
------------------------------------------------------------
-- The Linux instance
------------------------------------------------------------
type LinuxObjectId = Either [String] String
data LinuxObject = File [String] deriving (Eq, Show)
instance Object LinuxObject LinuxObjectId
data LinuxSecurityModel =
LinuxSecurityModel { lsmObjectSet :: FiniteMap LinuxObjectId LinuxObject }
instance (Show a, Show b) => Show (FiniteMap a b) where
show fm = show (fmToList fm)
instance Show LinuxSecurityModel where
show lsm = "LSM:" ++ "\tObjects: " ++ show (lsmObjectSet lsm)
instance SecurityModel LinuxSecurityModel LinuxObject LinuxObjectId
data LinuxSecurityPolicy = LinuxSecurityPolicy
instance SecurityPolicy LinuxSecurityPolicy LinuxSecurityModel LinuxObject LinuxObjectId
model :: FiniteMap LinuxObjectId LinuxObject
model = listToFM [ (Left [], File []), (Left ["home"], File ["home"]) ]
main :: IO ()
main = do { putStrLn (show model) }
[(Left [],File []),(Left ["home"],File ["home"])]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment