Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split records of SymbolT and DefinitionS #384

Open
wants to merge 95 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
c5fd565
Split constructors of DefinitionS to individual data types
matil019 Jan 13, 2019
f577108
Add instance Alt Maybe
matil019 Oct 21, 2019
c4dfb23
[norun] Change SymbolT.SymT to an independent data type
matil019 Oct 17, 2019
73d651a
[nocompile] Change all of SymbolT constructors to independent types
matil019 Oct 17, 2019
504e178
Isolate all of SymbolT data constructors
matil019 Oct 21, 2019
e9fd748
Add instance Nice for SymT, SymL, etc.
matil019 Oct 19, 2019
1b872dc
Modify findV to return SymV, same for other Sym?s
matil019 Oct 19, 2019
7803c9e
Change the return type of patLocal, mkLocal, vSym to SymV
matil019 Oct 19, 2019
5a0459a
Remuve uses of unsafePartialView from frege.compiler.Kinds
matil019 Oct 19, 2019
f83552d
Reduce warnings on frege.tools.doc.Utilities
matil019 Oct 19, 2019
8c03d3f
Remove uses of unsafePartialView from frege.compiler.passes.Imp
matil019 Oct 19, 2019
596b2e0
Reduce uses of partial functions in frege.ide.Utilities
matil019 Oct 19, 2019
a4cb129
Remove redundant cases in frege.compiler.gen.java.Common
matil019 Oct 19, 2019
d9c176b
Change the return type of envConstructors to [SymD Global]
matil019 Oct 19, 2019
d8ce200
Remove uses of partial functions in frege.compiler.passes.Instances
matil019 Oct 19, 2019
6f2e5a4
Remove some of partial functions in frege.compiler.Classes
matil019 Oct 19, 2019
efac3c0
Remove a dead case in frege.compiler.gen.java.InstanceCode
matil019 Oct 19, 2019
727656c
Remove a dead case in frege.compiler.gen.java.DataCode
matil019 Oct 19, 2019
9caad72
Remove some partial functions and dead cases in frege.c.g.j.VarCode
matil019 Oct 19, 2019
81e2594
Remove partial functions in frege.compiler.gen.java.Match
matil019 Oct 19, 2019
56e7ac8
Change the return type of allourvars and allvars to [SymV Global]
matil019 Oct 19, 2019
fb417c4
Change fundep to take SymV
matil019 Oct 19, 2019
f0b8d1c
Change ccSym to take SymV
matil019 Oct 19, 2019
8bef123
Change the type of Global.locals to TreeMap Int (SymV Global)
matil019 Oct 19, 2019
7809062
Remove some partial functions in frege.compiler.passes.Transdef
matil019 Oct 19, 2019
daf9a49
Add instance Ord for SymT, SymL, etc.
matil019 Oct 19, 2019
a316f7a
Remove dead cases and partial functions from f.c.passes.LetUnroll
matil019 Oct 19, 2019
2c7fad5
Remove some partial functions and dead cases in frege.compiler.Typecheck
matil019 Oct 19, 2019
81a68d2
Remove partial functions in frege.compiler.GenMeta
matil019 Oct 19, 2019
d1cbfc0
Remove unused imports
matil019 Oct 19, 2019
03611c1
Assume main is SymV in frege.compiler.passes.GenCode
matil019 Oct 21, 2019
4777ba6
[prototype] Make insertSym and updateSym polymorphic
matil019 Oct 21, 2019
e0d5f1e
Add Prism
matil019 Oct 22, 2019
f95bcb3
Add prisms for SymbolT
matil019 Oct 22, 2019
cdcb6db
Introduce SymVal to constrain the return type of findVD
matil019 Oct 23, 2019
86364a5
Modify Classes.implemented to take SymVal
matil019 Oct 23, 2019
63a8efc
Remove a non-exhaustive case from passC.mkanno
matil019 Oct 23, 2019
43de55b
Remove unsafeToSymC from passC.methodcheck
matil019 Oct 23, 2019
eaaae98
Remove a redundant pattern of tcInstMethod
matil019 Oct 23, 2019
a3f51fd
Assume tcInstMethod takes either SymV or SymL
matil019 Oct 23, 2019
037f1a8
Change the type of SymI.env to SymMeth
matil019 Oct 23, 2019
58b9af7
Change the return type of classMethodOfInstMethod to SymV
matil019 Oct 24, 2019
e16d177
Modify strictReturn to return SymVal
matil019 Oct 24, 2019
cab842a
Add findMain, specialized to find the main function
matil019 Oct 24, 2019
e31e3d2
Use SymVal in substInst
matil019 Oct 24, 2019
23933ec
Use SymV in rHas
matil019 Oct 24, 2019
aaf425d
Modify passC.methodcheck to take SymMeth
matil019 Oct 24, 2019
1fdcc0c
Assume SymV in isEasy.Let
matil019 Oct 24, 2019
d698fae
Assume SymV in etaExpand.cleanVarType
matil019 Oct 24, 2019
17905bd
Change the type of Global.genEnv to [SymV Global]
matil019 Oct 24, 2019
e868594
Assume the return type of instTSym and instTauSym to be SymT
matil019 Oct 24, 2019
c973f5c
Modify methCode and related functions to take SymV
matil019 Oct 24, 2019
38021a1
Modify wrapIRMethod to take SymVal
matil019 Oct 24, 2019
379359c
Remove use of unsafePartialView in symWarning
matil019 Oct 24, 2019
1d5d778
Modify arity to take SymVal
matil019 Oct 24, 2019
f3992b8
Add a custom partial conversion SymbolT -> SymV in SymbolTable
matil019 Oct 24, 2019
599465c
Remove use of unsafePartialView in docWarningSym
matil019 Oct 24, 2019
1f5afaf
Remove uses of unsafePartialView from passes.Final
matil019 Oct 25, 2019
59847a3
Ignore missing SymbolT.env' in resolve3
matil019 Oct 25, 2019
f3f0c3a
Ignore missing SymbolT.env' in enter1ClaDcl
matil019 Oct 25, 2019
749d6cc
Remove uses of unsafePartialView in Transdef
matil019 Oct 25, 2019
1a8fade
Move a common part in SymbolTable to a new function
matil019 Oct 28, 2019
3ac3df8
Change the type of SymC.env to SymMeth
matil019 Oct 26, 2019
cdd5ba1
Replace a partial function in InstanceCode with a new error message
matil019 Oct 30, 2019
eba6356
View SymMeth as SymV in InstanceCode to reduce unsafePartialView
matil019 Oct 30, 2019
5634a4f
Treat non-SymV as non-existent in Transdef.ordInfix
matil019 Oct 30, 2019
1df0181
Remove a "may evaluate to false" warning in Classes.tcInstMethod
matil019 Oct 30, 2019
61f2681
Remove uses of unsafePartialView in Classes
matil019 Oct 30, 2019
6a60400
Remove an unused import in Final to avoid warnings
matil019 Oct 30, 2019
c4c7736
Remove uses of partial matches in VarCode
matil019 Oct 30, 2019
3b9cefb
Add a custom partial function in InstanceCode
matil019 Oct 30, 2019
da7ebcf
Add a custom partial function in Global
matil019 Oct 30, 2019
9effb28
Add an error message to the new error in SymbolTable
matil019 Oct 30, 2019
a9b0fa2
Add a copy of unsafePartialView to MethodCall
matil019 Oct 30, 2019
afca4ce
Remove uses of partial matches in doc.Utility
matil019 Oct 30, 2019
a42eca7
Remove uses of partial functions in tools.Doc
matil019 Oct 30, 2019
e7908e5
Remove uses of partial matches in ide.Utilities
matil019 Oct 30, 2019
e01d94c
Change SymbolTable.InsUpd to protected
matil019 Oct 30, 2019
4b83084
Make constructors of SymbolT, SymMeth and SymVal strict
matil019 Oct 30, 2019
e6f82dd
Clean unused imports
matil019 Oct 30, 2019
46e2e2f
Replace 'view'ing lenses with simple getters
matil019 Oct 30, 2019
750cc61
Remove Prisms and use Traversals instead
matil019 Oct 30, 2019
98d630e
Replace 'view'ing lenses with simple getters for SymMeth and SymVal
matil019 Oct 30, 2019
2709dab
Change the type of allClasses to StG [SymC Global]
matil019 Oct 30, 2019
d39551c
Remove Utilities.symVD
matil019 Oct 31, 2019
a501df7
Modify Desugar.updVis not to throw an error
matil019 Oct 31, 2019
cfa58ac
Change unAlias.aliases to return [SymA Global]
matil019 Oct 31, 2019
1ac6dad
Change isHigherKindedClass to take SymC
matil019 Oct 31, 2019
389b789
Change DataCode.subDecls to take SymT
matil019 Oct 31, 2019
49e0ca1
Add instance Ord for SymVal and SymMeth
matil019 Oct 31, 2019
8ec97a2
Change symInfo to take SymVal
matil019 Oct 31, 2019
1952d83
Remove redundant parameter from match.matchEnum
matil019 Oct 31, 2019
d39d409
Restrict parameter type of dataCode, classCode and instanceCode
matil019 Oct 31, 2019
b2fec3f
Change transDatDcl.newtCheck to take SymT
matil019 Oct 31, 2019
11bdb3f
Clean up the code
matil019 Oct 31, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
315 changes: 146 additions & 169 deletions frege/compiler/Classes.fr

Large diffs are not rendered by default.

117 changes: 60 additions & 57 deletions frege/compiler/GenMeta.fr
Original file line number Diff line number Diff line change
Expand Up @@ -141,21 +141,21 @@ genmeta = do

-- let ops = [ mkOp (s,x) | (s,x) <- each g.optab, x >= LOP0 ]

let asyms = [sym | sym@SymA {pos} <- values g.thisTab, sym.vis!=Private]
let asyms = [sym | SymbolT.A sym <- values g.thisTab, sym.vis!=Private]
symas <- liftStG $ mapSt annoSymA asyms


let csyms = [sym | sym@SymC {pos} <- values g.thisTab, sym.vis!=Private]
let csyms = [sym | SymbolT.C sym <- values g.thisTab, sym.vis!=Private]
symcs <- liftStG $ mapSt annoSymC csyms

let isyms = [sym | sym@SymI {pos} <- values g.thisTab, sym.vis!=Private]
let isyms = [sym | SymbolT.I sym <- values g.thisTab, sym.vis!=Private]
symis <- liftStG $ mapSt annoSymI isyms

let tsyms = [sym | sym@SymT {pos} <- values g.thisTab, sym.vis!=Private]
let tsyms = [sym | SymbolT.T sym <- values g.thisTab, sym.vis!=Private]
symts <- liftStG $ mapSt annoSymT tsyms

symvs <- liftStG $ envValues g.thisTab
symls <- liftStG $ envLinks g.thisTab
symvs <- liftStG $ envValues $ values g.thisTab
symls <- liftStG $ envLinks $ values g.thisTab

g <- getSTT
ctime <- liftIO (System.currentTimeMillis())
Expand Down Expand Up @@ -200,23 +200,23 @@ genmeta = do


--- create annotations for all SymV in an environment
envValues :: Symtab -> StG [DOCUMENT]
envValues env = do
let vsyms = [sym | sym@SymV {pos} <- values env, sym.vis != Private]
envValues :: [Symbol] -> StG [DOCUMENT]
envValues envsyms = do
let vsyms = [sym | SymbolT.V sym <- envsyms, sym.vis != Private]
symvs <- mapSt annoSymV vsyms
stio symvs

--- create annotations for all SymL in an environment
envLinks :: Symtab -> StG [DOCUMENT]
envLinks env = do
envLinks :: [Symbol] -> StG [DOCUMENT]
envLinks envsyms = do
g <- getST
let syms = [ sym | sym@SymL {alias} <- values env, sym.vis != Private]
let syms = [ sym | SymbolT.L sym <- envsyms, sym.vis != Private]
mapM annoSymL syms

--- create annotations for all SymD in an environment
envCons :: Symtab -> StG [DOCUMENT]
envCons env = do
let syms = [sym | sym@SymD {pos} <- values env]
envCons :: [Symbol] -> StG [DOCUMENT]
envCons envsyms = do
let syms = [sym | SymbolT.D sym <- envsyms]
mapSt annoSymD syms


Expand Down Expand Up @@ -429,9 +429,9 @@ expIndex exp = encodeX exp >>= mbIndex
-- the list of symbols corresponding to the let bound names
syms ← mapM U.findV env
-- make (and encode) the list of sigmas
sigs ← mapM (\s -> if Symbol.anno s then sigIndex s.typ else return (-1)) syms
sigs ← mapM (\s -> if SymV.anno s then sigIndex s.typ else return (-1)) syms
-- make and encode the list of expressions
exps ← mapM (maybe (return 0) (>>=expIndex) . Symbol.expr) syms
exps ← mapM (maybe (return 0) (>>=expIndex) . _.expr) syms
exp ← expIndex ex
if exp == 0 || any (<1) exps || any (<1) qexs
then return Nothing
Expand Down Expand Up @@ -503,33 +503,35 @@ eaIndex expa = do
changeST Global.{gen <- GenSt.{xunique <- (1+)} • GenSt.{xTree <- insert expa g.xunique}}
stio g.xunique

annoSymA :: SymA Global -> StG DOCUMENT
annoSymA syma = do
g ← getST
vars <- mapSt tauIndex (Symbol.vars syma)
typ <- sigIndex (Symbol.typ syma)
vars <- mapSt tauIndex syma.vars
typ <- sigIndex syma.typ
kind <- kindIndex syma.kind
let a = meta g "SymA" [
("offset", anno syma.pos.first.offset),
("name", annoG g (Symbol.name syma)),
("name", annoG g syma.name),
("vars", anno vars),
("typ", anno typ),
("kind", anno kind),
("publik", if syma.vis == Public then PP.nil else anno false),
("doc", maybe PP.nil anno (Symbol.doc syma))
("doc", maybe PP.nil anno syma.doc)
]
stio a

annoSymV :: SymV Global -> StG DOCUMENT
annoSymV symv = do
g <- getST
gargs ← mapM tauIndex symv.gargs
case isPSigma (Symbol.typ symv) of
case isPSigma symv.typ of
true -> E.fatal symv.pos (text (symv.nice g ++ " has no type."))
false -> do
sig <- sigIndex (Symbol.typ symv)
sig <- sigIndex symv.typ
-- inline candidates must be safe tail calls and no loops
let !classop
| MName tname _ <- symv.name,
Just SymC{} <- g.find tname = isJust symv.expr -- this is a class member
Just (SymbolT.C _) <- g.find tname = isJust symv.expr -- this is a class member
| otherwise = false
!candidate = classop || symv.exported
-- U.logmsg TRACE9 symv.pos (text ((nicer symv g)
Expand Down Expand Up @@ -580,32 +582,30 @@ annoSymV symv = do
changeST Global.{gen <- _.{expSym <- insert symv.name exp}}
stio a

annoSymL :: SymL Global -> StG DOCUMENT
annoSymL sym = do
g ← getST
pure $ meta g "SymL" [
("offset", anno (Symbol.pos sym).first.offset),
("name", annoG g (Symbol.name sym)),
("alias", annoG g (Symbol.alias sym)),
("offset", anno sym.pos.first.offset),
("name", annoG g sym.name),
("alias", annoG g sym.alias),
("publik", if sym.vis == Public then PP.nil else anno false),
-- ("doc", maybe PP.nil anno (Symbol.doc sym))
]

annoSymD :: SymD Global -> StG DOCUMENT
annoSymD sym = do
g <- getST
typ <- sigIndex (Symbol.typ sym)
typ <- sigIndex sym.typ
fields <- mapSt conFieldA sym.flds
let a = meta g "SymD" [
("offset", anno (Symbol.pos sym).first.offset),
("name", annoG g (Symbol.name sym)),
-- ("stri", lit sym.strsig.show),
("cid", anno (Symbol.cid sym)),
("offset", anno sym.pos.first.offset),
("name", annoG g sym.name),
("cid", anno sym.cid),
("typ", anno typ),
("fields", annoListG g fields),
-- ("fnms", if null fnms || all null fnms then PP.nil else anno fnms),
-- ("ftys", if null ftys then PP.nil else anno ftys),
("priv", if sym.vis == Private then anno true else PP.nil),
("publik", if sym.vis == Public then PP.nil else anno false),
("doc", maybe PP.nil anno (Symbol.doc sym)),
("doc", maybe PP.nil anno sym.doc),
("op", if sym.op == defaultInfix then PP.nil else anno (ord sym.op))]
stio a

Expand All @@ -626,50 +626,53 @@ instance AnnoG ConFieldA where
]


annoSymC :: SymC Global -> StG DOCUMENT
annoSymC sym = do
g ← getST
tau <- tauIndex (Symbol.tau sym)
meml <- envLinks (Symbol.env sym)
memv <- envValues (Symbol.env sym)
tau <- tauIndex sym.tau
meml <- envLinks $ map _.toSymbol $ values sym.meth
memv <- envValues $ map _.toSymbol $ values sym.meth
let a = meta g "SymC" [
("offset", anno (Symbol.pos sym).first.offset),
("name", annoG g (Symbol.name sym)),
("offset", anno sym.pos.first.offset),
("name", annoG g sym.name),
("tau", anno tau),
("sups", if null sym.supers then PP.nil else annoListG g sym.supers),
("ins1", if null sym.insts then PP.nil else annoListG g (map fst sym.insts)),
("ins2", if null sym.insts then PP.nil else annoListG g (map snd sym.insts)),
("lnks", some meml),
("funs", some memv),
("publik", if sym.vis == Public then PP.nil else anno false),
("doc", maybe PP.nil anno (Symbol.doc sym))]
("doc", maybe PP.nil anno sym.doc)]
stio a

annoSymI :: SymI Global -> StG DOCUMENT
annoSymI sym = do
g ← getST
typ <- sigIndex (Symbol.typ sym)
meml <- envLinks (Symbol.env sym)
memv <- envValues (Symbol.env sym)
typ <- sigIndex sym.typ
meml <- envLinks $ map _.toSymbol $ values sym.meth
memv <- envValues $ map _.toSymbol $ values sym.meth
let a = meta g "SymI" [
("offset", anno (Symbol.pos sym).first.offset),
("name", annoG g (Symbol.name sym)),
("clas", annoG g (Symbol.clas sym)),
("offset", anno sym.pos.first.offset),
("name", annoG g sym.name),
("clas", annoG g sym.clas),
("typ", anno typ),
("lnks", some meml),
("funs", some memv),
("doc", maybe PP.nil anno (Symbol.doc sym))]
("doc", maybe PP.nil anno sym.doc)]
stio a

annoSymT :: SymT Global -> StG DOCUMENT
annoSymT sym = do
g ← getST
typ <- sigIndex (Symbol.typ sym)
memc <- envCons (Symbol.env sym)
meml <- envLinks (Symbol.env sym)
memv <- envValues (Symbol.env sym)
typ <- sigIndex sym.typ
memc <- envCons $ values sym.env
meml <- envLinks $ values sym.env
memv <- envValues $ values sym.env
kind <- kindIndex sym.kind
gargs ← mapM tauIndex sym.gargs
let a = meta g "SymT" [
("offset", anno (Symbol.pos sym).first.offset),
("name", annoG g (Symbol.name sym)),
("offset", anno sym.pos.first.offset),
("name", annoG g sym.name),
("typ", anno typ),
("kind", anno kind),
("cons", some memc),
Expand All @@ -679,8 +682,8 @@ annoSymT sym = do
("isEnum", if sym.enum then anno true else PP.nil),
("pur", if sym.pur then anno true else PP.nil),
("newt", if sym.newt then anno true else PP.nil),
("nativ", maybe PP.nil anno (Symbol.nativ sym)),
("nativ", maybe PP.nil anno sym.nativ),
("gargs", if null gargs then PP.nil else anno gargs),
("publik", if sym.vis == Public then PP.nil else anno false),
("doc", maybe PP.nil anno (Symbol.doc sym))]
("doc", maybe PP.nil anno sym.doc)]
pure a
5 changes: 3 additions & 2 deletions frege/compiler/Javatypes.fr
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ package frege.compiler.Javatypes where
import frege.compiler.Utilities as U()
import frege.lib.PP (text)

import Compiler.types.Symbols(SymbolT)
import Compiler.types.Positions(Position)
import Compiler.types.Global as G

Expand Down Expand Up @@ -106,8 +107,8 @@ findAllSupers name
Left l -> liftStG do
g <- getST
syms <- mapM U.findT (U.typesOfNativ name g)
let oss = filter (g.ourSym) syms
pos = if null oss then Position.null else (head oss).pos
let oss = filter (g.ourSym . SymbolT.T) syms
pos = if null oss then Position.null else (head oss).pos
E.error pos (text ("`" ++ name ++ "` is not a known java class"))
changeST Global.{javaEnv <- _.delete name}
Right c -> do
Expand Down
45 changes: 21 additions & 24 deletions frege/compiler/Kinds.fr
Original file line number Diff line number Diff line change
Expand Up @@ -71,47 +71,44 @@ kiTypes = do
g <- getST
let tsyms = typeSyms g
deps = map (typeDep g) tsyms
tdeps = zip (map Symbol.name tsyms) deps
tdeps = zip (map _.name tsyms) deps
groups = tsort tdeps
foreach groups kiTypeGroup
return ()

--- do kind inference on a group of types
kiTypeGroup qns = do
types <- mapM U.findT qns
let vartypes = filter (varKind . Symbol.kind) types -- with kinds that contain KVar
names = map Symbol.name vartypes
let vartypes = filter (varKind . SymT.kind) types -- with kinds that contain KVar
names = map SymT.name vartypes
foreach vartypes (kiTypeSym names)

-- refresh :: Symbol -> StG Symbol
-- refresh sym = getST >>= (return . unJust . sym.name.findit)



kiTypeSym :: [QName] -> Symbol -> StG ()
kiTypeSym :: [QName] -> SymT Global -> StG ()
kiTypeSym names sym = do
g <- getST
E.logmsg TRACEK (Symbol.pos sym) (text ("kind check for " ++ nice sym g))
E.logmsg TRACEK sym.pos (text ("kind check for " ++ nice sym g))
-- kind check all constructor sigmas
let cons = [ con | con@SymD{typ} <- values sym.env ]
let cons = [ con | SymbolT.D con <- values sym.env ]
foreach cons (kiConSym names)
g ← getST
sym U.findT sym.name
sym <- U.findT sym.name
let kflat (KApp k ks) = k : kflat ks
kflat ks = [ks]
typ = ForAll (zipWith Tau.{kind=} (sym.typ.bound) (kflat sym.kind)) sym.typ.rho
showbnds = text . joined " " . map (flip nice g)
changeSym sym.{typ}
E.logmsg TRACEK (Symbol.pos sym) (text "type is now ∀"
changeSym $ SymbolT.T sym.{typ}
E.logmsg TRACEK sym.pos (text "type is now ∀"
<+> showbnds typ.bound <+> text "." <+> text (nicer typ.rho g)
)


kiConSym :: [QName] -> SymD Global -> StG ()
kiConSym names con = do
g <- getST
E.logmsg TRACEK (Symbol.pos con) (text ("kind check for " ++ nice con g))
E.logmsg TRACEK con.pos (text ("kind check for " ++ nice con g))
(sigma,_) <- kiSigma names [] con.typ
changeSym con.{typ=sigma}
changeSym $ SymbolT.D con.{typ=sigma}

-- kind inference on a 'Sigma' type where something else than 'KType' is expected
kiSigmaX :: Sigma -> Kind -> StG (Sigma, Kind)
Expand Down Expand Up @@ -225,7 +222,7 @@ kiCtx names env Ctx{cname, tau} = do
KVar -> return env -- not yet kind checked
k -> do
(_, env) <- unifyTauKind names env tau k
return env
return env


type Envs = [TreeMap String Kind]
Expand Down Expand Up @@ -293,24 +290,24 @@ unifyTauKind names env (TVar{pos,var,kind}) exp = do
unifyTauKind names env (TCon{pos,name}) exp = do
g <- getST
sym <- U.findT name

E.logmsg TRACEK pos (text ("unifyTauKind: " ++ nice name g
++ " initial " ++ show sym.kind
++ " expected " ++ show exp))

case unifyKind sym.kind exp of
Just k -> do
when (! (k `keq` sym.kind) && sym.name `elem` names) do
changeSym sym.{kind=k}
changeSym $ SymbolT.T sym.{kind=k}
E.logmsg TRACEK pos (text ("unifyTauKind: " ++ nice name g ++ " result " ++ show k))
return (k, env)
Nothing -> do
g <- getST
E.error pos (text ("kind error, type constructor `" ++ name.nice g
E.error pos (text ("kind error, type constructor `" ++ name.nice g
++ "` has kind "
++ show sym.kind
++ ", expected was " ++ show exp))
return (sym.kind, env)
return (sym.kind, env)

-- TCon b ~ exp => check TCon for kb -> exp and b for kb
unifyTauKind names env (it@TApp a b) exp = do
Expand Down Expand Up @@ -409,7 +406,7 @@ varKind (KApp a b) = varKind a || varKind b
varKind _ = false

--- find the 'Sigmas' of all constructors of the given type 'Symbol'
conSigmas SymT{env} = [ typ | SymD{typ} <- values env ]
conSigmas (SymbolT.T SymT{env}) = [ typ | SymbolT.D SymD{typ} <- values env ]
conSigmas _ = []

--- give the direct dependencies of a type symbol
Expand All @@ -418,8 +415,8 @@ typeDep g = ourNames g . sigmasTCons . conSigmas
--- find our type symbols
typeSyms :: Global -> [Symbol]
typeSyms g = filter isOurT (values g.thisTab) where
isOurT SymT{name} = g.our name
isOurT _ = false
isOurT (SymbolT.T SymT{name}) = g.our name
isOurT _ = false

--- find all our 'QNames' from a 'OrdSet'
ourNames :: Global -> TreeMap QName β -> [QName]
Expand Down
Loading