Skip to content

Commit 19321c8

Browse files
committed
Cleans up explore code a bit
1 parent 78174a4 commit 19321c8

File tree

2 files changed

+29
-32
lines changed

2 files changed

+29
-32
lines changed

Barbq/UI/Runtime.hs

+4-7
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,16 @@ runRenderM crm vty input = runReaderT m vty
4242

4343
explore :: forall w m e. (Show e, Comonad w) => Pairing m w -> Component' w m e V.Image -> Consumer (Maybe e) RenderM ()
4444
explore pair space = do
45+
let (img, runner) = render space
4546
vty <- lift ask
46-
let (img, runner) = let { (UI ui) = extract (unpack space) } in runWriter (ui send)
47-
let pic = V.picForImage img
48-
_bounds <- liftIO $ V.outputIface vty & V.displayBounds
49-
--liftIO $ print bounds
50-
liftIO $ V.update vty pic
51-
-- TODO: Keystrokes
52-
-- e <- liftIO $ nextEvent vty
47+
liftIO $ V.update vty (V.picForImage img)
5348
e <- await
5449
case e of
5550
Nothing -> return ()
5651
Just e -> explore pair (appEndo (runner e) space)
5752
where
53+
render :: forall v. Component' w m e v -> (v, Handler e (Component' w m e v))
54+
render space = let { (UI ui) = extract (unpack space) } in runWriter (ui send)
5855
send :: forall v. m () -> Endo (Component' w m e v)
5956
send action =
6057
Endo $ over Component' $ pair (const id) action <<< duplicate

default.nix

+25-25
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
{ compiler ? "ghc865", pkgs ? import <nixpkgs> {} }:
22

33
let
4-
getvolume = pkgs.callPackage ./getvolume/default.nix { };
4+
getvolume = pkgs.callPackage ./getvolume/default.nix {};
55
packageSet = pkgs.haskell.packages.${compiler};
66
haskellPackages =
77
packageSet.override {
8-
overrides = (self: super:
9-
{
10-
ghc = super.ghc // { withPackages = super.ghc.withHoogle; };
11-
ghcWithPackages = self.ghc.withPackages;
12-
async-timer = pkgs.haskell.lib.dontCheck super.async-timer;
13-
}
14-
);
15-
};
16-
raw = haskellPackages.callCabal2nix "barbq" ./. {};
17-
drv = pkgs.symlinkJoin {
18-
name = "barbq";
19-
paths = [ raw getvolume ];
20-
};
21-
22-
in
23-
{
24-
barbq = drv;
25-
barbq-shell = haskellPackages.shellFor {
26-
packages = p: [raw];
27-
shellHook = ''
28-
export HIE_HOOGLE_DATABASE="$(cat $(which hoogle) | sed -n -e 's|.*--database \(.*\.hoo\).*|\1|p')"
29-
'';
30-
buildInputs = with pkgs; [ cabal-install hlint ghcid getvolume ] ;
8+
overrides = (
9+
self: super:
10+
{
11+
ghc = super.ghc // { withPackages = super.ghc.withHoogle; };
12+
ghcWithPackages = self.ghc.withPackages;
13+
async-timer = pkgs.haskell.lib.dontCheck super.async-timer;
14+
}
15+
);
3116
};
32-
}
17+
raw = haskellPackages.callCabal2nix "barbq" ./. {};
18+
drv = pkgs.symlinkJoin {
19+
name = "barbq";
20+
paths = [ raw getvolume ];
21+
};
3322

23+
in
24+
{
25+
barbq = drv;
26+
barbq-shell = haskellPackages.shellFor {
27+
packages = p: [ raw ];
28+
shellHook = ''
29+
export HIE_HOOGLE_DATABASE="$(cat $(which hoogle) | sed -n -e 's|.*--database \(.*\.hoo\).*|\1|p')"
30+
'';
31+
buildInputs = with pkgs; [ cabal-install hlint ghcid getvolume pkgs.libiconv ];
32+
};
33+
}

0 commit comments

Comments
 (0)