doc: switch to literate idris

Switch entire project over to literate markdown files
This commit is contained in:
Nathan McCarty 2025-01-04 11:40:34 -05:00
parent 0ba73aa1fd
commit 94bbe93db9
11 changed files with 712 additions and 319 deletions

39
src/Util/Eff.md Normal file
View file

@ -0,0 +1,39 @@
# Effects utilities
Contains utility functions extending the functionality of the `eff` package.
```idris
module Util.Eff
import Control.Eff
import Text.ANSI
%default total
```
## Logging
Use the `WriterL "log" String` effect like a logging library. We'll provide a few "log levels" as verbs for the effect, but no filtering is done, when logging is enabled, all logs are always displayed, however the log level is indicated with a colored tag.
<!-- idris
namespace Logging
-->
```idris
export
info : Has (WriterL "log" String) fs => String -> Eff fs ()
info str =
let tag = show . bolden . show . colored Green $ "[INFO]"
in tellAt "log" (tag ++ ": " ++ str ++ "\n")
export
debug : Has (WriterL "log" String) fs => String -> Eff fs ()
debug str =
let tag = show . bolden . show . colored BrightWhite $ "[DEBUG]"
in tellAt "log" (tag ++ ": " ++ str ++ "\n")
export
warn : Has (WriterL "log" String) fs => String -> Eff fs ()
warn str =
let tag = show . bolden . show . colored Yellow $ "[WARN]"
in tellAt "log" (tag ++ ": " ++ str ++ "\n")
```