Skip to content

Commit

Permalink
switched to Common.Doc.Pretty
Browse files Browse the repository at this point in the history
git-svn-id: https://svn-agbkb.informatik.uni-bremen.de/Hets/trunk@6181 cec4b9c1-7d33-0410-9eda-942365e851bb
  • Loading branch information
Christian Maeder authored and Christian Maeder committed Apr 7, 2006
1 parent a4794e5 commit 5a13581
Show file tree
Hide file tree
Showing 48 changed files with 1,848 additions and 1,909 deletions.
1 change: 0 additions & 1 deletion Comorphisms/HasCASL2IsabelleHOL.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import qualified Common.Lib.Map as Map
import Data.List
import Data.Maybe
import Common.AS_Annotation (Named(..))
import Common.PrettyPrint

-- HasCASL
import HasCASL.Logic_HasCASL
Expand Down
17 changes: 2 additions & 15 deletions HasCASL/As.der.hs
Original file line number Diff line number Diff line change
Expand Up @@ -215,23 +215,10 @@ data Component = Selector UninstOpId Partiality Type SeparatorKind Range

-- | the possible quantifiers
data Quantifier = Universal | Existential | Unique
deriving (Eq, Ord)

instance Show Quantifier where
show q = case q of
Universal -> forallS
Existential -> existsS
Unique -> existsUnique
deriving (Eq, Ord, Show)

-- | the possibly type annotations of terms
data TypeQual = OfType | AsType | InType | Inferred deriving (Eq, Ord)

instance Show TypeQual where
show q = case q of
OfType -> colonS
AsType -> asS
InType -> inS
Inferred -> colonS
data TypeQual = OfType | AsType | InType | Inferred deriving (Eq, Ord, Show)

-- | an indicator of (otherwise equivalent) let or where equations
data LetBrand = Let | Where | Program deriving (Show, Eq, Ord)
Expand Down
12 changes: 10 additions & 2 deletions HasCASL/AsUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ module HasCASL.AsUtils where
import HasCASL.As
import Common.Id
import Common.Keywords
import Common.PrettyPrint
import Common.Doc
import qualified Common.Lib.Pretty as Pretty
import Common.GlobalAnnotations
import qualified Common.Lib.Set as Set

-- | the string for the universe type
Expand Down Expand Up @@ -304,8 +306,14 @@ toKind vk = case vk of
_ -> error "toKind: Downset"
MissingKind -> error "toKind: Missing"

showPretty :: Pretty a => a -> ShowS
showPretty = shows . toOldDoc . pretty

toOldDoc :: Doc -> Pretty.Doc
toOldDoc = toText emptyGlobalAnnos

-- | generate a comparison string
expected :: PrettyPrint a => a -> a -> String
expected :: Pretty a => a -> a -> String
expected a b =
"\n expected: " ++ showPretty a
"\n found: " ++ showPretty b "\n"
Expand Down
6 changes: 3 additions & 3 deletions HasCASL/ClassAna.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import HasCASL.AsUtils
import HasCASL.PrintAs()
import Common.Id
import HasCASL.Le
import Common.PrettyPrint
import qualified Common.Lib.Map as Map
import Common.Lib.State
import Common.Result
import Common.Doc

-- * analyse kinds

Expand Down Expand Up @@ -104,15 +104,15 @@ invertVariance v = case v of
-- * diagnostic messages

-- | create message for different kinds
diffKindDiag :: (PosItem a, PrettyPrint a) =>
diffKindDiag :: (PosItem a, Pretty a) =>
a -> RawKind -> RawKind -> [Diagnosis]
diffKindDiag a k1 k2 =
[ Diag Error
("incompatible kind of: " ++ showPretty a "" ++ expected k1 k2)
$ getRange a ]

-- | check if raw kinds are equal
checkKinds :: (PosItem a, PrettyPrint a) =>
checkKinds :: (PosItem a, Pretty a) =>
a -> RawKind -> RawKind -> [Diagnosis]
checkKinds p k1 k2 =
if k1 == k2 then []
Expand Down
28 changes: 14 additions & 14 deletions HasCASL/Constrain.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Stability : experimental
Portability : portable
constraint resolution
-}

module HasCASL.Constrain where
Expand All @@ -24,11 +23,10 @@ import qualified Common.Lib.Set as Set
import qualified Common.Lib.Map as Map
import qualified Common.Lib.Rel as Rel
import Common.Lib.State
import Common.PrettyPrint
import Common.Lib.Pretty
import Common.Keywords
import qualified Common.PrettyPrint as PP
import Common.Id
import Common.Result
import Common.Doc

import Control.Exception(assert)

Expand All @@ -39,12 +37,13 @@ data Constrain = Kinding Type Kind
| Subtyping Type Type
deriving (Eq, Ord, Show)

instance PrettyPrint Constrain where
printText0 ga c = case c of
Kinding ty k -> printText0 ga ty <+> colon
<+> printText0 ga k
Subtyping t1 t2 -> printText0 ga t1 <+> text lessS
<+> printText0 ga t2
instance PP.PrettyPrint Constrain where
printText0 ga = toText ga . pretty

instance Pretty Constrain where
pretty c = case c of
Kinding ty k -> fsep [pretty ty, colon, pretty k]
Subtyping t1 t2 -> fsep [pretty t1, less, pretty t2]

instance PosItem Constrain where
getRange c = case c of
Expand Down Expand Up @@ -86,7 +85,8 @@ entail te p =

byInst :: Monad m => TypeEnv -> Constrain -> m Constraints
byInst te c = let cm = classMap te in case c of
Kinding ty k -> if k == universe then assert (rawKindOfType ty == ClassKind ())
Kinding ty k -> if k == universe then
assert (rawKindOfType ty == ClassKind ())
$ return noC else
let Result _ds mk = inferKinds (Just True) ty te in
case mk of
Expand All @@ -97,7 +97,8 @@ byInst te c = let cm = classMap te in case c of
else fail $ "constrain '" ++
showPretty c "' is unprovable"
++ "\n known kinds are: " ++
showPretty ks ""
concat (intersperse ", " $
map (flip showPretty "") ks)
Subtyping t1 t2 -> if lesserType te t1 t2 then return noC
else fail ("unable to prove: " ++ showPretty t1 " < "
++ showPretty t2 "")
Expand Down Expand Up @@ -326,5 +327,4 @@ fromTypeMap :: TypeMap -> Rel.Rel Type
fromTypeMap = Map.foldWithKey (\ t ti r -> let k = typeKind ti in
Set.fold ( \ j -> Rel.insert (TypeName t k 0)
$ TypeName j k 0) r
$ superTypes ti) Rel.empty

$ superTypes ti) Rel.empty
1 change: 0 additions & 1 deletion HasCASL/Logic_HasCASL.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import HasCASL.Symbol
import HasCASL.ParseItem
import HasCASL.Morphism
import HasCASL.ATC_HasCASL()
import HasCASL.LaTeX_HasCASL()
import HasCASL.SymbolMapAnalysis
import HasCASL.Sublogic
import HasCASL.SimplifyTerm
Expand Down
12 changes: 6 additions & 6 deletions HasCASL/Merge.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ merging parts of local environment
module HasCASL.Merge where

import Common.Id
import Common.PrettyPrint
import Common.Doc
import Common.Result

import HasCASL.As
Expand All @@ -34,17 +34,17 @@ import Data.List
class Mergeable a where
merge :: a -> a -> Result a

instance (Ord a, PosItem a, PrettyPrint a, Mergeable b)
instance (Ord a, PosItem a, Pretty a, Mergeable b)
=> Mergeable (Map.Map a b) where
merge = mergeMap id merge

improveDiag :: (PosItem a, PrettyPrint a) => a -> Diagnosis -> Diagnosis
improveDiag :: (PosItem a, Pretty a) => a -> Diagnosis -> Diagnosis
improveDiag v d = d { diagString = let f:l = lines $ diagString d in
unlines $ (f ++ " of '" ++ showPretty v "'") : l
, diagPos = getRange v
}

mergeMap :: (Ord a, PosItem a, PrettyPrint a) =>
mergeMap :: (Ord a, PosItem a, Pretty a) =>
(b -> b) -> (b -> b -> Result b)
-> Map.Map a b -> Map.Map a b -> Result (Map.Map a b)
mergeMap e f m1 m2 = foldM ( \ m (k, v) ->
Expand All @@ -69,7 +69,7 @@ instance Mergeable a => Mergeable (Maybe a) where
instance Mergeable ClassInfo where
merge = mergeA "super classes"

instance (PrettyPrint a, Eq a) => Mergeable (AnyKind a) where
instance (Pretty a, Eq a) => Mergeable (AnyKind a) where
merge = mergeA "super kinds"

mergeTypeInfo :: TypeInfo -> TypeInfo -> Result TypeInfo
Expand Down Expand Up @@ -191,7 +191,7 @@ instance Mergeable Env where
, typeMap = tMap
, assumps = as }

mergeA :: (PrettyPrint a, Eq a) => String -> a -> a -> Result a
mergeA :: (Pretty a, Eq a) => String -> a -> a -> Result a
mergeA str t1 t2 = if t1 == t2 then return t1 else
fail ("different " ++ str ++ expected t1 t2)

Expand Down
4 changes: 2 additions & 2 deletions HasCASL/MixAna.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import qualified Common.Lib.Set as Set

import HasCASL.As
import HasCASL.AsUtils
import HasCASL.PrintAs
import HasCASL.PrintAs()
import HasCASL.Unify
import HasCASL.VarDecl
import HasCASL.Le
Expand Down Expand Up @@ -202,7 +202,7 @@ resolver isPat ga trm =
$ Set.union (Rel.keysSet ass) $ Rel.keysSet vs
chart <- iterateCharts ga [trm] $ initChart addRule ruleS
let Result ds mr = getResolved
(shows . printTerm emptyGlobalAnnos . parenTerm) (getRange trm)
(showPretty . parenTerm) (getRange trm)
toMixTerm chart
addDiags ds
if isPat then case mr of
Expand Down
Loading

0 comments on commit 5a13581

Please sign in to comment.