package asak
Install
Dune Dependency
Authors
Maintainers
Sources
md5=dcf2006b1fb818261aab8fb7b4387b10
sha512=8ee28c765f5d5bf7f4caae9a8f806501f5563f17360ad3c9e1b78bbb849697ae53d0165a6e5eb38a061c92547f2f9863ae0e693fea7f76cecf1557ac1ccba2c2
Description
Asak provides functions to parse, type-check and identify similar OCaml codes. These functions are then used to partition codes implementing the same function and help to detect code duplication.
Published: 17 Jan 2020
README
asak
Asak is an OCaml library that allows to identify similar OCaml codes.
Why ?
For teaching
The module Asak.Partition
offers a function create
that produces a partition of codes implementing the same function, where two codes are in the same class if they are syntactically "close".
For redundancy detection
The binary anzad
can detect redundant definitions of an OCaml project built with dune
and compare it with a database of previously analyzed projects.
To use it on a project with sources in src/
, run:
dune build @check
anzad src/
How ?
The idea is to compare AST (Abstract Syntax Tree) of codes. However, the OCaml AST is too rich for our purpose (since, for example, match x with ...
and function ...
generate two different AST). We decided instead to use the Lambda language, an intermediate language in the OCaml compilation pipeline, where such syntactic sugar is optimized away.
To efficiently compare Lambda trees, we use the methodology of Chilowicz et al. which consist in hashing recursively trees.
We then compare hashes and provide a clustering of the closest functions.
But really, how ?
There is two cores:
Asak.Lambda_hash
, that defines a functionhash_lambda
which is hashing a Lambda expression, capturing the shape of the AST.Asak.Clustering
, that defines a functioncluster
which is making a kind of complete-linkage clustering of a list of hashes. This function can parallelize some work.
More details
A paper (in french) about asak was published in the proceedings of the JFLA (Journées Francophones des Langages Applicatifs) 2020. It can be found here: https://github.com/nobrakal/asak-paper/
Documentation
The documentation of the API is available here: https://nobrakal.github.io/asak/asak/.
A man page is available for the binary anzad
.
The name
This tool is about making partitions. "Partition" is the word in french for "sheet music". Consequently, its name is about music: asak is the name of Tuareg's traditional songs accompanied by a monochord violin.
This monochord violin is called an anzad, which is the name of the binary client of asak.
License and copyright
Asak is released under the MIT license. The copyright is held by IRIF / OCaml Software Foundation.
Authors
Asak is developed by Alexandre Moine.
Dependencies (4)
Used by (2)
-
learn-ocaml
>= "0.12" & < "1.0.0"
-
learn-ocaml-client
< "1.0.0"
Conflicts
None