Skip to content

Simple exploratory CLI app tinkering with Cats, Cats Effect, fs2

Notifications You must be signed in to change notification settings

sangamon/funreverse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FunReverse

Simple Scala CLI app based on Cats, Cats Effect and fs2. The goal of this learning project was to exercise the combined use of these libraries with a simplistic scenario that still transcends single type class/construct/library examples.

Mission Statement

  • A command line REPL that prints the reverse of each input line. Empty line input exits processing.
  • Input/output pairs are appended to a log file together with a time stamp.
  • After REPL exit, read the log file and dump it to an XML file.

Sample Session

$ sbt run
[...]
*** FunReverse ***
Entering an arbitrary line will print the reverse of the input.
Entering an empty line will exit processing.
Binary call log is written to /home/patrick/prog/scala/funreverse/calls.binlog
> test
tset
> blah
halb
>
XML call log has been written to /home/patrick/prog/scala/funreverse/calls.xml
[success] Total time: 19 s, completed Apr 13, 2020 9:49:32 PM
$ cat /home/patrick/prog/scala/funreverse/calls.xml
<calls><call><time>2020-04-13T19:49:28.887Z</time><input>test</input><output>tset</output></call><call><time>2020-04-13T19:49:31.284Z</time><input>blah</input><output>halb</output></call></calls>

Implementation Notes

  • REPL is implemented via Monad#iterateWhile().
  • Logger instance is passed via ReaderT.
  • Log entries are written using scodec and read using scodec-stream.
  • XML is generated using the JDK StAX API.

About

Simple exploratory CLI app tinkering with Cats, Cats Effect, fs2

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages