
#11441: RFC: Inline intermediate languages (Core, STG, Cmm, even StrictCore) -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Iceland_jack): Focusing on Core for now, we can reuse Haskell's syntax (some intersection between Haskell and Core syntax), see #11350, with minor sugar for functions: {{{#!hs {-# CORE id #-} id :: forall a. a -> a id @a (x :: a) = x {-# CORE add #-} double :: forall num. Num num => num -> num double (@ num) (numDict :: Num num) (x :: num) = (+) (@ num) numDict x x }}} or we could cheekily reuse Template Haskell. Like [https://ghc.haskell.org/trac/ghc/wiki/Records/OverloadedRecordFields/Overloa... this suggestions] to define a magic module for implicit values we can have define a magic module of quoters (`QuasiQuoter`s for sublanguages that are treated specially: {{{#!hs import GHC.Magic (core, stg) [core| id :: forall a. a -> a id = \ (@ a) (x :: a) -> x double :: forall num. Num num => num -> num double = \(@ num) (numDict :: Num num) (x :: num) -> + @ num numDict x x |] }}} or a combinator library where users code directly in Core AST, `data Expr b = Var Id | ...`. Some questions: * Dictionaries and their scope. * Writing function metadata. * Only top-level definitions? * ... Interested in other uses. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11441#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler