Add HasType / InferType classes - #1915
Conversation
eef819a to
d45c0cd
Compare
| | let (primArgs, primResTy) = splitFunForallTy (primType pr) | ||
| , TyConApp tupTcNm tupArgs <- tyView primResTy | ||
| , Text.isInfixOf "GHC.Tuple.(" (nameOcc tupTcNm) | ||
| -> mkPolyFunTy primResTy (primArgs <> fmap Right tupArgs) | ||
|
|
||
| | otherwise | ||
| -> error "PrimInfo.coreTypeOf: MultiResult primitive without tuple type" |
There was a problem hiding this comment.
This really needs a note here to explain why it behaves as it does, e.g. the rationale behind the old multiPrimType that this replaces
There was a problem hiding this comment.
Updated: the doc in Clash.Normalize.Transformation.MultiPrim was extended and this now points to that.
| _ -> error $ unlines ["applyTypeToArgs:" | ||
| ,"Expression: " ++ showPpr e | ||
| ,"Type: " ++ showPpr opTy | ||
| ,"Args: " ++ unlines (map (either showPpr showPpr) args) | ||
| ] |
There was a problem hiding this comment.
While this is being moved it might be nice to neaten up the error message
There was a problem hiding this comment.
Updated: needs to be checked by someone else
| piResultTy | ||
| :: HasCallStack | ||
| => TyConMap | ||
| -> Type | ||
| -> Type | ||
| -> Type | ||
| piResultTy m ty arg = case piResultTyMaybe m ty arg of | ||
| Just res -> res | ||
| Nothing -> pprPanic "piResultTy" (ppr ty <> line <> ppr arg) |
There was a problem hiding this comment.
I wonder if this can just be replaced with piResultTy tcm ty arg = piResultTys tcm ty [arg] and the piResultTyMaybe function then removed
There was a problem hiding this comment.
Updated: needs to be checked by someone else
There was a problem hiding this comment.
I mean, if we don't use piResultTyMaybe anywhere any longer, we might as well remove it.
There was a problem hiding this comment.
We don't, it was more of a maybe this is some perf trick that I'm just not seeing
d710111 to
804f7de
Compare
804f7de to
68c7acb
Compare
68c7acb to
1085f69
Compare
1085f69 to
d8b8273
Compare
This PR introduces some new classes for inspecting things in Clash core:
These functions can then be used to extract type information from any typed thing that exists in core.
Still TODO: