This repository has been archived by the owner on May 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
58 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,16 @@ | ||
module App where | ||
|
||
import Args ( args | ||
, path | ||
import Args ( args ) | ||
import Mbl ( parseMbl | ||
, interpret | ||
) | ||
import Mbl ( parseMbl, interpret ) | ||
import qualified Data.ByteString as BS | ||
import qualified Data.Text as T | ||
import qualified Configuration as C | ||
|
||
main :: IO () | ||
main = do | ||
config <- args | ||
contents <- BS.readFile $ T.unpack $ path config | ||
mbl <- either (fail) pure $ parseMbl contents | ||
interpret mbl | ||
putStrLn "3" | ||
putStrLn "4" | ||
contents <- BS.readFile $ T.unpack $ C.path config | ||
mbl <- either (fail) pure $ parseMbl config contents | ||
interpret config mbl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module Configuration where | ||
|
||
import qualified Data.Text as T | ||
import qualified Duration as D | ||
|
||
type Delimiter = Char | ||
|
||
data Configuration = Configuration | ||
{ path :: T.Text | ||
, repeat :: Bool | ||
, tick :: D.Duration | ||
, delimiter :: Delimiter } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,19 @@ | ||
module Mbl.Interpreter where | ||
|
||
import Prelude hiding ( repeat ) | ||
import Mbl.Types | ||
import qualified Control.Concurrent as C | ||
import qualified Control.Monad as CM | ||
import qualified Data.ByteString.Char8 as BS | ||
import qualified Configuration as C | ||
import qualified Duration as D | ||
import qualified Data.Bool as B | ||
|
||
|
||
interpret :: MBL -> IO () | ||
interpret _ = C.threadDelay 30000000 | ||
interpret :: C.Configuration -> MBL -> IO () | ||
interpret config mlb = CM.forM_ (repeat mlb) interpret' | ||
where | ||
repeat :: MBL -> MBL | ||
repeat = B.bool id cycle (C.repeat config) | ||
interpret' :: Action -> IO () | ||
interpret' Wait = C.threadDelay $ D.toMicroseconds $ C.tick config | ||
interpret' (Print str) = BS.putStrLn str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters