@hackage reflex-process0.3.0.0
reflex-frp interface for running shell commands
Categories
License
BSD-3-Clause
Maintainer
maintainer@obsidian.systems
Links
- Documentation
- No source repository
- Changelog
- Security
Versions
Installation
Tested Compilers
Dependencies (7)
- async >=2 && <3
- base >=4.12 && <4.14
- bytestring >=0.10 && <0.11
- data-default >=0.2 && <0.8
- process >=1.6.4 && <1.7
- reflex >=0.7.1 && <0.8 Show all…
Dependents (1)
@hackage/reflex-ghci
reflex-process
Functional-reactive shell commands
This library provides a functional-reactive interface for running shell commands from reflex.
Example
The following example uses reflex-vty to run a terminal application that calls a shell command and displays the result:
> {-# LANGUAGE OverloadedStrings #-}
> import Reflex
> import Reflex.Process
> import Reflex.Vty
>
> import Control.Monad ((<=<))
> import Data.Default (def)
> import qualified Data.Set as Set
> import qualified Data.Text.Encoding as T
> import qualified Graphics.Vty.Input as V
> import qualified System.Process as P
>
> cmd :: P.CreateProcess
> cmd = P.proc "ls" ["-a"]
>
> main :: IO ()
> main = mainWidget $ do
> exit <- keyCombos $ Set.singleton (V.KChar 'c', [V.MCtrl])
> p <- createProcess cmd def
> stdout <- foldDyn (flip mappend) "" $ _process_stdout p
> boxStatic def $ col $ do
> fixed 3 $ boxStatic def $ text "reflex-process"
> fixed 3 $ text "Press Ctrl-C to exit."
> fixed 1 $ text "stdout:"
> stretch $ text $ T.decodeUtf8 <$> current stdout
> pure $ () <$ exit
Developer environment
You can get ghcid running for working on the code with the command:
nix-shell -E '((import ./reflex-platform {}).ghc.callCabal2nix "reflex-process" ./. {}).env' --run ghcid