Permalink
Browse files

Let the compiler infer the type of the (X)HTML output for the entries.

  • Loading branch information...
1 parent 298c05b commit e5048a971f3e4289855214418338ac032f11ea4c @mfp committed Apr 13, 2009
Showing with 33 additions and 39 deletions.
  1. +21 −21 catalog.ml
  2. +2 −2 node.ml
  3. +8 −9 node.mli
  4. +1 −0 ocsiblog.mli
  5. +1 −7 simple_markup__html.ml
View
@@ -4,28 +4,28 @@ open ExtString
module type ENTRY =
sig
- type entry
+ type 'a entry
type sort_criterion
- val name : entry -> string
- val tags : entry -> string list
- val deps : entry -> string list
- val signal_deps_changed : entry -> unit
+ val name : _ entry -> string
+ val tags : _ entry -> string list
+ val deps : _ entry -> string list
+ val signal_deps_changed : _ entry -> unit
val compare :
- ?secondary : sort_criterion list -> sort_criterion -> entry -> entry -> int
+ ?secondary : sort_criterion list -> sort_criterion -> 'a entry -> 'a entry -> int
end
module type S =
sig
- type entry
+ type 'a entry
type sort_criterion
- type t
- val refresh : t -> unit
- val entries : t -> entry list
+ type 'a t
+ val refresh : _ t -> unit
+ val entries : 'a t -> 'a entry list
val sorted_entries :
?reverse : bool ->
- ?secondary : sort_criterion list -> sort_criterion -> t -> entry list
- val get_entry : t -> string -> entry option
- val has_entry : t -> string -> bool
+ ?secondary : sort_criterion list -> sort_criterion -> 'a t -> 'a entry list
+ val get_entry : 'a t -> string -> 'a entry option
+ val has_entry : _ t -> string -> bool
end
let compare_by_criteria basic_comparison ?(extra = []) crit =
@@ -44,29 +44,29 @@ let dir_filter_map f dir =
module Make(Entry : sig
include ENTRY
- val make : name:string -> file:string -> entry
+ val make : name:string -> file:string -> 'a entry
end)
: sig
- include S with type entry = Entry.entry
+ include S with type 'a entry = 'a Entry.entry
and type sort_criterion = Entry.sort_criterion
- val make : string -> t
+ val make : string -> 'a t
end =
struct
module M = Map.Make(String)
module S = Set.Make(String)
- type entry = Entry.entry
+ type 'a entry = 'a Entry.entry
type sort_criterion = Entry.sort_criterion
- type t = {
+ type 'a t = {
basedir : string;
- mutable entries : entry_info M.t;
+ mutable entries : 'a entry_info M.t;
}
- and entry_info = {
+ and 'a entry_info = {
e_time : float;
e_name : string;
- e_data : entry;
+ e_data : 'a entry;
}
let (/^) = Filename.concat
View
@@ -4,12 +4,12 @@ open Printf
module S = Set.Make(String)
-type entry = {
+type 'html entry = {
name : string;
title : string;
date : float;
markup : Simple_markup.paragraph list;
- mutable html : Simple_markup__html.html_output XHTML.M.elt list option;
+ mutable html : 'html XHTML.M.elt list option;
deps : string list Lazy.t;
tags : string list;
syndicated : bool;
View
@@ -3,16 +3,15 @@ include Catalog.ENTRY with type sort_criterion = [ `Date | `Title ]
val split_headers_body : string -> (string * string) list * string list
-val make : name:string -> file:string -> entry
-val date : entry -> float
-val markup : entry -> Simple_markup.paragraph list
-val syndicated : entry -> bool
-val allow_comments : entry -> bool
-val title : entry -> string
+val make : name:string -> file:string -> 'html entry
+val date : _ entry -> float
+val markup : _ entry -> Simple_markup.paragraph list
+val syndicated : _ entry -> bool
+val allow_comments : _ entry -> bool
+val title : _ entry -> string
val get_html :
- (Simple_markup.paragraph list ->
- Simple_markup__html.html_output XHTML.M.elt list) ->
- entry -> Simple_markup__html.html_output XHTML.M.elt list
+ (Simple_markup.paragraph list -> 'html XHTML.M.elt list) ->
+ 'html entry -> 'html XHTML.M.elt list
val is_inner_link : string -> bool
View
@@ -0,0 +1 @@
+(* No functionality exported by the Ocsiblog module *)
View
@@ -3,11 +3,6 @@
open Simple_markup
open XHTML.M
-type html_output =
- [`Address | `Blockquote | `Del | `Div | `Dl | `Fieldset
- | `Form | `H1 | `H2 | `H3 | `H4 | `H5 | `H6 | `Hr | `Ins
- | `Noscript | `Ol | `P | `Pre | `Script | `Table | `Ul ]
-
let rec elm_to_html ~render_pre ~render_link ~render_img elm =
let self = elm_to_html ~render_pre ~render_link ~render_img in
let item l = li (List.map self l)
@@ -50,6 +45,5 @@ and text_to_html ~render_link ~render_img = function
end
| Image href -> render_img href
-let to_html ~render_pre ~render_link ~render_img l :
- [> html_output] XHTML.M.elt list =
+let to_html ~render_pre ~render_link ~render_img l =
List.map (elm_to_html ~render_pre ~render_link ~render_img) l

0 comments on commit e5048a9

Please sign in to comment.