kuifje alternatives and similar packages
Based on the "Language" category.
Alternatively, view kuifje alternatives based on common mentions on social networks and blogs.
-
elm-compiler
Compiler for Elm, a functional language for reliable webapps. -
stylish-haskell
Haskell code prettifier [Moved to: https://github.com/haskell/stylish-haskell] -
haskell-src-exts
Manipulating Haskell source: abstract syntax, lexer, parser, and pretty-printer -
language-python
A parser for Python 2.x and 3.x written in Haskell -
nirum
Nirum: IDL compiler and RPC/distributed object framework for microservices -
tal
An implementation of Typed Assembly Language (Morrisett, Walker, Crary, Glew) -
aterm-utils
Utility functions for working with aterms as generated by Minitermite -
language-ecmascript
Haskell library: ECMAScript parser, pretty-printer and additional tools -
ministg
Ministg is an interpreter for a high-level, small-step, operational semantics for the STG machine. -
purescript-tsd-gen
TypeScript Declaration File (.d.ts) generator for PureScript
Static code analysis for 29 languages.
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of kuifje or a related project?
README
Kuifje
A prototype for a Quantitative Information Flow aware programming language.
Based on the paper: "Quantitative Information Flow with Monads in Haskell" by Jeremy Gibbons, Annabelle McIver, Carroll Morgan, and Tom Schrijvers.
Generating documentation
The important functions in the code are documented using Haddock notation.
To generate the documentation in HTML format, run cabal haddock
.
Defining a program
The syntax of the language is defined in the src/Syntax.hs
file. You can use the predefined constructor functions and the combinator <>
to define programs. Using the Control.Lens
library and helper functions for the syntax can simplify the implementation.
A brief example:
-- | State space for the program.
data SE = SE {
_x :: Integer,
_y :: Integer
} deriving (Eq, Ord)
makeLenses ''SE
-- | Initialize the state by giving a value to x and setting y to 0.
initSE :: Integer -> SE
initSE x = SE { _x = x, _y = 0 }
program :: Kuifje SE
program
= update (\s -> return (s.^y $ 0)) <> -- y := 0
while (\s -> return (s^.x > 0)) ( -- while (x > 0) {
update (\s -> return (s.^y $ (s^.x + s^.y))) <> -- y := x + y
update (\s -> return (s.^x $ (s^.x - 1))) -- x := x - 1
) -- }
For more elaborate syntax, see the examples.
Running the analysis
The function hysem
from the Semantics
module can be used to calculate the hyper-distributions based on a program and the input distributions.
The Semantics
module offers the bayesVuln
function to calculate the Bayes Vulnerability of distributions, this can be combined with the condEntropy
function to calculate the average entropy over a hyper-distribution.
Continuing the above example:
-- | Extract the meaningful variable from the state space.
project :: Dist (Dist SE) -> Dist (Dist Integer)
project = fmap (fmap (\s -> s^.y))
-- | Generate the hyper-distribution for an input of x : [5..8]
-- with uniform distribution.
hyper :: Dist (Dist Integer)
hyper = project $ hysem program (uniform [initSE x | x <- [5..8]])
run :: IO ()
run = do
putStrLn "> hyper"
print hyper
putStrLn "> condEntropy bayesVuln hyper"
print $ condEntropy bayesVuln hyper
-- > hyper
-- 1 % 4 1 % 1 15
-- 1 % 4 1 % 1 21
-- 1 % 4 1 % 1 28
-- 1 % 4 1 % 1 36
-- > condEntropy bayesVuln hyper
-- 1 % 1
Examples
The following examples are implemented in this repository:
- The Monty-Hall problem:
Monty.hs
- Defence against side-channels:
SideChannel.hs
- Password checker:
Password.hs