RFC: Inline intermediate languages (Core, STG, Cmm, even StrictCore)
Allow intermediate code inline.
Inline Core
Typeable/WithTypeable:
withTypeable :: TTypeRep a -> (Typeable a => r) -> r
Currently,
withTypeable
cannot be written in Haskell, but it is straightforward to write in Core. Can we fix this?
A reflection on types (2016):
We cannot implement withTypeable in Haskell source. But we can implement it in GHC's statically-typed intermediate language, System FC. The definition is simple, roughly like this:
withTypeable tr k = k tr -- Not quite right
Its second argument k expects a Typeable dictionary as its value argument. But since a Typeable dictionary is represented by a TypeRep, we can simply pass tr to k. When written in System FC there is a type-safe coercion to move from TypeRep a to Typeable a, but that coercion is erased at runtime. Since the definition can be statically type checked, withTypeable does not form part of the trusted code base.
Inline Cmm
Edkward Kmett writes his own .cmm
hither, yon.
Inline Strict Core
Should Types are calling conventions (2009) be implemented:
'4.4 The
seq
function'A nice feature of Strict Core,,ANF,, is that it is possible to give a straightforward definition of the primitive seq function of Haskell:
seq : {a:* -> b:* -> {a} -> {b} -> b} = { \a:*. \b:*. \x:{a}. \y:{b}. let _:a = x <> in y <> }
Trac metadata
Trac field | Value |
---|---|
Version | 7.10.3 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |