diff options
author | Paul Oliver <contact@pauloliver.dev> | 2025-08-26 21:39:37 +0000 |
---|---|---|
committer | Paul Oliver <contact@pauloliver.dev> | 2025-08-26 21:40:12 +0000 |
commit | 101b60386ec8380cc3a62154bc7c1c53205f5d59 (patch) | |
tree | fc67555b20416791d59c6cd9a5e8fb9e2437f15d | |
parent | f1f62e00559d5c68a5e7b1246208391835a13d0d (diff) |
Improves formatting even more
-rw-r--r-- | hsm-core/Hsm/Core/Serial.hs | 22 | ||||
-rw-r--r-- | hsm-log/Hsm/Log.hs | 1 | ||||
-rw-r--r-- | hsm-repl/Test/Repl.hs | 3 |
3 files changed, 15 insertions, 11 deletions
diff --git a/hsm-core/Hsm/Core/Serial.hs b/hsm-core/Hsm/Core/Serial.hs index a0efca3..a672fca 100644 --- a/hsm-core/Hsm/Core/Serial.hs +++ b/hsm-core/Hsm/Core/Serial.hs @@ -36,13 +36,17 @@ import Language.Haskell.TH -- Generates a data type `GPIOPin` with constructors `GPIO2`, `GPIO3` `GPIO4`, -- and a function `pinLine :: GPIOPin -> Int`. makeSerial :: String -> String -> String -> Name -> [Int] -> Q [Dec] -makeSerial name suffix mapFun mapType idxs = - return [DataD [] dtName [] Nothing (idxCons <$> idxs) [derivClause], SigD mapFunName . AppT (AppT ArrowT $ ConT dtName) $ ConT mapType, FunD mapFunName $ mapFunClause <$> idxs] +makeSerial name suffix mapFunction mapType indices = + return + [ DataD [] dataName [] Nothing (indexCons <$> indices) [deriveClause] + , SigD mapFunctionName . AppT (AppT ArrowT $ ConT dataName) $ ConT mapType + , FunD mapFunctionName $ mapFunctionClause <$> indices + ] where - dtName = mkName $ name <> suffix - idxName idx = mkName $ name <> show idx - idxCons idx = NormalC (idxName idx) [] - derivClause = DerivClause Nothing [ConT ''Bounded, ConT ''Enum, ConT ''Show] - mapFunName = mkName mapFun - mapFunBody = NormalB . LitE . IntegerL . integerFromInt - mapFunClause idx = Clause [ConP (idxName idx) [] []] (mapFunBody idx) [] + dataName = mkName $ name <> suffix + indexName index = mkName $ name <> show index + indexCons index = NormalC (indexName index) [] + deriveClause = DerivClause Nothing [ConT ''Bounded, ConT ''Enum, ConT ''Show] + mapFunctionName = mkName mapFunction + mapFunctionBody = NormalB . LitE . IntegerL . integerFromInt + mapFunctionClause index = Clause [ConP (indexName index) [] []] (mapFunctionBody index) [] diff --git a/hsm-log/Hsm/Log.hs b/hsm-log/Hsm/Log.hs index a1ffdb4..d8dbab0 100644 --- a/hsm-log/Hsm/Log.hs +++ b/hsm-log/Hsm/Log.hs @@ -9,6 +9,7 @@ module Hsm.Log , logMsg , logBlock , runLog + , runLogs ) where import Control.Monad (when) diff --git a/hsm-repl/Test/Repl.hs b/hsm-repl/Test/Repl.hs index 2d299b8..8588718 100644 --- a/hsm-repl/Test/Repl.hs +++ b/hsm-repl/Test/Repl.hs @@ -1,8 +1,7 @@ import Control.Monad.Loops (whileJust_) -import Data.Function ((&)) import Effectful (runEff) import Hsm.Log (Severity(Trace), runLog) import Hsm.Repl (repl, runRepl) main :: IO () -main = whileJust_ repl return & runRepl @"exec-repl λ " @'[ "Prelude"] @[Bool] & runLog @"repl" Trace & runEff +main = runEff . runLog @"repl" Trace . runRepl @"exec-repl λ " @'[ "Prelude"] @[Bool] $ whileJust_ repl return |