QIO-1.3: The Quantum IO Monad is a library for defining quantum computations in Haskell

Safe HaskellSafe
LanguageHaskell2010

QIO.Vec

Description

This module defines a Vector as a list of pairs. In the context of QIO, a Vector is the type used to represent a probability distribution.

Synopsis

Documentation

newtype Vec x a Source #

A Vector over types x and a is a wrapper around list of pairs of a and x.

Constructors

Vec 

Fields

Instances

Num n => Monad (Vec n) Source #

Vectors, over Numeric types, can be defined as a Monad.

Methods

(>>=) :: Vec n a -> (a -> Vec n b) -> Vec n b #

(>>) :: Vec n a -> Vec n b -> Vec n b #

return :: a -> Vec n a #

fail :: String -> Vec n a #

Num n => Functor (Vec n) Source # 

Methods

fmap :: (a -> b) -> Vec n a -> Vec n b #

(<$) :: a -> Vec n b -> Vec n a #

Num n => Applicative (Vec n) Source # 

Methods

pure :: a -> Vec n a #

(<*>) :: Vec n (a -> b) -> Vec n a -> Vec n b #

(*>) :: Vec n a -> Vec n b -> Vec n b #

(<*) :: Vec n a -> Vec n b -> Vec n a #

(Show x, Show a) => Show (Vec x a) Source # 

Methods

showsPrec :: Int -> Vec x a -> ShowS #

show :: Vec x a -> String #

showList :: [Vec x a] -> ShowS #

empty :: Vec x a Source #

An empty Vector is defined as the empty list

(<@@>) :: (Num x, Eq a) => Vec x a -> a -> x Source #

The "probability" of an object in a Vector, is the sum of all the probabilities associated with that object.

(<**>) :: Num x => x -> Vec x a -> Vec x a Source #

A Vector can be multiplied by a scalar, by mapping the multiplcation over each probability in the vector.

(<++>) :: Vec x a -> Vec x a -> Vec x a Source #

Two Vectors can be added, using list concatenation.