File: clusters.mli

package info (click to toggle)
ocaml-deriving-ocsigen 0.6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 628 kB
  • ctags: 1,159
  • sloc: ml: 6,334; makefile: 63; sh: 18
file content (42 lines) | stat: -rw-r--r-- 1,193 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
(* Copyright Grégoire Henry 2011.
   This file is free software, distributed under the MIT license.
   See the file COPYING for details.
*)

(* A cluster is the finite set of recursive class instances needed for
   deriving a "regular" recursive type declaration. For example:

   type 'a t = A of 'a | B of 'a * 'a t | I of int t

   The corresponding cluster is:

   { 'a t ; int t }.

   For multiple recursives declarations, we may group clusters by the
   set of free variables involved in the required instances. For
   example:

   type 'a t1 = ('a, int) t2
   and ('a, 'b) t2 = A of 'a t1 | B of 'b deriving (Show)

   Types declaration t1 and t2 share the same clusters:

   { 'a t1; ('a, int) t2 }.

   This notion of clusters allows to be less restrictive with
   recursive type declaration than previous version of deriving. It's
   still not sufficient for handling "non-regular" datatypes like:

   type 'a nested = Z of nested | S of ('a * 'a) nested

   because the set of required instance would be infinite.

*)

type cluster = {
  params: Type.param list;
  decls: Type.decl list;
  instances: (Type.name * Type.expr list) list;
}

val make: Type.decl list -> cluster list