All Projects → Lysxia → coq-simple-io

Lysxia / coq-simple-io

Licence: MIT License
IO for Gallina

Programming Languages

Coq
218 projects
ocaml
1615 projects
Makefile
30231 projects
shell
77523 projects

Projects that are alternatives of or similar to coq-simple-io

autosubst
Automation for de Bruijn syntax and substitution in Coq [maintainers=@RalfJung,@co-dan]
Stars: ✭ 41 (+95.24%)
Mutual labels:  coq
finmap
Finite sets, finite maps, multisets and generic sets
Stars: ✭ 45 (+114.29%)
Mutual labels:  coq
Table-Detection-Extraction
Detect the tables in a form and extract the tables as well as the cells of the tables.
Stars: ✭ 35 (+66.67%)
Mutual labels:  extraction
ti recover
Appcelerator Titanium APK source code recovery tool
Stars: ✭ 17 (-19.05%)
Mutual labels:  extraction
MtacAR
Mtac in Agda
Stars: ✭ 29 (+38.1%)
Mutual labels:  coq
chapar
A framework for verification of causal consistency for distributed key-value stores and their clients in Coq [maintainer=@palmskog]
Stars: ✭ 29 (+38.1%)
Mutual labels:  coq
coq-art
Coq code and exercises from the Coq'Art book [maintainers=@ybertot,@Casteran]
Stars: ✭ 57 (+171.43%)
Mutual labels:  coq
zauberlehrling
Collection of tools and ideas for splitting up big monolithic PHP applications in smaller parts.
Stars: ✭ 28 (+33.33%)
Mutual labels:  extraction
ltac2-tutorial
Ltac2 tutorial
Stars: ✭ 27 (+28.57%)
Mutual labels:  coq
Stanford-NER-Python
Stanford Named Entity Recognizer (NER) - Python Wrapper
Stars: ✭ 63 (+200%)
Mutual labels:  extraction
RDMP
Research Data Management Platform (RDMP) is an open source application for the loading,linking,anonymisation and extraction of datasets stored in relational databases.
Stars: ✭ 20 (-4.76%)
Mutual labels:  extraction
SevenZipSharp
Fork of SevenZipSharp on CodePlex
Stars: ✭ 171 (+714.29%)
Mutual labels:  extraction
coq-of-ocaml
Formal verification of OCaml programs
Stars: ✭ 161 (+666.67%)
Mutual labels:  coq
multinomials
Multinomials for the Mathematical Components library.
Stars: ✭ 12 (-42.86%)
Mutual labels:  coq
InfSeqExt
A Coq library for reasoning (co)inductively on infinite sequences using LTL-like modal operators
Stars: ✭ 12 (-42.86%)
Mutual labels:  coq
LibHyps
A Coq library providing tactics to deal with hypothesis
Stars: ✭ 14 (-33.33%)
Mutual labels:  coq
H2PC TagExtraction
A application made to extract assets from cache files of H2v using BlamLib by KornnerStudios.
Stars: ✭ 12 (-42.86%)
Mutual labels:  extraction
AutoIt-Ripper
Extract AutoIt scripts embedded in PE binaries
Stars: ✭ 101 (+380.95%)
Mutual labels:  extraction
Set-Theory
Coq encoding of ZFC and formalization of the textbook Elements of Set Theory
Stars: ✭ 55 (+161.9%)
Mutual labels:  coq
Abel
A proof of Abel-Ruffini theorem.
Stars: ✭ 26 (+23.81%)
Mutual labels:  coq

Purely functional IO for Coq Build Status

Hello World in Coq

From SimpleIO Require Import SimpleIO.
From Coq Require Import String.
#[local] Open Scope string_scope.

Definition main : IO unit :=
  print_endline "Hello, world!".

RunIO main.

The coq-simple-io library provides tools to implement IO programs directly in Coq, in a similar style to Haskell.

  • IO monad
  • Bindings to OCaml standard library
  • RunIO command for running programs

Facilities for formal verification are not included. There is no canonical way to describe the effects of the arbitrary foreign constructs that this library allows, so this library commits to none.

A possible workflow is to generalize your program to any monad with a certain interface, specialize it to a mathematical monad (e.g., state, or free monad) for formal verification, and to IO for execution. coqffi provides a toolchain for generating such interfaces from OCaml interfaces.

Installation

From OPAM

opam install coq-simple-io

From this repository as a local package

# Clone this repository
git clone https://github.com/Lysxia/coq-simple-io

# Register it with opam (the last argument is the path to the repo)
opam pin add coq-simple-io ./coq-simple-io

Documentation

The documentation of the latest released version is available on website at https://lysxia.github.io/coq-simple-io/toc.html

Consult the OCaml user manual for detailed description of extracted code.

Interface

To use this library:

Require Import SimpleIO.SimpleIO.

(* And to use the monadic notations: *)
Import IO.Notations.
Local Open Scope io_scope.

(* Equivalent notations can be found ext-lib, using its [Monad] type class. *)

Combinators for IO actions.

Parameter IO : Type -> Type.

Module IO.

Parameter ret : forall {a}, a -> IO a.
Parameter bind : forall {a b}, IO a -> (a -> IO b) -> IO b.
Parameter fix_io : forall {a b}, ((a -> IO b) -> (a -> IO b)) -> a -> IO b.
(* etc. *)

Module Notations.
Notation "c >>= f" := (bind c f)
Notation "f =<< c" := (bind c f)
Notation "x <- c1 ;; c2" := (bind c1 (fun x => c2))
Notation "e1 ;; e2" := (_ <- e1%io ;; e2%io)%io
Notation delay io := (delay_io (fun _ => io)).
End Notations.

End IO.

Defining IO actions

The IO type extracts to the following definition in OCaml:

(* Implicitly [forall r, (a -> r) -> r]. *)
type 'a coq_IO = ('a -> Obj.t) -> Obj.t

So an effectful function f : t -> u -> v in OCaml can be wrapped as a Coq function f : t -> u -> IO v in the following way:

Parameter f : t -> u -> IO v.
Extract Constant f => "fun a b k -> k (f a b)".

Basically, add an extra parameter k and apply it to the OCaml function call.

This boilerplate can also be generated from OCaml interfaces using coqffi.

Library organization

The source code can be found under src/.

  • SimpleIO.SimpleIO: Reexports default modules.

Default modules

The following modules are imported with SimpleIO.SimpleIO.

  • SimpleIO.IO_Monad: Definition of IO and basic combinators.
  • SimpleIO.IO_Stdlib: Wrappers around Stdlib from OCaml's standard library.
  • SimpleIO.IO_StdlibAxioms: Basic theory for pure Stdlib functions.
  • SimpleIO.IO_Exceptions: Catch common exceptions.
  • SimpleIO.IO_RawChar: Utilities that rely on ExtrOcamlString.
  • SimpleIO.IO_String: Operations on OCaml strings.

Auxiliary modules

The following module can be imported separately. They correspond to modules from the OCaml standard library.

  • SimpleIO.IO_Bytes: Mutable byte sequences.
  • SimpleIO.IO_Random: Pseudo-random number generators (PRNG).
  • SimpleIO.IO_Float: Floating-point arithmetic.
  • SimpleIO.IO_Unix: Interface to the Unix system.
  • SimpleIO.IO_Sys: System interface.

Unsafe modules

  • SimpleIO.IO_Unsafe: Unsafe operations.
  • SimpleIO.IO_UnsafeNat: Pervasives functions adapted to nat (unsafety because of overflow and underflow).

Related

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].