My large Haskell + Python project KGcreator (tool for automating the generation of Knowledge Graphs) and auto code formatting
You might wonder what the topics of my large Haskell + Python project KGcreator and auto code formatting have to do with each other.
I addition to working on two Python books (Python Intelligent Systems and Deep Learning and Graph Databases), my main 'retirement' activity has been write a lot of Haskell code and a smaller amount of Python code for my KGcreator project. After reading a discussion on Hacker News yesterday about Python code tidy/auto-format tools, I decided to add Makefile targets.
After a 'stack install stylish-haskell hindent' and a 'pip install yapf', I added something like this to my Haskell top level Makefile:
And something like this to my Python top level Makefile:
I addition to working on two Python books (Python Intelligent Systems and Deep Learning and Graph Databases), my main 'retirement' activity has been write a lot of Haskell code and a smaller amount of Python code for my KGcreator project. After reading a discussion on Hacker News yesterday about Python code tidy/auto-format tools, I decided to add Makefile targets.
After a 'stack install stylish-haskell hindent' and a 'pip install yapf', I added something like this to my Haskell top level Makefile:
tidy: cd src/fileutils; stylish-haskell -i *.hs; hindent *.hs cd src/nlp; stylish-haskell -i *.hs; hindent *.hs cd src/sw; stylish-haskell -i *.hs; hindent *.hs cd src/webclients; stylish-haskell -i *.hs; hindent *.hs cd test; stylish-haskell -i *.hs; hindent *.hs
And something like this to my Python top level Makefile:
tidy: cd botorch_bayesian_optimization; yapf *.py --style='{indent_width: 2}' -i cd coref_anaphora_resolution_web_service; yapf *.py --style='{indent_width: 2}' -i cd data_fusion; yapf *.py --style='{indent_width: 2}' -i cd deep_learning_keras; yapf *.py --style='{indent_width: 2}' -i cd deep_learning_pytorch; yapf *.py --style='{indent_width: 2}' -i cd discrete_optimization; yapf *.py --style='{indent_width: 2}' -i ....Trivial stuff, but I already find my KGcreator and my books' codebases easier to work with. For Common Lisp and Scheme I always just rely on using the tab character to auto-indent and leave it at that. I use VSCode for both Haskell and Python development and after experimenting with a few extensions I decided it was easier to add a make target. Nothing is automated right now, I 'make tidy', 'make tests', and then 'git commit...' manually. Still to be done is adding git commit hooks. Fortunately I can use notes in one of my old blog posts as a guide :-)