on master help sign in
Improve profile exe source
commit72ba33e3cebd569c8e010b2d6aaa7dc1e42ce091 authorElliot Cameron <eacameron@gmail.com> dateTue 19 May 2020, 20:31 (6 years ago) parent33f61ab
1 file changed+11−12
default.nix+11−12
default.nix+11−12
@@ -325,29 +325,28 @@ in rec {
325325 {-# LANGUAGE PackageImports #-}
326326 module Main where
327327
328− import "base" Prelude
328+ -- Explicitly import Prelude from base lest there be multiple modules called Prelude
329+ import "base" Prelude (IO, (++), read)
329330
330− import Control.Exception
331− import Reflex.Profiled
332− import System.Environment
331+ import "base" Control.Exception (finally)
332+ import "reflex" Reflex.Profiled (writeProfilingData)
333+ import "base" System.Environment (getArgs)
333334
334− import qualified Obelisk.Run
335+ import qualified "obelisk-run" Obelisk.Run
335336 import qualified Frontend
336337 import qualified Backend
337338
338339 main :: IO ()
339340 main = do
340− args <- getArgs
341− let port = read $ args !! 0
342− assets = args !! 1
343− profileFile = (args !! 2) <> ".rprof"
344− Obelisk.Run.run port (Obelisk.Run.runServeAsset assets) Backend.backend Frontend.frontend `finally` writeProfilingData profileFile
341+ [portStr, assets, profFileName] <- getArgs
342+ Obelisk.Run.run (read portStr) (Obelisk.Run.runServeAsset assets) Backend.backend Frontend.frontend
343+ `finally` writeProfilingData (profFileName ++ ".rprof")
345344 '';
346345 in nixpkgs.runCommand "ob-run" {
347346 buildInputs = [ (profiled.ghc.ghcWithPackages (p: [p.backend p.frontend])) ];
348347 } ''
349− cp ${exeSource} $PWD/ob-run.hs
350− mkdir -p $out/bin/
348+ cp ${exeSource} ob-run.hs
349+ mkdir -p $out/bin
351350 ghc -x hs -prof -fno-prof-auto -threaded ob-run.hs -o $out/bin/ob-run
352351 '';
353352