yggdrasil-0.1.0.0: Executable specifications of composable cryptographic protocols.

Safe HaskellNone
LanguageHaskell2010

Yggdrasil.Distribution

Description

Provides primitives for high-level cryptographic sampling.

Synopsis

Documentation

type Distribution = DistributionT Identity Source #

Allows randomly sampling elements of type b.

newtype DistributionT m b Source #

Allows randomly sampling elements of type b in the context of monad m.

Constructors

DistributionT 

Fields

Instances
MonadTrans DistributionT Source # 
Instance details

Defined in Yggdrasil.Distribution

Methods

lift :: Monad m => m a -> DistributionT m a #

Monad m => Monad (DistributionT m) Source # 
Instance details

Defined in Yggdrasil.Distribution

Methods

(>>=) :: DistributionT m a -> (a -> DistributionT m b) -> DistributionT m b #

(>>) :: DistributionT m a -> DistributionT m b -> DistributionT m b #

return :: a -> DistributionT m a #

fail :: String -> DistributionT m a #

Monad m => Functor (DistributionT m) Source # 
Instance details

Defined in Yggdrasil.Distribution

Methods

fmap :: (a -> b) -> DistributionT m a -> DistributionT m b #

(<$) :: a -> DistributionT m b -> DistributionT m a #

Monad m => Applicative (DistributionT m) Source # 
Instance details

Defined in Yggdrasil.Distribution

Methods

pure :: a -> DistributionT m a #

(<*>) :: DistributionT m (a -> b) -> DistributionT m a -> DistributionT m b #

liftA2 :: (a -> b -> c) -> DistributionT m a -> DistributionT m b -> DistributionT m c #

(*>) :: DistributionT m a -> DistributionT m b -> DistributionT m b #

(<*) :: DistributionT m a -> DistributionT m b -> DistributionT m a #

class Sampler s where Source #

Provides randomness.

Minimal complete definition

sampleCoin

Methods

sampleCoin :: s -> (Bool, s) Source #

Produce a bit of randomness.

sample :: s -> DistributionT m b -> m (b, s) Source #

Samples a distribution.

sample' :: Monad m => s -> DistributionT m b -> m b Source #

Samples a distribution, discarding the result randomness.

Instances
Sampler SystemDRG Source # 
Instance details

Defined in Yggdrasil.Distribution

liftDistribution :: Monad m => Distribution b -> DistributionT m b Source #

Lifts a Distribution to an arbitrary monadic DistributionT.

coin :: Distribution Bool Source #

Tosses a fair coin.

uniform :: [a] -> Distribution a Source #

A uniform Distribution over all elements of [a].