Verified Commit 4cf0b6c4 authored by Camil Staps's avatar Camil Staps 🚀

Combine all FunctionLocation, ClassLocation etc. into one Location

parent 43a0e806
...@@ -70,14 +70,14 @@ import Levenshtein ...@@ -70,14 +70,14 @@ import Levenshtein
} }
:: ClassResult :== (BasicResult, ClassResultExtras) :: ClassResult :== (BasicResult, ClassResultExtras)
:: ClassResultExtras = { class_name :: String :: ClassResultExtras = { class_name :: String
, class_heading :: String , class_heading :: String
, class_funs :: [String] , class_funs :: [String]
, class_instances :: [String] , class_instances :: [String]
} }
:: MacroResult :== (BasicResult, MacroResultExtras) :: MacroResult :== (BasicResult, MacroResultExtras)
:: MacroResultExtras = { macro_name :: String :: MacroResultExtras = { macro_name :: String
, macro_representation :: String , macro_representation :: String
} }
...@@ -114,9 +114,9 @@ where ...@@ -114,9 +114,9 @@ where
where where
basic :: Result -> BasicResult basic :: Result -> BasicResult
basic (FunctionResult (br,_)) = br basic (FunctionResult (br,_)) = br
basic (TypeResult (br,_)) = br basic (TypeResult (br,_)) = br
basic (ClassResult (br,_)) = br basic (ClassResult (br,_)) = br
basic (MacroResult (br,_)) = br basic (MacroResult (br,_)) = br
err :: Int String -> Response err :: Int String -> Response
err c m = { return = c err c m = { return = c
...@@ -126,12 +126,12 @@ err c m = { return = c ...@@ -126,12 +126,12 @@ err c m = { return = c
, suggestions = Nothing , suggestions = Nothing
} }
E_NORESULTS :== 127 E_NORESULTS :== 127
E_INVALIDINPUT :== 128 E_INVALIDINPUT :== 128
E_INVALIDNAME :== 129 E_INVALIDNAME :== 129
E_INVALIDTYPE :== 130 E_INVALIDTYPE :== 130
MAX_RESULTS :== 15 MAX_RESULTS :== 15
Start w Start w
# (io, w) = stdio w # (io, w) = stdio w
...@@ -203,45 +203,42 @@ where ...@@ -203,45 +203,42 @@ where
// Search normal functions // Search normal functions
# filts = catMaybes [ (\t _ -> isUnifiable t) <$> mbType # filts = catMaybes [ (\t _ -> isUnifiable t) <$> mbType
, (\n loc _ -> isNameMatch (size n-2) n loc) <$> name , (\n loc _ -> isNameMatch (size n-2) n loc) <$> name
, isModMatchF <$> modules , (\mods loc _ -> isModMatch mods loc) <$> modules
] ]
# funs = map (\f -> makeFunctionResult name mbType Nothing f db) $ findFunction`` filts db # funs = map (\f -> makeFunctionResult name mbType Nothing f db) $ findFunction`` filts db
// Search macros // Search macros
# macros = case name of # macros = case name of
Nothing = [] Nothing = []
(Just n) = findMacro` (\(ML lib mod m _) _ -> isNameMatch (size n-2) n (FL lib mod m Nothing)) db (Just n) = findMacro` (\loc _ -> isNameMatch (size n-2) n loc) db
# macros = map (\(lhs,rhs) -> makeMacroResult name lhs rhs) macros # macros = map (\(lhs,rhs) -> makeMacroResult name lhs rhs) macros
// Search class members // Search class members
# filts = catMaybes [ (\t _ _ _ _->isUnifiable t) <$> mbType # filts = catMaybes [ (\t _ _ _ _->isUnifiable t) <$> mbType
, (\n (CL lib mod _ _) _ _ f _ -> isNameMatch , (\n (Location lib mod _ _) _ _ f _ -> isNameMatch
(size n-2) n (FL lib mod f Nothing)) <$> name (size n-2) n (Location lib mod Nothing f)) <$> name
, isModMatchC <$> modules , (\mods loc _ _ _ _ -> isModMatch mods loc) <$> modules
] ]
# members = findClassMembers`` filts db # members = findClassMembers`` filts db
# members = map (\(CL lib mod cls line,vs,_,f,et) -> makeFunctionResult name mbType # members = map (\(Location lib mod line cls,vs,_,f,et) -> makeFunctionResult name mbType
(Just {cls_name=cls,cls_vars=vs}) (FL lib mod f line,et) db) members (Just {cls_name=cls,cls_vars=vs}) (Location lib mod line f,et) db) members
// Search types // Search types
# lcTypeName = if (isJust mbType && isType (fromJust mbType)) # lcName = if (isJust mbType && isType (fromJust mbType))
(let (Type name _) = fromJust mbType in Just $ toLowerCase name) (let (Type name _) = fromJust mbType in Just $ toLowerCase name)
(toLowerCase <$> name) (toLowerCase <$> name)
# types = case lcTypeName of # types = case lcName of
(Just n) = findType` (\tl _ -> toLowerCase (getName tl) == n) db (Just n) = findType` (\tl _ -> toLowerCase (getName tl) == n) db
Nothing = [] Nothing = []
# types = map (\(tl,td) -> makeTypeResult name tl td) types # types = map (\(tl,td) -> makeTypeResult name tl td) types
// Search classes // Search classes
# classes = case (isNothing mbType, toLowerCase <$> name) of # classes = case (isNothing mbType, toLowerCase <$> name) of
(True, Just c) = map (flip makeClassResult db) $ (True, Just c) = map (flip makeClassResult db) $
findClass` (\(CL _ _ c` _) _ _ _ -> toLowerCase c` == c) db findClass` (\(Location _ _ _ c`) _ _ _ -> toLowerCase c` == c) db
_ = [] _ = []
// Merge results // Merge results
= sort $ funs ++ members ++ types ++ classes ++ macros = sort $ funs ++ members ++ types ++ classes ++ macros
where
getName (TL _ _ t _) = t
getName (TL_Builtin t) = t
makeClassResult :: (ClassLocation, [TypeVar], ClassContext, [(FunctionName,ExtendedType)]) makeClassResult :: (Location, [TypeVar], ClassContext, [(Name,ExtendedType)])
TypeDB -> Result TypeDB -> Result
makeClassResult (CL lib mod cls line, vars, cc, funs) db makeClassResult (Location lib mod line cls, vars, cc, funs) db
= ClassResult = ClassResult
( { library = lib ( { library = lib
, filename = modToFilename mod , filename = modToFilename mod
...@@ -259,8 +256,8 @@ where ...@@ -259,8 +256,8 @@ where
} }
) )
makeTypeResult :: (Maybe String) TypeLocation TypeDef -> Result makeTypeResult :: (Maybe String) Location TypeDef -> Result
makeTypeResult mbName (TL lib mod t line) td makeTypeResult mbName (Location lib mod line t) td
= TypeResult = TypeResult
( { library = lib ( { library = lib
, filename = modToFilename mod , filename = modToFilename mod
...@@ -272,7 +269,7 @@ where ...@@ -272,7 +269,7 @@ where
} }
, { type = concat $ print False td } , { type = concat $ print False td }
) )
makeTypeResult mbName (TL_Builtin t) td makeTypeResult mbName (Builtin t) td
= TypeResult = TypeResult
( { library = "" ( { library = ""
, filename = "" , filename = ""
...@@ -285,8 +282,8 @@ where ...@@ -285,8 +282,8 @@ where
, { type = concat $ print False td } , { type = concat $ print False td }
) )
makeMacroResult :: (Maybe String) MacroLocation Macro -> Result makeMacroResult :: (Maybe String) Location Macro -> Result
makeMacroResult mbName (ML lib mod m line) mac makeMacroResult mbName (Location lib mod line m) mac
= MacroResult = MacroResult
( { library = lib ( { library = lib
, filename = modToFilename mod , filename = modToFilename mod
...@@ -302,7 +299,7 @@ where ...@@ -302,7 +299,7 @@ where
) )
makeFunctionResult :: (Maybe String) (Maybe Type) (Maybe ShortClassResult) makeFunctionResult :: (Maybe String) (Maybe Type) (Maybe ShortClassResult)
(FunctionLocation, ExtendedType) TypeDB -> Result (Location, ExtendedType) TypeDB -> Result
makeFunctionResult makeFunctionResult
orgsearch orgsearchtype mbCls (fl, et=:(ET type tes)) db orgsearch orgsearchtype mbCls (fl, et=:(ET type tes)) db
= FunctionResult = FunctionResult
...@@ -331,8 +328,8 @@ where ...@@ -331,8 +328,8 @@ where
) )
where where
(lib,mod,fname,line,builtin) = case fl of (lib,mod,fname,line,builtin) = case fl of
(FL l m f ln) = (l, m, f,ln, Nothing) (Location l m ln f) = (l, m, f, ln, Nothing)
(FL_Builtin f) = ("","",f,Nothing,Just True) (Builtin f) = ("", "", f, Nothing, Just True)
toStrUnifier :: Unifier -> StrUnifier toStrUnifier :: Unifier -> StrUnifier
toStrUnifier (tvas1, tvas2) = (map toStr tvas1, map toStr tvas2) toStrUnifier (tvas1, tvas2) = (map toStr tvas1, map toStr tvas2)
...@@ -368,21 +365,16 @@ where ...@@ -368,21 +365,16 @@ where
isUnifiable :: Type ExtendedType -> Bool isUnifiable :: Type ExtendedType -> Bool
isUnifiable t1 (ET t2 _) = isJust (unify [] t1 (prepare_unification False t2)) isUnifiable t1 (ET t2 _) = isJust (unify [] t1 (prepare_unification False t2))
isNameMatch :: !Int !String FunctionLocation -> Bool isNameMatch :: !Int !String Location -> Bool
isNameMatch maxdist n1 fl isNameMatch maxdist n1 loc
# (n1, n2) = ({toLower c \\ c <-: n1}, {toLower c \\ c <-: getName fl}) # (n1, n2) = ({toLower c \\ c <-: n1}, {toLower c \\ c <-: getName loc})
= n1 == "" || indexOf n1 n2 <> -1 || levenshtein n1 n2 <= maxdist = n1 == "" || indexOf n1 n2 <> -1 || levenshtein n1 n2 <= maxdist
where
getName (FL _ _ n _) = n; getName (FL_Builtin n) = n
isModMatchF :: ![String] FunctionLocation ExtendedType -> Bool
isModMatchF mods (FL _ mod _ _) _ = isMember mod mods
isModMatchC :: ![String] ClassLocation [TypeVar] ClassContext FunctionName ExtendedType -> Bool isModMatch :: ![String] Location -> Bool
isModMatchC mods (CL _ mod _ _) _ _ _ _ = isMember mod mods isModMatch mods (Location _ mod _ _) = isMember mod mods
log :: (LogMessage (Maybe Request) Response) IPAddress *World log :: (LogMessage (Maybe Request) Response) IPAddress *World
-> *(IPAddress, *World) -> *(IPAddress, *World)
log msg s w log msg s w
| not needslog = (newS msg s, w) | not needslog = (newS msg s, w)
# (tm,w) = localTime w # (tm,w) = localTime w
......
...@@ -29,20 +29,13 @@ from Type import ::Type, ::TypeVar, ::TVAssignment, ::TypeDef, class print(..), ...@@ -29,20 +29,13 @@ from Type import ::Type, ::TypeVar, ::TVAssignment, ::TypeDef, class print(..),
, macro_extras :: TypeExtras , macro_extras :: TypeExtras
} }
:: FunctionLocation = FL Library Module FunctionName LineNr :: Location = Location Library Module LineNr Name
| FL_Builtin FunctionName | Builtin Name
:: MacroLocation = ML Library Module MacroName LineNr
:: ClassLocation = CL Library Module Class LineNr
:: TypeLocation = TL Library Module TypeName LineNr
| TL_Builtin TypeName
:: Name :== String
:: Library :== String :: Library :== String
:: Module :== String :: Module :== String
:: FunctionName :== String
:: MacroName :== String
:: Class :== String :: Class :== String
:: GenericName :== String
:: TypeName :== String
:: LineNr :== Maybe Int :: LineNr :== Maybe Int
derive gEq TypeDB derive gEq TypeDB
...@@ -51,52 +44,53 @@ instance zero TypeDB ...@@ -51,52 +44,53 @@ instance zero TypeDB
instance zero TypeExtras instance zero TypeExtras
instance print TE_Priority instance print TE_Priority
instance print (FunctionName, ExtendedType) instance print (Name, ExtendedType)
getFunction :: FunctionLocation TypeDB -> Maybe ExtendedType getName :: Location -> Name
putFunction :: FunctionLocation ExtendedType TypeDB -> TypeDB
putFunctions :: [(FunctionLocation, ExtendedType)] TypeDB -> TypeDB getFunction :: Location TypeDB -> Maybe ExtendedType
findFunction :: FunctionName TypeDB -> [(FunctionLocation, ExtendedType)] putFunction :: Location ExtendedType TypeDB -> TypeDB
findFunction` :: (FunctionLocation ExtendedType -> Bool) TypeDB putFunctions :: [(Location, ExtendedType)] TypeDB -> TypeDB
-> [(FunctionLocation, ExtendedType)] findFunction :: Name TypeDB -> [(Location, ExtendedType)]
findFunction`` :: [(FunctionLocation ExtendedType -> Bool)] TypeDB findFunction` :: (Location ExtendedType -> Bool) TypeDB
-> [(FunctionLocation, ExtendedType)] -> [(Location, ExtendedType)]
findFunction`` :: [(Location ExtendedType -> Bool)] TypeDB
getMacro :: MacroLocation TypeDB -> Maybe Macro -> [(Location, ExtendedType)]
putMacro :: MacroLocation Macro TypeDB -> TypeDB
putMacros :: [(MacroLocation, Macro)] TypeDB -> TypeDB getMacro :: Location TypeDB -> Maybe Macro
findMacro` :: (MacroLocation Macro -> Bool) TypeDB -> [(MacroLocation, Macro)] putMacro :: Location Macro TypeDB -> TypeDB
putMacros :: [(Location, Macro)] TypeDB -> TypeDB
findMacro` :: (Location Macro -> Bool) TypeDB -> [(Location, Macro)]
getInstances :: Class TypeDB -> [Type] getInstances :: Class TypeDB -> [Type]
putInstance :: Class Type TypeDB -> TypeDB putInstance :: Class Type TypeDB -> TypeDB
putInstances :: Class [Type] TypeDB -> TypeDB putInstances :: Class [Type] TypeDB -> TypeDB
putInstancess :: [(Class, [Type])] TypeDB -> TypeDB putInstancess :: [(Class, [Type])] TypeDB -> TypeDB
getClass :: ClassLocation TypeDB -> Maybe ([TypeVar],ClassContext,[(FunctionName,ExtendedType)]) getClass :: Location TypeDB -> Maybe ([TypeVar],ClassContext,[(Name,ExtendedType)])
putClass :: ClassLocation [TypeVar] ClassContext [(FunctionName,ExtendedType)] TypeDB -> TypeDB putClass :: Location [TypeVar] ClassContext [(Name,ExtendedType)] TypeDB -> TypeDB
putClasses :: [(ClassLocation, [TypeVar], ClassContext, [(FunctionName,ExtendedType)])] TypeDB -> TypeDB putClasses :: [(Location, [TypeVar], ClassContext, [(Name,ExtendedType)])] TypeDB -> TypeDB
findClass :: Class TypeDB -> [(ClassLocation, [TypeVar], ClassContext, [(FunctionName, ExtendedType)])] findClass :: Class TypeDB -> [(Location, [TypeVar], ClassContext, [(Name, ExtendedType)])]
findClass` :: (ClassLocation [TypeVar] ClassContext [(FunctionName,ExtendedType)] -> Bool) TypeDB findClass` :: (Location [TypeVar] ClassContext [(Name,ExtendedType)] -> Bool) TypeDB
-> [(ClassLocation, [TypeVar], ClassContext, [(FunctionName, ExtendedType)])] -> [(Location, [TypeVar], ClassContext, [(Name, ExtendedType)])]
findClassMembers` :: (ClassLocation [TypeVar] ClassContext FunctionName ExtendedType -> Bool) TypeDB findClassMembers` :: (Location [TypeVar] ClassContext Name ExtendedType -> Bool) TypeDB
-> [(ClassLocation, [TypeVar], ClassContext, FunctionName, ExtendedType)] -> [(Location, [TypeVar], ClassContext, Name, ExtendedType)]
findClassMembers`` :: [ClassLocation [TypeVar] ClassContext FunctionName ExtendedType -> Bool] findClassMembers`` :: [Location [TypeVar] ClassContext Name ExtendedType -> Bool]
TypeDB -> [(ClassLocation, [TypeVar], ClassContext, FunctionName, ExtendedType)] TypeDB -> [(Location, [TypeVar], ClassContext, Name, ExtendedType)]
getType :: TypeLocation TypeDB -> Maybe TypeDef getType :: Location TypeDB -> Maybe TypeDef
putType :: TypeLocation TypeDef TypeDB -> TypeDB putType :: Location TypeDef TypeDB -> TypeDB
putTypes :: [(TypeLocation, TypeDef)] TypeDB -> TypeDB putTypes :: [(Location, TypeDef)] TypeDB -> TypeDB
findType :: TypeName TypeDB -> [(TypeLocation, TypeDef)] findType :: Name TypeDB -> [(Location, TypeDef)]
findType` :: (TypeLocation TypeDef -> Bool) TypeDB findType` :: (Location TypeDef -> Bool) TypeDB -> [(Location, TypeDef)]
-> [(TypeLocation, TypeDef)]
getDerivations :: Name TypeDB -> [Type]
getDerivations :: GenericName TypeDB -> [Type] putDerivation :: Name Type TypeDB -> TypeDB
putDerivation :: GenericName Type TypeDB -> TypeDB putDerivations :: Name [Type] TypeDB -> TypeDB
putDerivations :: GenericName [Type] TypeDB -> TypeDB putDerivationss :: [(Name, [Type])] TypeDB -> TypeDB
putDerivationss :: [(GenericName, [Type])] TypeDB -> TypeDB
searchExact :: Type TypeDB -> [(Location, ExtendedType)]
searchExact :: Type TypeDB -> [(FunctionLocation, ExtendedType)]
newDb :: TypeDB newDb :: TypeDB
openDb :: *File -> *(Maybe TypeDB, *File) openDb :: *File -> *(Maybe TypeDB, *File)
......
...@@ -13,12 +13,12 @@ import Text.JSON ...@@ -13,12 +13,12 @@ import Text.JSON
import Type import Type
:: TypeDB :: TypeDB
= { functionmap :: Map FunctionLocation ExtendedType = { functionmap :: Map Location ExtendedType
, macromap :: Map MacroLocation Macro , macromap :: Map Location Macro
, classmap :: Map ClassLocation ([TypeVar],ClassContext,[(FunctionName, ExtendedType)]) , classmap :: Map Location ([TypeVar],ClassContext,[(Name, ExtendedType)])
, instancemap :: Map Class [Type] , instancemap :: Map Class [Type]
, typemap :: Map TypeLocation TypeDef , typemap :: Map Location TypeDef
, derivemap :: Map GenericName [Type] , derivemap :: Map Name [Type]
} }
printersperse :: Bool a [b] -> [String] | print a & print b printersperse :: Bool a [b] -> [String] | print a & print b
...@@ -27,15 +27,14 @@ printersperse ia a bs = intercalate (print False a) (map (print ia) bs) ...@@ -27,15 +27,14 @@ printersperse ia a bs = intercalate (print False a) (map (print ia) bs)
(--) infixr 5 :: a b -> [String] | print a & print b (--) infixr 5 :: a b -> [String] | print a & print b
(--) a b = print False a ++ print False b (--) a b = print False a ++ print False b
derive gEq ClassOrGeneric, FunctionLocation, ClassLocation, Type, TypeDB, derive gEq ClassOrGeneric, Location, Type, TypeDB, TypeExtras, TE_Priority,
TypeExtras, TE_Priority, ExtendedType, TypeDef, TypeLocation, TypeDefRhs, ExtendedType, TypeDef, TypeDefRhs, RecordField, Constructor, Kind, Macro
RecordField, Constructor, Kind, MacroLocation, Macro derive JSONEncode ClassOrGeneric, Location, Type, TypeDB, TypeExtras,
derive JSONEncode ClassOrGeneric, FunctionLocation, ClassLocation, Type, TE_Priority, ExtendedType, TypeDef, TypeDefRhs, RecordField, Constructor,
TypeDB, TypeExtras, TE_Priority, ExtendedType, TypeDef, TypeLocation, Kind, Macro
TypeDefRhs, RecordField, Constructor, Kind, MacroLocation, Macro derive JSONDecode ClassOrGeneric, Location, Type, TypeDB, TypeExtras,
derive JSONDecode ClassOrGeneric, FunctionLocation, ClassLocation, Type, TE_Priority, ExtendedType, TypeDef, TypeDefRhs, RecordField, Constructor,
TypeDB, TypeExtras, TE_Priority, ExtendedType, TypeDef, TypeLocation, Kind, Macro
TypeDefRhs, RecordField, Constructor, Kind, MacroLocation, Macro
instance zero TypeDB instance zero TypeDB
where where
...@@ -47,35 +46,18 @@ where ...@@ -47,35 +46,18 @@ where
, derivemap = newMap , derivemap = newMap
} }
instance < (a,b,c,d) | Ord a & Ord b & Ord c & Ord d
where
(<) (a,b,c,d) (e,f,g,h) = ((a,b),(c,d)) < ((e,f),(g,h))
instance < (Maybe a) | < a instance < (Maybe a) | < a
where where
(<) (Just a) (Just b) = a < b (<) (Just a) (Just b) = a < b
(<) (Just _) Nothing = True (<) (Just _) Nothing = True
(<) Nothing _ = False (<) Nothing _ = False
instance < FunctionLocation instance < Location
where where
(<) (FL a b c d) (FL e f g h) = (a,b,c,d) < (e,f,g,h) (<) (Location a b c d) (Location e f g h) = ((a,b),(c,d)) < ((e,f),(g,h))
(<) (FL_Builtin a) (FL_Builtin b) = a < b (<) (Location _ _ _ _) (Builtin _) = True
(<) (FL_Builtin _) _ = True (<) (Builtin _) (Location _ _ _ _) = False
(<) _ _ = False (<) (Builtin a) (Builtin b) = a < b
instance < MacroLocation
where (<) (ML a b c d) (ML e f g h) = (a,b,c,d) < (e,f,g,h)
instance < ClassLocation
where (<) (CL a b c d) (CL e f g h) = (a,b,c,d) < (e,f,g,h)
instance < TypeLocation
where
(<) (TL a b c d) (TL e f g h) = (a,b,c,d) < (e,f,g,h)
(<) (TL_Builtin a) (TL_Builtin b) = a < b
(<) (TL_Builtin _) _ = True
(<) _ _ = False
instance zero TypeExtras instance zero TypeExtras
where where
...@@ -97,7 +79,7 @@ where ...@@ -97,7 +79,7 @@ where
print _ (RightAssoc i) = "infixr " -- i print _ (RightAssoc i) = "infixr " -- i
print _ (NoAssoc i) = "infix " -- i print _ (NoAssoc i) = "infix " -- i
instance print (FunctionName, ExtendedType) instance print (Name, ExtendedType)
where where
print _ (f, (ET t e)) print _ (f, (ET t e))
= gen -- fname -- " " -- e -- " :: " -- t = gen -- fname -- " " -- e -- " :: " -- t
...@@ -108,40 +90,41 @@ where ...@@ -108,40 +90,41 @@ where
| e.te_isrecordfield = "." +++ f | e.te_isrecordfield = "." +++ f
| otherwise = f | otherwise = f
getFunction :: FunctionLocation TypeDB -> Maybe ExtendedType getName :: Location -> Name
getName (Location _ _ _ name) = name
getName (Builtin name) = name
getFunction :: Location TypeDB -> Maybe ExtendedType
getFunction loc {functionmap} = get loc functionmap getFunction loc {functionmap} = get loc functionmap
putFunction :: FunctionLocation ExtendedType TypeDB -> TypeDB putFunction :: Location ExtendedType TypeDB -> TypeDB
putFunction fl t tdb=:{functionmap} = { tdb & functionmap = put fl t functionmap } putFunction fl t tdb=:{functionmap} = { tdb & functionmap = put fl t functionmap }
putFunctions :: [(FunctionLocation, ExtendedType)] TypeDB -> TypeDB putFunctions :: [(Location, ExtendedType)] TypeDB -> TypeDB
putFunctions ts tdb = foldr (\(loc,t) db -> putFunction loc t db) tdb ts putFunctions ts tdb = foldr (\(loc,t) db -> putFunction loc t db) tdb ts
findFunction :: FunctionName TypeDB -> [(FunctionLocation, ExtendedType)] findFunction :: Name TypeDB -> [(Location, ExtendedType)]
findFunction f db=:{functionmap} findFunction f db=:{functionmap}
= toList $ filterWithKey (\fl _-> f == getName fl) functionmap = toList $ filterWithKey (\fl _-> f == getName fl) functionmap
where
getName (FL _ _ f _) = f
getName (FL_Builtin f) = f
findFunction` :: (FunctionLocation ExtendedType -> Bool) TypeDB findFunction` :: (Location ExtendedType -> Bool) TypeDB
-> [(FunctionLocation, ExtendedType)] -> [(Location, ExtendedType)]
findFunction` f {functionmap} = toList $ filterWithKey f functionmap findFunction` f {functionmap} = toList $ filterWithKey f functionmap
findFunction`` :: [(FunctionLocation ExtendedType -> Bool)] TypeDB findFunction`` :: [(Location ExtendedType -> Bool)] TypeDB
-> [(FunctionLocation, ExtendedType)] -> [(Location, ExtendedType)]
findFunction`` fs {functionmap} = toList $ foldr filterWithKey functionmap fs findFunction`` fs {functionmap} = toList $ foldr filterWithKey functionmap fs
getMacro :: MacroLocation TypeDB -> Maybe Macro getMacro :: Location TypeDB -> Maybe Macro
getMacro loc {macromap} = get loc macromap getMacro loc {macromap} = get loc macromap