Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/reflex-frp/reflex-process
Run and interact with system processes from within a Reflex FRP application.
https://github.com/reflex-frp/reflex-process
frp haskell process reflex shell vty
Last synced: 3 months ago
JSON representation
Run and interact with system processes from within a Reflex FRP application.
- Host: GitHub
- URL: https://github.com/reflex-frp/reflex-process
- Owner: reflex-frp
- License: bsd-3-clause
- Created: 2020-01-10T19:37:46.000Z (almost 5 years ago)
- Default Branch: develop
- Last Pushed: 2024-02-09T23:31:15.000Z (9 months ago)
- Last Synced: 2024-06-19T23:57:40.481Z (5 months ago)
- Topics: frp, haskell, process, reflex, shell, vty
- Language: Haskell
- Homepage: https://reflex-frp.org
- Size: 105 KB
- Stars: 10
- Watchers: 18
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.lhs
- Changelog: ChangeLog.md
- License: LICENSE
Awesome Lists containing this project
README
reflex-process
==============[![Haskell](https://img.shields.io/badge/language-Haskell-orange.svg)](https://haskell.org) [![Hackage](https://img.shields.io/hackage/v/reflex-process.svg)](https://hackage.haskell.org/package/reflex-process) [![BSD3 License](https://img.shields.io/badge/license-BSD3-blue.svg)](https://github.com/reflex-frp/reflex-process/blob/master/LICENSE)
Functional-reactive system processes
------------------------------------Run and interact with system processes from within a [Reflex FRP](https://reflex-frp.org/) application.
Example
-------The following example uses [reflex-vty](https://github.com/reflex-frp/reflex-vty) to run a terminal application that calls a shell command and displays the result:
```haskell
> {-# 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 as T
> 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 $ initManager_ $ col $ do
> exit <- keyCombos $ Set.singleton (V.KChar 'c', [V.MCtrl])
> p <- createProcess cmd def
> stdout <- foldDyn (flip mappend) "" $ _process_stdout p
> grout flex $ boxStatic def $ col $ do
> grout (fixed 3) $ boxStatic def $ text "reflex-process"
> grout (fixed 3) $ text "Press Ctrl-C to exit."
> grout (fixed 2) $ text $ pure $ "Running command: " <> case P.cmdspec cmd of
> P.ShellCommand s -> T.pack s
> P.RawCommand p args -> T.intercalate " " $ T.pack <$> (p : args)
> grout (fixed 1) $ text "stdout:"
> grout flex $ text $ T.decodeUtf8 <$> current stdout
> pure $ () <$ exit
```Developer environment
---------------------You can enter a development shell by running `nix-shell`.
From the shell, you can run `cabal` or `ghc` commands or `ghcid`.