Skip to content

Instantly share code, notes, and snippets.

@Kakadu
Created October 29, 2020 18:50
Show Gist options
  • Save Kakadu/77369b90d1619ed3364a56803244b1fe to your computer and use it in GitHub Desktop.
Save Kakadu/77369b90d1619ed3364a56803244b1fe to your computer and use it in GitHub Desktop.
ocaml error Type char/2 is not compatible with type char/2312
module Types : sig
type ('a, 'b) tag = Parsed of 'a * 'b option | Failed of 'b option
type ('stream, 'parsed, 'error) result = ('parsed * 'stream, 'error) tag
val bind : ('stream, 'parsed, 'error) result -> ('parsed -> [`Ok of 'parsed' | `Fail of 'error]) -> ('stream, 'parsed', 'error) result
end = struct
type ('a, 'b) tag = Parsed of 'a * 'b option | Failed of 'b option
type ('stream, 'parsed, 'error) result = ('parsed * 'stream, 'error) tag
let bind _ _ = assert false
end
module Token : sig
type t
val repr : t -> string
end = struct
type t
let repr _ = assert false
end
module Reason = struct type t end
class virtual char s =
let regexp = Re_str.regexp "'\\([^']\\|''\\|\\\\n\\|\\\\t\\)'" in
object(self : 'a)
method virtual get : String.t -> Re_str.regexp -> ('a, Token.t, Reason.t) Types.result
method getCHAR : ('a, char, Reason.t) Types.result =
Types.bind
(self#get "string constant" regexp)
(fun t -> `Ok ((Token.repr t).[0]))
(*
(< get : String.t ->
Re_str.regexp -> ('a, Token.t, Reason.t) Types.result;
getCHAR : ('a, char/2312, Reason.t) Types.result; .. >
as 'a, char/2, Reason.t)
Types.result = (char/2 * 'a, Reason.t) Types.tag
but an expression was expected of type
('a, char/2312, Reason.t) Types.result =
(char/2312 * 'a, Reason.t) Types.tag
Type char/2 is not compatible with type char/2312 = < .. >
*)
end[@@warning "-3"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment