1-- | This module provides a GHC plugin designed to improve code that uses
2-- Reflex. Currently, it just adds an INLINABLE pragma to any top-level
3-- definition that doesn't have an explicit inlining pragma. In the future,
4-- additional optimizations are likely to be added.
6{-# LANGUAGE LambdaCase #-}
7{-# LANGUAGE OverloadedStrings #-}
20#if MIN_VERSION_base(4,9,0)
21import Prelude hiding ((<>))
28-- | The GHCJS build of Reflex.Optimizer just throws an error; instead, the version built with GHC should be used.
30plugin = error "The GHCJS build of Reflex.Optimizer cannot be used. Instead, build with GHC and use the result with GHCJS."
34-- | The GHC plugin itself. See "GhcPlugins" for more details.
36plugin = defaultPlugin { installCoreToDos = install }
38install :: [CommandLineOption] -> [CoreToDo] -> CoreM [CoreToDo]
40 liftIO $ putStrLn $ showSDocUnsafe $ ppr p
42 simpl@(CoreDoSimplify _ _) -> [CoreDoSpecialising, simpl]
44 return $ makeInlinable : concatMap f p
45install options@(_:_) p = do
46 warnMsg $ "Reflex.Optimizer: ignoring " <> fromString (show $ length options) <> " command-line options"
49makeInlinable :: CoreToDo
50makeInlinable = CoreDoPluginPass "MakeInlinable" $ \modGuts -> do
51 let f v = setIdInfo v $ let i = idInfo v in
52 setInlinePragInfo i $ let p = inlinePragInfo i in
53 if isDefaultInlinePragma p
54 then defaultInlinePragma { inl_inline = Inlinable }
56 newBinds = flip map (mg_binds modGuts) $ \case
57 NonRec b e -> NonRec (f b) e
58 Rec bes -> Rec $ map (first f) bes
59 return $ modGuts { mg_binds = newBinds }
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list