https://github.com/functionally/haquil
https://github.com/functionally/haquil
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/functionally/haquil
- Owner: functionally
- License: mit
- Created: 2022-11-10T06:36:54.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2022-11-10T06:53:23.000Z (about 3 years ago)
- Last Synced: 2025-02-24T08:18:19.524Z (11 months ago)
- Language: Haskell
- Size: 58.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: ReadMe.md
- Changelog: ChangeLog.md
- License: LICENSE
Awesome Lists containing this project
README
quil: An instruction set for quantum computing
==============================================
This Haskell library implements the Quil language for quantum computing, as specified in "A Practical Quantum Instruction Set Architecture" <>, using the indexing conventions in <>.
Please report issues at <>.
Example
-------
This example creates a wavefunction for the [Bell state](https://en.wikipedia.org/wiki/Bell_state) and then performs a measurement on its highest qubit.
> import Control.Monad.Random (evalRandIO)
> import Data.Qubit ((^^*), groundState, measure)
> import Data.Qubit.Gate (h, cnot)
> -- Construct the Bell state.
> let bell = [h 0, cnot 0 1] ^^* groundState 2
> bell
0.7071067811865475|00> + 0.7071067811865475|11> @ [1,0]
> -- Measure the Bell wavefunction.
> bell' <- evalRandIO $ measure [1] bell
> bell'
([(1,0)],1.0|00> @ [1,0])
> -- Measure it again.
> evalRandIO $ measure [1] bell'
([(1,0)],1.0|00> @ [1,0])
> -- Measure another Bell wavefunction.
> evalRandIO $ measure [1] bell
([(1,0)],1.0|00> @ [1,0])
> -- Measure another Bell wavefunction.
> evalRandIO $ measure [1] bell
([(1,1)],1.0|11> @ [1,0])