Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use the program #5

Open
Ayoya22 opened this issue Nov 5, 2019 · 3 comments
Open

How to use the program #5

Ayoya22 opened this issue Nov 5, 2019 · 3 comments

Comments

@Ayoya22
Copy link

Ayoya22 commented Nov 5, 2019

Hello, I am new to Ocaml, please can you help me with simple instructions and concrete examples on how to run the program and also how I can use it to solve related problems.
Thanks

@marcoonroad
Copy link
Owner

marcoonroad commented Nov 11, 2019

Hi Djoukam,

The intent and purpose of this library is to write enforced program invariants on type-level, but the proper validation is deferred to actual program execution/run-time. The only benefit of the usage of this library is when you and your team/coworkers use OCaml on the job codebase. Out of such context, this library is useless. I would recommend better tools for formal verification such as Coq, Idris or even property-based testing libraries such as QuickCheck (for Haskell) and Hypothesis (for Python). Of course, there are a bunch of property-based testing tools for other languages if your team uses another programming language.

Feel free to DM me if you need more guidance.

@Ayoya22
Copy link
Author

Ayoya22 commented Nov 19, 2019 via email

@marcoonroad
Copy link
Owner

To use this library properly, you need a good knowledge of OCaml's modules and functors. A good resource covering such concepts is the OCaml's Real World book:

I also recommend playing around with an interactive REPL for prototyping, utop is the most known one. Once you have an environment set up on your machine, including OPAM, you can install this library, then type on Linux's terminal:

utop

And inside the REPL, typing:

#require "subtype-refinement";;

And after:

open Subtype_refinement;;

Now you can create type refinements based on arbitrary constraints. The test here covers better examples than the README itself (which I'll improve soon once I have some time).

Library details (you can skip if you wish)

The library basically creates a generative module with fresh private type of functor's parameter (the constraint/"typeclass" module). By generative, if we have two modules M1 and M2 which are the result of a functor application F(M0) (so M1 = F(M0) and M2 = F(M0)), both M1 and M2 will contain different types, that is, M1 != M2 (with applicative functors, both M1 and M2 will share the same type constraint, a behavior akin to Haskell's typeclasses, that is, M1 == M2). And by private, it means that only the module can construct/make such private types, and the user can later upcast these private types carrying invariants. This is sometimes called a "translucent" type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants