Skip to content

Commit

Permalink
Use forM_ in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kamil-adam committed Jan 19, 2022
1 parent 982b366 commit 74c6a1e
Show file tree
Hide file tree
Showing 16 changed files with 182 additions and 228 deletions.
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# 📅 Revision history for HelMA

## 0.6.13.0 -- 2022-01-19

* Use `forM_` in tests

## 0.6.12.0 -- 2022-01-07

* Add `Logger` based on Writer
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 🔧 🎨 HelMA - Heavenly Esoteric Little Minimal Automaton for Esoteric Languages implemented in Haskell
# 🔧 🎨 HelMA - Haskellish Esoteric Little Minimal Automaton for Esoteric Languages implemented in Haskell

**🔧 🎨 HelMA** is first part of [HelVM](http://helvm.github.io/) project and implementation of:
* **🧑‍🔧 🧑‍🎨 HAMALAM** - Holistic Actual Minimalist Languages of Automatic Machine.
Expand Down
4 changes: 2 additions & 2 deletions docs/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

**Future Features**

Features to do:
Features to implemented in Haskell:
* [x] 🌈 BrainFuck Interpreter
* [x] ❤️ [ETA](http://www.miketaylor.org.uk/tech/eta/doc/) Interpreter
* [ ] 💛 [Malbolge](https://lutter.cc/malbolge/) Interpreter
* [ ] 💚 [Piet](https://www.dangermouse.net/esoteric/piet.html) Interpreter
* [x] 💙 [SubLeq](http://mazonka.com/subleq/) Interpreter
* [x] 🤍 [WhiteSpace](https://helvm.github.io/wspace/tutorial.html) Interpreter
* [x] 🤍 [WhiteSpace](https://helvm.github.io/WSpace/tutorial.html) Interpreter
* [ ] 🦄 [Zot](https://github.com/helvm/zot_haskell) Interpreter

You can propose feature by [GitHub](https://github.com/helvm/helma/issues).
Expand Down
72 changes: 21 additions & 51 deletions docs/reports/hlint.html
Original file line number Diff line number Diff line change
Expand Up @@ -161,20 +161,17 @@

<p><a class="all" href="javascript:show('')">All hints</a></p>
<ul>
<li><a id="hint0" href="javascript:show('hint0')">Warning: Redundant do (4)</a></li>
<li><a id="hint1" href="javascript:show('hint1')">Suggestion: Move brackets to avoid $ (1)</a></li>
<li><a id="hint2" href="javascript:show('hint2')">Suggestion: Reduce duplication (6)</a></li>
<li><a id="hint0" href="javascript:show('hint0')">Warning: Redundant do (1)</a></li>
<li><a id="hint1" href="javascript:show('hint1')">Suggestion: Reduce duplication (7)</a></li>
</ul>

<p><a class="all" href="javascript:show('')">All files</a></p>
<ul>
<li><a id="file0" href="javascript:show('file0')">./hs/benchmark/HelVM/HelMA/Automata/BrainFuck/Evaluator/IEvaluatorBenchMark.hs (2)</a></li>
<li><a id="file1" href="javascript:show('file1')">./hs/benchmark/HelVM/HelMA/Automata/BrainFuck/Evaluator/TEvaluatorBenchMark.hs (2)</a></li>
<li><a id="file2" href="javascript:show('file2')">./hs/benchmark/HelVM/HelMA/Automata/ETA/EvaluatorBenchMark.hs (2)</a></li>
<li><a id="file3" href="javascript:show('file3')">./hs/src/HelVM/HelMA/Automaton/IO/MockIO.hs (1)</a></li>
<li><a id="file4" href="javascript:show('file4')">./hs/test/HelVM/HelMA/Automata/ETA/EvaluatorSpec.hs (1)</a></li>
<li><a id="file5" href="javascript:show('file5')">./hs/test/HelVM/HelMA/Automata/WhiteSpace/EvaluatorSpec.hs (2)</a></li>
<li><a id="file6" href="javascript:show('file6')">./hs/test/HelVM/MonadErrorSpec.hs (1)</a></li>
<li><a id="file2" href="javascript:show('file2')">./hs/test/HelVM/Common/Collections/MapListSpec.hs (1)</a></li>
<li><a id="file3" href="javascript:show('file3')">./hs/test/HelVM/HelMA/Automata/ETA/EvaluatorSpec.hs (1)</a></li>
<li><a id="file4" href="javascript:show('file4')">./hs/test/HelVM/HelMA/Automata/WhiteSpace/EvaluatorSpec.hs (2)</a></li>
</ul>

</div>
Expand All @@ -185,7 +182,7 @@
- a tool to suggest improvements to your Haskell code.
</p>

<div class="hint2 file0">
<div class="hint1 file0">
./hs/benchmark/HelVM/HelMA/Automata/BrainFuck/Evaluator/IEvaluatorBenchMark.hs:45:3: Suggestion: Reduce duplication<br/>
Found<br/>
<pre><span class='hs-keyword'>let</span> <span class='hs-varid'>file</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>readBfFile</span> <span class='hs-varid'>fileName</span>
Expand All @@ -198,7 +195,7 @@

</div>

<div class="hint2 file0">
<div class="hint1 file0">
./hs/benchmark/HelVM/HelMA/Automata/BrainFuck/Evaluator/IEvaluatorBenchMark.hs:45:3: Suggestion: Reduce duplication<br/>
Found<br/>
<pre><span class='hs-keyword'>let</span> <span class='hs-varid'>file</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>readBfFile</span> <span class='hs-varid'>fileName</span>
Expand All @@ -211,7 +208,7 @@

</div>

<div class="hint2 file1">
<div class="hint1 file1">
./hs/benchmark/HelVM/HelMA/Automata/BrainFuck/Evaluator/TEvaluatorBenchMark.hs:44:5: Suggestion: Reduce duplication<br/>
Found<br/>
<pre><span class='hs-keyword'>let</span> <span class='hs-varid'>file</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>readBfFile</span> <span class='hs-varid'>fileName</span>
Expand All @@ -224,7 +221,7 @@

</div>

<div class="hint2 file1">
<div class="hint1 file1">
./hs/benchmark/HelVM/HelMA/Automata/BrainFuck/Evaluator/TEvaluatorBenchMark.hs:44:5: Suggestion: Reduce duplication<br/>
Found<br/>
<pre><span class='hs-keyword'>let</span> <span class='hs-varid'>file</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>readBfFile</span> <span class='hs-varid'>fileName</span>
Expand All @@ -237,49 +234,22 @@

</div>

<div class="hint0 file2">
./hs/benchmark/HelVM/HelMA/Automata/ETA/EvaluatorBenchMark.hs:35:31: Warning: Redundant do<br/>
<div class="hint1 file2">
./hs/test/HelVM/Common/Collections/MapListSpec.hs:50:11: Suggestion: Reduce duplication<br/>
Found<br/>
<pre><span class='hs-keyword'>do</span> <span class='hs-varid'>ioExec</span> <span class='hs-varid'>stackType</span> <span class='hs-str'>"from-eas"</span> <span class='hs-varid'>fileName</span> <span class='hs-varid'>inputs</span></pre>
Perhaps<br/>
<pre><span class='hs-definition'>ioExec</span> <span class='hs-varid'>stackType</span> <span class='hs-str'>"from-eas"</span> <span class='hs-varid'>fileName</span> <span class='hs-varid'>inputs</span></pre>

</div>

<div class="hint0 file2">
./hs/benchmark/HelVM/HelMA/Automata/ETA/EvaluatorBenchMark.hs:45:31: Warning: Redundant do<br/>
Found<br/>
<pre><span class='hs-keyword'>do</span> <span class='hs-varid'>ioExec</span> <span class='hs-varid'>stackType</span> <span class='hs-str'>"original"</span> <span class='hs-varid'>fileName</span> <span class='hs-varid'>inputs</span></pre>
<pre><span class='hs-definition'>it</span> <span class='hs-str'>"mapListToList . fromIntIndexedList"</span> <span class='hs-varop'>$</span>
<span class='hs-layout'>(</span><span class='hs-varid'>mapListToList</span> <span class='hs-varop'>.</span> <span class='hs-varid'>fromIntIndexedList</span><span class='hs-layout'>)</span> <span class='hs-varid'>input</span> <span class='hs-varop'>`shouldBe`</span> <span class='hs-varid'>output</span>
<span class='hs-definition'>it</span> <span class='hs-str'>"I.toList . fromIntIndexedList"</span> <span class='hs-varop'>$</span>
<span class='hs-layout'>(</span><span class='hs-conid'>I.toList</span> <span class='hs-varop'>.</span> <span class='hs-varid'>fromIntIndexedList</span><span class='hs-layout'>)</span> <span class='hs-varid'>input</span> <span class='hs-varop'>`shouldBe`</span> <span class='hs-varid'>output</span>
<span class='hs-definition'>it</span> <span class='hs-str'>"LL.toList . fromIntIndexedList"</span> <span class='hs-varop'>$</span>
<span class='hs-layout'>(</span><span class='hs-conid'>LL.toList</span> <span class='hs-varop'>.</span> <span class='hs-varid'>fromIntIndexedList</span><span class='hs-layout'>)</span> <span class='hs-varid'>input</span> <span class='hs-varop'>`shouldBe`</span> <span class='hs-varid'>output</span>
</pre>
Perhaps<br/>
<pre><span class='hs-definition'>ioExec</span> <span class='hs-varid'>stackType</span> <span class='hs-str'>"original"</span> <span class='hs-varid'>fileName</span> <span class='hs-varid'>inputs</span></pre>
<pre><span class='hs-conid'>Combine</span> <span class='hs-varid'>with</span> <span class='hs-varop'>./</span><span class='hs-varid'>hs</span><span class='hs-varop'>/</span><span class='hs-varid'>test</span><span class='hs-varop'>/</span><span class='hs-conid'>HelVM</span><span class='hs-varop'>/</span><span class='hs-conid'>Common</span><span class='hs-varop'>/</span><span class='hs-conid'>Collections</span><span class='hs-varop'>/</span><span class='hs-conid'>MapListSpec.hs</span><span class='hs-conop'>:</span><span class='hs-num'>59</span><span class='hs-conop'>:</span><span class='hs-num'>11</span></pre>

</div>

<div class="hint1 file3">
./hs/src/HelVM/HelMA/Automaton/IO/MockIO.hs:94:25: Suggestion: Move brackets to avoid $<br/>
Found<br/>
<pre><span class='hs-layout'>(</span><span class='hs-varid'>orError</span> <span class='hs-varid'>mockIO</span> <span class='hs-varop'>$</span> <span class='hs-varid'>top</span> <span class='hs-layout'>(</span><span class='hs-varid'>input</span> <span class='hs-varid'>mockIO</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span> <span class='hs-varop'>&lt;$</span>
<span class='hs-varid'>put</span> <span class='hs-varid'>mockIO</span><span class='hs-layout'>{</span><span class='hs-varid'>input</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>orError</span> <span class='hs-varid'>mockIO</span> <span class='hs-varop'>$</span> <span class='hs-varid'>discard</span> <span class='hs-varop'>$</span> <span class='hs-varid'>input</span> <span class='hs-varid'>mockIO</span><span class='hs-layout'>}</span></pre>
Perhaps<br/>
<pre><span class='hs-definition'>orError</span> <span class='hs-varid'>mockIO</span> <span class='hs-layout'>(</span><span class='hs-varid'>top</span> <span class='hs-layout'>(</span><span class='hs-varid'>input</span> <span class='hs-varid'>mockIO</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span> <span class='hs-varop'>&lt;$</span>
<span class='hs-varid'>put</span> <span class='hs-varid'>mockIO</span><span class='hs-layout'>{</span><span class='hs-varid'>input</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>orError</span> <span class='hs-varid'>mockIO</span> <span class='hs-varop'>$</span> <span class='hs-varid'>discard</span> <span class='hs-varop'>$</span> <span class='hs-varid'>input</span> <span class='hs-varid'>mockIO</span><span class='hs-layout'>}</span></pre>

</div>

<div class="hint0 file6">
./hs/test/HelVM/MonadErrorSpec.hs:9:8: Warning: Redundant do<br/>
Found<br/>
<pre><span class='hs-keyword'>do</span> <span class='hs-varid'>describe</span> <span class='hs-str'>"MonadError"</span> <span class='hs-varop'>$</span>
<span class='hs-keyword'>do</span> <span class='hs-varid'>it</span> <span class='hs-str'>"Right"</span> <span class='hs-varop'>$</span> <span class='hs-varid'>textRight</span> <span class='hs-varop'>`shouldBe`</span> <span class='hs-conid'>Right</span> <span class='hs-num'>1</span>
<span class='hs-varid'>it</span> <span class='hs-str'>"Left"</span> <span class='hs-varop'>$</span> <span class='hs-varid'>textLeft</span> <span class='hs-varop'>`shouldBe`</span> <span class='hs-conid'>Left</span> <span class='hs-str'>"one"</span></pre>
Perhaps<br/>
<pre><span class='hs-definition'>describe</span> <span class='hs-str'>"MonadError"</span> <span class='hs-varop'>$</span>
<span class='hs-keyword'>do</span> <span class='hs-varid'>it</span> <span class='hs-str'>"Right"</span> <span class='hs-varop'>$</span> <span class='hs-varid'>textRight</span> <span class='hs-varop'>`shouldBe`</span> <span class='hs-conid'>Right</span> <span class='hs-num'>1</span>
<span class='hs-varid'>it</span> <span class='hs-str'>"Left"</span> <span class='hs-varop'>$</span> <span class='hs-varid'>textLeft</span> <span class='hs-varop'>`shouldBe`</span> <span class='hs-conid'>Left</span> <span class='hs-str'>"one"</span></pre>

</div>

<div class="hint2 file4">
./hs/test/HelVM/HelMA/Automata/ETA/EvaluatorSpec.hs:30:11: Suggestion: Reduce duplication<br/>
Found<br/>
<pre><span class='hs-keyword'>let</span> <span class='hs-varid'>params</span> <span class='hs-keyglyph'>=</span> <span class='hs-layout'>(</span><span class='hs-layout'>,</span> <span class='hs-varid'>defaultStackType</span><span class='hs-layout'>)</span> <span class='hs-varop'>&lt;$&gt;</span> <span class='hs-varid'>file</span>
Expand All @@ -292,7 +262,7 @@

</div>

<div class="hint0 file5">
<div class="hint0 file4">
./hs/test/HelVM/HelMA/Automata/WhiteSpace/EvaluatorSpec.hs:25:21: Warning: Redundant do<br/>
Found<br/>
<pre><span class='hs-keyword'>do</span> <span class='hs-varid'>describe</span> <span class='hs-str'>"original"</span> <span class='hs-varop'>$</span>
Expand Down Expand Up @@ -345,7 +315,7 @@

</div>

<div class="hint2 file5">
<div class="hint1 file4">
./hs/test/HelVM/HelMA/Automata/WhiteSpace/EvaluatorSpec.hs:40:15: Suggestion: Reduce duplication<br/>
Found<br/>
<pre><span class='hs-keyword'>let</span> <span class='hs-varid'>paramsIO</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>paramsF</span> <span class='hs-varop'>&lt;$&gt;</span> <span class='hs-varid'>file</span>
Expand Down
2 changes: 1 addition & 1 deletion docs/reports/stan.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion helma.cabal
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cabal-version: 2.4

name: helma
version: 0.6.12.0
version: 0.6.13.0

synopsis: HELMA - Heavenly Esoteric Little Minimal Automaton for Esoteric Languages
description: Please see the README on GitHub at <https://github.com/helvm/helma#readme>
Expand Down
6 changes: 2 additions & 4 deletions hs/benchmark/HelVM/HelMA/Automata/ETA/EvaluatorBenchMark.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ execFromEas stackType = forM
, ("readnum" , ["0\n" , "1\n"])
, ("fact" , ["0\n" , "1\n" , "2\n" , "3\n" , "4\n" , "5\n" , "6\n" , "7\n" , "8\n" , "9\n" ])
, ("bottles" , [""])
] $ \(fileName , inputs) -> do
ioExec stackType "from-eas" fileName inputs
] $ uncurry (ioExec stackType "from-eas")

execOriginal :: StackType -> IO [[Text]]
execOriginal stackType = forM
Expand All @@ -42,8 +41,7 @@ execOriginal stackType = forM
, ("fact" , ["1\n" , "2\n" , "3\n" , "4\n" , "5\n" , "6\n" , "7\n" , "8\n"])
, ("bottles" , [""])
, ("crlf" , [""])
] $ \(fileName , inputs) -> do
ioExec stackType "original" fileName inputs
] $ uncurry (ioExec stackType "original")

ioExec :: StackType -> FilePath -> FilePath -> [Text] -> IO [Text]
ioExec stackType dirName fileName inputs = do
Expand Down
2 changes: 1 addition & 1 deletion hs/src/HelVM/HelMA/Automaton/IO/MockIO.hs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ instance BusinessIO (ControlT MockIO) where
mockGetChar :: MockIO Char
mockGetChar = mockGetChar' =<< get where
mockGetChar' :: MonadState MockIOData f => MockIOData -> f Char
mockGetChar' mockIO = (orError mockIO $ top (input mockIO)) <$ put mockIO { input = orError mockIO $ discard $ input mockIO }
mockGetChar' mockIO = orError mockIO (top $ input mockIO) <$ put mockIO { input = orError mockIO $ discard $ input mockIO }

mockGetLine :: MockIO Text
mockGetLine = mockGetLine' =<< get where
Expand Down
Loading

0 comments on commit 74c6a1e

Please sign in to comment.