Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
iTasks-Experiments
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
clean-and-itasks
iTasks-Experiments
Commits
ff14d685
Commit
ff14d685
authored
8 years ago
by
Bas Lijnse
Browse files
Options
Downloads
Patches
Plain Diff
Completed a minimal viable version of the "Try iTasks application"
parent
29ca3293
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
TryiTasks/TryiTasks.icl
+62
-10
62 additions, 10 deletions
TryiTasks/TryiTasks.icl
with
62 additions
and
10 deletions
TryiTasks/TryiTasks.icl
+
62
−
10
View file @
ff14d685
module
TryiTasks
import
iTasks
import
iTasks
,
Text
from
StdFunc
import
o
/**
* This application let's you play with small iTask programs. It a sort of very minimal 'IDE'.
* You can choose example programs, modify them and build/run them
*/
startCode
:==
"start :: Task String
\n
start = updateInformation () []
\"
Hello World
\"\n
"
//Code examples: Should be read from
examples
:==
[(
"Hello World"
,
join
"
\n
"
[
"main :: Task String"
,
"main = viewInformation () []
\"
Hello World
\"
"
])
,(
"Sum"
,
join
"
\n
"
[
"main :: Task Int"
,
"main = enterInformation
\"
Enter a number
\"
[] >>=
\\
num1 ->"
,
" enterInformation
\"
Enter a second number
\"
[] >>=
\\
num2 ->"
,
" viewInformation
\"
The sum is:
\"
[] (num1 + num2)"
])
]
startCode
:==
snd
(
hd
(
examples
))
//Code of the first example
//Paths to the required Clean and iTasks tools for building
cpmBin
:==
"/Users/bas/Clean/bin/cpm"
tryiTasks
::
Task
()
tryiTasks
=
...
...
@@ -13,10 +31,17 @@ tryiTasks =
\
scode
->
(
loadExample
scode
-&&-
modifyCode
scode
)
@
snd
)
>^*
[
OnAction
(
Action
"Build and Run"
[])
(
hasValue
buildAndRun
)]
@!
()
@!
()
loadExample
::
(
Shared
String
)
->
Task
()
loadExample
scode
=
viewInformation
"Load example"
[]
"Here you will be able to select an example code fragment and load it to the shared state"
@!
()
/*
loadExample scode = (forever (
enterChoice "Load example" [ChooseWith (ChooseFromComboBox fst)] examples @ snd
>>* [OnAction (Action "Load" []) (hasValue (\example -> set example scode))]
) @! ()) <<@ ForceLayout
*/
loadExample
scode
=
viewInformation
"Load example"
[]
"Here should be the selection of examples but it messes up the buttons somehow :("
@!
()
modifyCode
::
(
Shared
String
)
->
Task
String
modifyCode
scode
=
updateSharedInformation
"Edit code"
[
UpdateWith
toView
fromView
]
scode
...
...
@@ -31,13 +56,40 @@ buildAndRun fragment = withTemporaryDirectory
>>|
createCleanProject
buildDir
>>|
buildCleanProject
buildDir
>>|
runExecutable
buildDir
>>|
return
()
>>*
[
OnAction
ActionClose
(
always
(
return
()))]
where
createCleanModule
fragment
buildDir
=
viewInformation
"Create module"
[]
"Here a clean module will be created from the fragment"
createCleanProject
buildDir
=
viewInformation
"Create project"
[]
"Here a Clean project will be created to build the module"
buildCleanProject
buildDir
=
viewInformation
"Build project"
[]
"Here the Clean project will be build to create the executable"
runExecutable
buildDir
=
viewInformation
"Run executable"
[]
"Here the generated executable will be run to test"
//Create a clean module from the fragment
createCleanModule
fragment
buildDir
=
exportTextFile
(
buildDir
</>
"test.icl"
)
content
where
content
=
join
"
\n
"
[
"module test"
,
"import iTasks"
,
fragment
,
"Start w = startEngine main w"
]
//Create a Clean project build the module"
createCleanProject
buildDir
=
callProcess
"Create project"
[]
cpmBin
[
"project"
,
"test"
,
"create"
]
(
Just
buildDir
)
>>|
setProjectOptions
buildDir
//Should be possible to do with command line options in cpm
where
setProjectOptions
buildDir
=
importTextFile
projectFile
>>-
\
content
->
exportTextFile
projectFile
(
setOptions
content
)
where
projectFile
=
buildDir
</>
"test.prj"
setOptions
s
=
(
replaceSubString
"Target:
\t
StdEnv"
"Target:
\t
iTasks"
o
replaceSubString
"HeapSize:
\t
2097152"
"HeapSize:
\t
20971520"
)
s
//Build the Clean project will be build to create the executable
buildCleanProject
buildDir
=
callProcess
"Building project"
[]
cpmBin
[
"test.prj"
]
(
Just
buildDir
)
//"Here the generated executable will be run to test"
runExecutable
buildDir
=
callProcess
"Your code is running"
[
ViewWith
toView
]
(
buildDir
</>
"test.exe"
)
[
"-port"
,
"8088"
]
(
Just
buildDir
)
where
toView
_
=
ATag
[
HrefAttr
"http://localhost:8088/"
,
TargetAttr
"_blank"
]
[
Text
"View the code at: http://localhost:8088"
]
Start
w
=
startEngine
tryiTasks
w
This diff is collapsed.
Click to expand it.
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