Note not "functional dependency". Are there tools available that allow me to build a static function dependency graph from source code? Something which indicates to me which functions depend on which other ones in a graphical manner.
Yes, there certainly are. If you look in the Development category on Hackage, you'll find tools for:
graphing package dependencies -- n.b requres older cabal
graphing module dependencies
graphing function calls
graphing running data structures
In particular, SourceGraph contains many analysis passes, including:
visualizing function calls
computing cyclomatic complexity
visualizing module imports
Other tools that you might be interested in are:
HPC, for visualizing test coverage
ThreadScope, for visualizing runtime behavior
lscabal, extract modules from a package
Here is the functional call graph produced by SourceGraph run over cabal2arch:
Related
I searched about the JAGS's manual and one post (here in 2012) about the ordinary differential equation (ode). I was thinking JAGS can because it's similar to WinBUGS (which does it through WBdiff interface). However, if I let JAGS read in my ode code, it cannot even recognize the D(y[...], t) expression.
Can JAGS deal with ode? Maybe I missed a plug-in in JAGS like WBdiff?
While WinBUGS/OpenBUGS/JAGS have almost equivalent syntax/feature sets, there are a few differences between them: one of these is that there is no ODE solver included as part of a standard JAGS installation.
However, JAGS is extensible using user-specified modules (like the plug-ins you mentioned), which provide new functions/distributions using C++ code that can then be used within JAGS when that module is loaded. It would certainly be possible to implement an ODE this way using e.g. the ODE solvers included in the boost C++ library. To do so you will need the following:
Familiarity with C++
Instructions for how to build a module for JAGS
I can't help you with the former, so this may be a dead-end for you if you have never used C++ before. But there is a tutorial available for how to build a JAGS module: https://pubmed.ncbi.nlm.nih.gov/23959766/ This article shows how to build a standalone module, but if you are happy to accept the limitation of using JAGS from R (as most people do) then it is MUCH easier to build a JAGS module within an R package - you could follow code in the runjags package as an example https://cran.r-project.org/package=runjags
If you are thinking of trying to do this yourself then I could potentially help with a few pointers along the way. Of course, it is also possible that someone else has already done this, but if so then I am not aware of it.
As part of a research project on property-based testing, I need to do static whole-program analysis of Haskell programs. I'm looking for suggestions on how to implement whole-program analysis of Haskell programs, hopefully without building lots of infrastructure myself.
I looked at Template Haskell, which has many of the capabilities I need, but is missing a key feature: in Template Haskell as implemented in GHC, there appears to be no way to get the definition of a function by name. (Related SO question: How to get the declaration of a function using `reify`?)
I suspect that there might be some way of doing whole-program analysis of Haskell programs using the GHC API, but I can't easily determine how this might be done from the GHC API documentation.
In particular, given a function call site, I need to be able to look up the corresponding function definition(s). I'm especially interested in Template Haskell or GHC API-based solutions.
Is there any way to do whole-program analysis of Haskell programs without building all the infrastructure myself?
I'm working on a Python/Haskell project and I'm looking for alternatives to Makefile. Obvious choices are Python SCons and Haskell Shake. Since I have no experience with either of them, I'd like to ask if there is any comparison of their drawbacks and advantages.
Update: The project has somewhat complex requirements for building:
Let the user configure the build - like options to enable/disable, paths to tools etc.
There are both Haskell and Python files generated at compile time. Their dependencies should work properly.
There are multiple Haskell programs that share most of the source files. I'd like so that:
it's possible to build each one individually, not building the sources that aren't needed;
source files aren't built multiple times when compiling multiple programs;
yet achieve parallelism during compilation, if possible.
Check for several installed programs on target systems and their paths (like python, flock etc.)
Check for dependencies on target systems, both Python, Haskell.
Parametrize the build according to the dependencies - if the dependencies for testing are missing, it should still be possible to build the project, skipping the tests (and informing the user about it).
There is a Why Shake? document that gives reasons to chose Shake over other build systems, but it does not focus on a comparison to SCons.
Update: All of your requirements seem easy enough to express in Shake (ask on StackOverflow if you get stuck with any of them). As to Shake vs SCons:
Shake is particularly good at dealing with generated files with dependencies that cannot be statically predicted, particularly if you are generating the files from programs you compile.
Building the Haskell parts of your project is likely to be harder than building the Python (since Haskell has a richer structure and more complex compiler). Using Shake makes it easier to tap into existing examples of compiling Haskell and use libraries for parsing Haskell if you need it.
There is a SCons wiki page that compares it to other build tools, unfortunately there is no comparison there with Haskell/Shake.
Also, this question may help.
SCons really shines as compared to other tools (especially make and cmake) by its Python syntax, and its implicit dependency system that is very accurate and easy to use.
Any suggestions for a good graph and network library for Haskell ?
I'm looking on functionality something like which networkx library has for Python.
I've found fgl (also see home page) quite easy to work with. I'm not familiar with networkx, so I don't know how it compares.
There's a graph data-structure in the containers package. You can view the interface for it here.
Additionally, you can search through all of the packages available on the haskell-platform or additional packages through Cabal using Hayoo!
It's more than a year old question, but in case someone looks for the lib - the igraph package provides the bindings to all functions about graph properties of the igraph-C library. It won't compile with the igraph-C versions newer than 0.6.5, because the authors don't have time to maintain it, as Nils Schweinsberg said: Pull requests are wellcome. Also not all functions from the original library have the Haskell bindings, but one can write some using the FFI.
fgl is very beautiful library implementing the functional concept of inductive graphs, but it lacks the functionality of the igraph library: You can create directed/undirected weighted/unweighted graphs and have the algorithms implemented taking that into account.
The igraph package could be a very valuable library for the Haskell community if an experienced haskeller took care of it further.
Note not "functional dependency". Are there tools available that allow me to build a static function dependency graph from source code? Something which indicates to me which functions depend on which other ones in a graphical manner.
Yes, there certainly are. If you look in the Development category on Hackage, you'll find tools for:
graphing package dependencies -- n.b requres older cabal
graphing module dependencies
graphing function calls
graphing running data structures
In particular, SourceGraph contains many analysis passes, including:
visualizing function calls
computing cyclomatic complexity
visualizing module imports
Other tools that you might be interested in are:
HPC, for visualizing test coverage
ThreadScope, for visualizing runtime behavior
lscabal, extract modules from a package
Here is the functional call graph produced by SourceGraph run over cabal2arch: