More complete RankNTypes support#494
Conversation
… infinite dupl. definitions
…plied type lambda arguments in result definitions
…ing type variable applications
…inor optimizations needed in FUN-ARG. FUN-ARG not general.
…ypes. PM-INST-ADT works for mixed concrete and polymorphic DataCon type arguments.
…rom an outer forall.
…same function for argument expressions.
…tion. Logging in ValidateState.
…s use 'deriving instance Eq'
…or all kind vars. Inputs are also made with kind vars subst'd.
…me issue when validating.
… cause mismatches. Some unneeded ADTs being printed (polyFuncArgTwoKinds)
…eport to user. Some issues
…ch that handles gen instances
|
|
||
| -- | Solve for concrete values in a fully executed state. | ||
| type SolveStates m r t = State t -> Bindings -> m (Result (r, NameGen) () ()) | ||
| type SolveStates m r t = State t -> Bindings -> m (Result (r, NameGen, Bindings) () ()) |
There was a problem hiding this comment.
The Bindings have a NameGen in them- so would be better to just make this (r, Bindings).
| -> Bindings | ||
| -> State t | ||
| -> IO (Result (ExecRes t, NameGen) () ()) | ||
| -> IO (Result (ExecRes t, NameGen, Bindings) () ()) |
| runToEnvText :: [(Name, Name)] -> T.Text | ||
| runToEnvText = T.intercalate "\n" . map (\(rTv, eTv) -> | ||
| mkNameHaskell pg rTv <> " -> " <> mkNameHaskell pg eTv) | ||
| prettyTyConcOrSym (TV.TySym (Id _ ty)) = "symbolic " <> mkTypeHaskell ty |
There was a problem hiding this comment.
Why this change? I think the Id indicates the TyVar Id?
There was a problem hiding this comment.
I think this was left in from when I was trying to do symbolic types. Will remove.
| solveStates' :: ( Named t | ||
| , ASTContainer t Expr | ||
| , ASTContainer t G2.Type) => Bindings -> [State t] -> IO (Maybe (ExecRes t, NameGen)) | ||
| , ASTContainer t G2.Type) => Bindings -> [State t] -> IO (Maybe (ExecRes t, NameGen, Bindings)) |
| filterToGenADTs :: TypeEnv -> TypeEnv | ||
| filterToGenADTs = filterTE ((== ADTG2Generated) . adt_source) | ||
|
|
||
| isEmpty :: TypeEnv -> Bool |
There was a problem hiding this comment.
Don't think we're using this anywhere? Cut.
| frstck = S.pop stck | ||
|
|
||
| -- | Separate a type into what is required for some RankNTypes rules. | ||
| sepTypeForRNT :: Type -> ([Type], [Type], Maybe Type) |
There was a problem hiding this comment.
Comment, what is each of these lists/what is the Maybe?
| in (t1:ts', rest) | ||
| getTs mt = ([], mt) -- ignore last in tms, return as tr | ||
|
|
||
| mkNestedLam :: LamUse -> [Id] -> Expr -> Expr |
There was a problem hiding this comment.
See
https://github.com/BillHallahan/G2/blob/master/src/G2/Language/Expr.hs#L407
Instead of this, just have mkLams (zip (repeat lu) vs) e?
| mkNestedLam :: LamUse -> [Id] -> Expr -> Expr | ||
| mkNestedLam lu vs e = foldr (Lam lu) e vs | ||
|
|
||
| mkNestedForAll :: [Type] -> Type -> Type |
There was a problem hiding this comment.
Could we just make the type of this [Id] -> Type -> Type and avoid the possibility of an error?
Also, consider defining in G2.Language.Typing
|
|
||
| -- PM-INST-VAR | ||
| pmInstVar ng_in | ||
| | tr `elem` ts -- return type in arguments |
There was a problem hiding this comment.
Only do this if tr is TyVar? (Seems like it'd avoid some duplication with PM-RET-DC?)
|
|
||
| -- Do tyVar substitution in all StateDiffs. Needed | ||
| -- when tracking generated type class instances. | ||
| alt_res'' = tyVarSubst tvnv alt_res' |
There was a problem hiding this comment.
Can't do this, sorry- instantiating type variables eagerly can cause problems for other systems (mostly having to do with GADTs.)
If you need to replace a single type variable that you know about and are instantiating to a specific type, that might be ok. I don't fully understand the problem being solved here.
There was a problem hiding this comment.
Would probably also be fine to do tyVarSubst specifically on the TCInstDiff
Changes (can point to place in code if more information is needed)
If we want to split these up, I could remove the changes to validation (including the duplicate outputs option).