Skip to content

Commit

Permalink
Add Logger
Browse files Browse the repository at this point in the history
  • Loading branch information
kamil-adam committed Jan 7, 2022
1 parent 3649783 commit 6705355
Show file tree
Hide file tree
Showing 63 changed files with 1,123 additions and 437 deletions.
7 changes: 7 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# 📅 Revision history for HelPA

## 0.4.2.0 -- 2022-01-07

* Add `Logger` based on Writer
* Refactor `Safe`
* Replace `CartesianProduct` to `ZipA`
* Use local `hlint`

## 0.4.1.0 -- 2021-12-23

* Add `Assembler of SubLeq` from eigenratios
Expand Down
21 changes: 12 additions & 9 deletions docs/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,32 @@
**Future Features**

Features to do for concrete languages:
* [ ] 🌈 BrainFuck Assembler Language -
[FBF](http://www.inshame.com/search/label/My%20Progs%3A%20FuckBrainfuck) ([code backup](https://github.com/esovm/FuckBrainFuck))
* [ ] 🌈 BrainFuck Assembler Language
* [ ] [asm2BF](https://esolangs.org/wiki/Asm2bf)
* [ ] [FBF](http://www.inshame.com/search/label/My%20Progs%3A%20FuckBrainfuck) ([code backup](https://github.com/esovm/FuckBrainFuck))
* [x] ❤️ [ETA](http://www.miketaylor.org.uk/tech/eta/doc/) Assembler Language - [EAS](http://www.miketaylor.org.uk/tech/eta/doc/easman.html) ([code backup](https://github.com/helvm/eta))
* [ ] 💛 [Malbolge](https://lutter.cc/malbolge/) Assembler Language:
* [LMAO](https://lutter.cc/malbolge/assembler.html) ([code](https://github.com/esoteric-programmer/LMAO))
* [LMFAO](https://lutter.cc/unshackled/assembler.html) ([code](https://github.com/esoteric-programmer/LMFAO))
* [LAL](https://www.trs.cm.is.nagoya-u.ac.jp/projects/Malbolge/lal/lal-def.html.en) ([code](https://git.trs.css.i.nagoya-u.ac.jp/malbolge/lowass))
* [HAL](https://www.trs.cm.is.nagoya-u.ac.jp/projects/Malbolge/hal/hal-def.html.en) ([code](https://git.trs.css.i.nagoya-u.ac.jp/malbolge/ternary))
* [ ] [LMAO](https://lutter.cc/malbolge/assembler.html) ([code](https://github.com/esoteric-programmer/LMAO))
* [ ] [LMFAO](https://lutter.cc/unshackled/assembler.html) ([code](https://github.com/esoteric-programmer/LMFAO))
* [ ] [LAL](https://www.trs.cm.is.nagoya-u.ac.jp/projects/Malbolge/lal/lal-def.html.en) ([code](https://git.trs.css.i.nagoya-u.ac.jp/malbolge/lowass))
* [ ] [HAL](https://www.trs.cm.is.nagoya-u.ac.jp/projects/Malbolge/hal/hal-def.html.en) ([code](https://git.trs.css.i.nagoya-u.ac.jp/malbolge/ternary))
* [ ] 💚 [Piet](https://www.dangermouse.net/esoteric/piet.html) Assembler Language -
[Piet](https://www.toothycat.net/wiki/wiki.pl?MoonShadow/Piet) ([code backup](https://github.com/helvm/Piet))
* [x] 💙 [SubLeq](http://mazonka.com/subleq/) Assembler Language:
* [x] [ASQ](http://mazonka.com/subleq/)
* [x] [eigenratios](http://eigenratios.blogspot.com/2006/09/mark-ii-oisc-self-interpreter.html)
* [ ] [sblasm](https://techtinkering.com/articles/subleq-a-one-instruction-set-computer/) ([code](https://github.com/lawrencewoodman/sblasm))
* [x] 🤍 [WhiteSpace](https://helvm.github.io/wspace/tutorial.html) Assembler Language - [WSA](https://helvm.github.io/wsa/intro.html) ([code backup](https://github.com/helvm/wsa))
* [ ] 🤍 [WhiteSpace](https://helvm.github.io/wspace/tutorial.html) Assembler Language
* [ ] [asm2WS](https://github.com/kspalaiologos/asm2ws)
* [x] [WSA](https://helvm.github.io/wsa/intro.html) ([code backup](https://github.com/helvm/wsa))
* [ ] 🖤 WMachine Assembler Language
* [ ] 🦄 [Zot](https://github.com/helvm/zot_haskell) Assembler Language

Features to do for concrete languages:
* [ ] 👾 🐲 🐉 [ELVM](https://github.com/shinh/elvm/blob/master/ELVM.md) for the above languages
* [ ] 🩸 💎 🔥 Bloody Brilliant - Basic-Like with Block for Bastards
* [ ] 🩸 💎 🔥 Bloody Brilliant - Basic-Like with Blocks and Brackets for Bastards
* [ ] 🍆 🍑 🍒 Fruity Fridays - Forth-Like with Functions for Fruitarians
* [ ] ✨💩 ✨ Shity Languages - Shit-Like Language, very fast stack assembler
* [ ] 💩 🎤 🧑‍🎤 Shity Language - Shit-Like Language, very fast stack assembler


You can propose languages and features by [GitHub](https://github.com/helvm/helap/issues).
Expand Down
186 changes: 186 additions & 0 deletions docs/reports/hlint.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
<title>HLint Report</title>
<script type='text/javascript'>

/* == Algorithm for show/unshow ==
Each hint/file is given a number, hint# or file#
When we say showOnly with a class name we add the rules to
the css #content div {display:none}, #content div.className {display:block}
When going back to showAll we remove these results
*/

// CSS MANIPULATION //

function deleteRules(n)
{
var css = document.styleSheets[0];
for (var i = 0; i < n; i++)
css.deleteRule(css.cssRules.length-1);
}

function insertRule(s)
{
var css = document.styleSheets[0];
css.insertRule(s, css.cssRules.length);
}

// SHOW/HIDE LOGIC //

/**
* @param {bool} [initialise=false] - Used to signal we are loading the page, so
the current location doesn't match our presumed state.
*/
function show(id, initialise=false)
{
var last;
if (initialise)
{
last = "";
}
else
{
last = document.location.hash.slice(1);
}

if (id === last) return;
if (id.length === 0)
{
deleteRules(3);
insertRule(".all {font-weight: bold;}");
}
else
{
if (last.length === 0)
{
deleteRules(1);
insertRule("#content div {display:none;}");
}
else
{
deleteRules(2);
}
insertRule("#content div." + id + " {display:block;}");
insertRule("#" + id + "{font-weight:bold;}");
}

if (window.history)
history.replaceState("", document.title, window.location.pathname + window.location.search + (id === "" ? "" : "#" + id));
else
document.location.hash = '#'.concat(id);
}

</script>
<style type="text/css">
/* These rules are manipulated by the script.
The commented form is how it looks with an id selected */

.all {font-weight: bold;} /* #content div {display:none;} */
/* #content div.id {display:block;} */
/* #id {font-weight: bold;} */

</style>
<style type="text/css">
/* See http://www.webreference.com/programming/css_frames/ */
body {
margin:0;
border:0;
padding:0;
height:100%;
max-height:100%;
font-family: sans-serif;
font-size:76%;
overflow: hidden;
}

#leftbar {
position:absolute;
top:0px;
left:0px;
width: 215px;
bottom: 0px;
overflow:auto;
background:rgb(202,223,255);
margin: 10px;
padding-top: 0;
padding-left: 7px;
padding-right: 7px;
border-radius: 5px;

display:none; /* Override if script present */
}

#content {
position:absolute;
top:0;
bottom:0;
right:0;
overflow:auto;
padding-bottom: 15px;
padding-right: 7px;

left:10px; /* Override if script present */
}

#leftbar ul {margin-top: 0px; padding-left: 15px;}
#leftbar p {margin-bottom: 0px;}
.note {color: gray; font-size: smaller;}

pre {
font-family: "lucida console", monospace;
padding-left: 15px;
margin: 2px;
}

#content div {
margin-bottom: 10px;
margin-right: 10px;
padding-top: 4px;
border-top: 1px solid #ccc;
}

.script #content {left:250px;}
.script #leftbar {display: block;}

/* From HsColour */
.hs-keyglyph, .hs-layout {color: red;}
.hs-keyword {color: blue;}
.hs-comment, .hs-comment a {color: green;}
.hs-str, .hs-chr {color: teal;}
</style>
</head>
<body>

<script type='text/javascript'>
document.body.className = "script";
</script>

<div id="leftbar" valign="top" style="min-width:200px">

<p><a class="all" href="javascript:show('')">All hints</a></p>
<ul>
<li>No hints</li>
</ul>

<p><a class="all" href="javascript:show('')">All files</a></p>
<ul>
<li>No files</li>
</ul>

</div>
<div id="content" valign="top" width="100%">
<p>
Report generated by <a href="http://community.haskell.org/~ndm/hlint/">HLint</a>
v2.1.11
- a tool to suggest improvements to your Haskell code.
</p>

No hints
</div>
<script type='text/javascript'>
show(window.location.hash.slice(1), true);
</script>
</body>
</html>
2 changes: 1 addition & 1 deletion docs/reports/stan.html

Large diffs are not rendered by default.

13 changes: 10 additions & 3 deletions helpa.cabal
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cabal-version: 2.4

name: helpa
version: 0.4.1.0
version: 0.4.2.0

synopsis: HELPA - Heavenly Esoteric Little Portable Assembler to esoteric languages
description: Please see the README on GitHub at <https://github.com/helvm/helpa#readme>
Expand Down Expand Up @@ -113,16 +113,21 @@ library
HelVM.Common.Containers.MTInsertDef
HelVM.Common.Containers.Util

HelVM.Common.Control.Control
HelVM.Common.Control.Message
HelVM.Common.Control.Logger
HelVM.Common.Control.Safe

HelVM.Common.Digit.Digitable
HelVM.Common.Digit.Digits
HelVM.Common.Digit.ToDigit

HelVM.Common.ListLikeUtil
HelVM.Common.NamedValue
HelVM.Common.ReadText
HelVM.Common.Safe
HelVM.Common.SequencesUtil
HelVM.Common.Util
HelVM.Common.ZipA

HelVM.HelPA.Assembler.API.SourcePath
HelVM.HelPA.Assembler.API.SwitchEnum
Expand Down Expand Up @@ -211,10 +216,11 @@ test-suite helpa-test
other-modules:
Spec

HelVM.CartesianProduct
HelVM.Expectations
HelVM.GoldenExpectations

HelVM.Common.Control.LoggerSpec

HelVM.HelPA.Assemblers.ASQ.AssemblyOptionsUtil
HelVM.HelPA.Assemblers.ASQ.FileUtil

Expand Down Expand Up @@ -249,6 +255,7 @@ test-suite helpa-test

, helpa

, dlist
, filepath
-- , ilist
, type-operators
Expand Down
5 changes: 4 additions & 1 deletion hlint.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/usr/bin/env bash

curl -sSL https://raw.github.com/ndmitchell/hlint/master/misc/run.sh | sh -s .
#curl -sSL https://raw.github.com/ndmitchell/hlint/master/misc/run.sh | sh -s .
hlint . --report=hlint.html --timing

mv hlint.html docs/reports
7 changes: 4 additions & 3 deletions hs/app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import HelVM.HelPA.Assembler.IO.BusinessIO

import HelVM.HelPA.Assembler.API.SwitchEnum

import HelVM.Common.Safe
import HelVM.Common.Control.Control
import HelVM.Common.Control.Safe

import AppOptions

Expand All @@ -31,8 +32,8 @@ main = run =<< execParser opts where
<> progDesc "" )

run :: AppOptions -> IO ()
run AppOptions {lang , version, nextAddressForQuestionMark , eolSeparator , addOutLabel , tokenType , debug , startOfInstruction , endOfLine , dir , file} = do
putTextLn =<< exceptTToIO (eval lang' asqOptions wsaOptions sourcePath) where --FIXME Bug in relude doc for putTextLn
run AppOptions {lang , version, nextAddressForQuestionMark , eolSeparator , addOutLabel , tokenType , debug , startOfInstruction , endOfLine , dir , file} =
putTextLn =<< controlTToIO (eval lang' asqOptions wsaOptions sourcePath) where --FIXME Bug in relude doc for putTextLn
asqOptions = ASQ.AssemblyOptions {version=version', questionMark=questionMark, separator=separator , addOutLabel=addOutLabel}
wsaOptions = WSA.AssemblyOptions {tokenType=tokenType', debug=debug , startOfInstruction=startOfInstruction , endOfLine=endOfLine}
sourcePath = SourcePath {dirPath = dir , filePath = file}
Expand Down
2 changes: 1 addition & 1 deletion hs/src/HelVM/Common/Collections/MapList.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module HelVM.Common.Collections.MapList where

import HelVM.Common.Containers.LLIndexSafe
import HelVM.Common.Containers.LLInsertDef
import HelVM.Common.Safe
import HelVM.Common.Control.Safe

import Data.Default

Expand Down
12 changes: 6 additions & 6 deletions hs/src/HelVM/Common/Containers/LLIndexSafe.hs
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{-# LANGUAGE UndecidableInstances #-}
module HelVM.Common.Containers.LLIndexSafe where

import HelVM.Common.Safe
import HelVM.Common.Control.Safe

import Data.ListLike

import Prelude hiding (break, divMod, drop, fromList, length, splitAt, swap, uncons)
import Prelude hiding (break, divMod, drop, fromList, length, splitAt, swap, uncons)

-- | Index
naturalIndexSafe :: (MonadSafeError m , IndexSafe full item) => full -> Natural -> m item
naturalIndexSafe :: (MonadSafe m , IndexSafe full item) => full -> Natural -> m item
naturalIndexSafe l = indexSafe l . fromIntegral

-- | Type Class
class IndexSafe full item | full -> item where
findWithDefault :: item -> Int -> full -> item
findMaybe :: Int -> full -> Maybe item
indexMaybe :: full -> Int -> Maybe item
findSafe :: MonadSafeError m => Int -> full -> m item
indexSafe :: MonadSafeError m => full -> Int -> m item
findSafe :: MonadSafe m => Int -> full -> m item
indexSafe :: MonadSafe m => full -> Int -> m item

instance ListLike full item => IndexSafe full item where
findWithDefault e i = fromMaybe e . findMaybe i
Expand All @@ -27,7 +27,7 @@ instance ListLike full item => IndexSafe full item where
indexSafe = indexSafeLL

-- | Internal functions
indexSafeLL :: (MonadSafeError m , ListLike full item) => full -> Int -> m item
indexSafeLL :: (MonadSafe m , ListLike full item) => full -> Int -> m item
indexSafeLL l i
| i < 0 = liftError "LLIndexSafe.indexSafeLL: index must be >= 0"
| length l <= i = liftError "LLIndexSafe.indexSafeLL: index must not found"
Expand Down
Loading

0 comments on commit 6705355

Please sign in to comment.