Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
qbar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jens Nolte
qbar
Commits
66778fdb
Commit
66778fdb
authored
5 years ago
by
Jens Nolte
Browse files
Options
Downloads
Patches
Plain Diff
Simplify persistent block script
parent
ca857b67
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/QBar/Core.hs
+3
-13
3 additions, 13 deletions
src/QBar/Core.hs
with
3 additions
and
13 deletions
src/QBar/Core.hs
+
3
−
13
View file @
66778fdb
...
...
@@ -272,39 +272,29 @@ blockScript path = forever $ yield =<< (lift $ blockScriptAction)
createScriptBlock
::
T
.
Text
->
BlockOutput
createScriptBlock
text
=
pangoMarkup
$
setBlockName
(
T
.
pack
path
)
$
createBlock
text
startPersistentBlockScript
::
FilePath
->
CachedBlock
-- This is only using 'CachedBlock' because the code was already written and tested
-- This could probably be massively simplified by using the new 'pushBlock'
startPersistentBlockScript
path
=
do
bar
<-
lift
$
ask
do
(
output
,
input
,
seal
)
<-
liftIO
$
spawn'
$
latest
$
emptyBlock
initialDataEvent
<-
liftIO
$
Event
.
new
task
<-
liftIO
$
async
$
do
let
processConfig
=
setStdin
closed
$
setStdout
createPipe
$
shell
path
finally
(
catch
(
withProcessWait
processConfig
$
\
process
->
do
let
handle
=
getStdout
process
runEffect
$
(
fromHandle
bar
handle
)
>->
signalFirstBlock
initialDataEvent
>->
toOutput
output
runEffect
$
(
fromHandle
bar
handle
)
>->
toOutput
output
)
(
\
e
->
-- output error
runEffect
$
(
yield
$
createErrorBlock
$
"["
<>
(
T
.
pack
$
show
(
e
::
IOException
))
<>
"]"
)
>->
signalFirstBlock
initialDataEvent
>->
toOutput
output
runEffect
$
(
yield
$
createErrorBlock
$
"["
<>
(
T
.
pack
$
show
(
e
::
IOException
))
<>
"]"
)
>->
toOutput
output
)
)
(
atomically
seal
)
liftIO
$
link
task
liftIO
$
Event
.
wait
initialDataEvent
cacheFromInput
input
where
signalFirstBlock
::
Event
.
Event
->
Pipe
BlockOutput
BlockOutput
IO
()
signalFirstBlock
event
=
do
-- Await first block
await
>>=
yield
lift
$
Event
.
set
event
-- Replace with cat
cat
fromHandle
::
Bar
->
Handle
->
Producer
BlockOutput
IO
()
fromHandle
bar
handle
=
forever
$
do
line
<-
lift
$
TIO
.
hGetLine
handle
...
...
This diff is collapsed.
Click to expand it.
Jens Nolte
@jens
mentioned in commit
c01bac43
·
5 years ago
mentioned in commit
c01bac43
mentioned in commit c01bac436c9a12ed35522d97f3ce233eee5370c9
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment