jon.recoil.org

Module Core.NothingSource

This module extends Base.Nothing.

type t = Base.Nothing.t = |

Having [@@deriving enumerate] may seem strange due to the fact that generated val all : t list is the empty list, so it seems like it could be of no use.

This may be true if you always expect your type to be Nothing.t, but [@@deriving enumerate] can be useful if you have a type which you expect to change over time. For example, you may have a program which has to interact with multiple servers which are possibly at different versions. It may be useful in this program to have a variant type which enumerates the ways in which the servers may differ. When all the servers are at the same version, you can change this type to Nothing.t and code which uses an enumeration of the type will continue to work correctly.

This is a similar issue to the identifiability of Nothing.t. As discussed below, another case where [@deriving enumerate] could be useful is when this type is part of some larger type.

Similar arguments apply for other derivers, like globalize and sexp_grammar.

val globalize : Core.Nothing.t @ local -> Core.Nothing.t
include Sexplib0.Sexpable.S__stack with type t := Core.Nothing.t
val sexp_of_t__stack : Core.Nothing.t @ local -> Sexplib0.Sexp.t @ local
val t_sexp_grammar : Core.Nothing.t Sexplib0.Sexp_grammar.t @@ portable
val unreachable_code : Core.Nothing.t -> _ @@ portable

Because there are no values of type Nothing.t, a piece of code that has a value of type Nothing.t must be unreachable. In such an unreachable piece of code, one can use unreachable_code to give the code whatever type one needs. For example:

  let f (r : (int, Nothing.t) Result.t) : int =
    match r with
    | Ok i -> i
    | Error n -> Nothing.unreachable_code n
  ;;

Note that the compiler knows that Nothing.t is uninhabited, hence this will type without warning:

  let f (Ok i : (int, Nothing.t) Result.t) = i
val unreachable_code_local : Core.Nothing.t @ local -> _ @@ portable

The same as unreachable_code, but for local ts.

It may seem weird that this is identifiable, but we're just trying to anticipate all the contexts in which people may need this. It would be a crying shame if you had some variant type involving Nothing.t that you wished to make identifiable, but were prevented for lack of Identifiable.S here.

Obviously, of_string and t_of_sexp will raise an exception.

include Base.Identifiable.S__local__portable with type t := Core.Nothing.t
type comparator_witness = Base.Nothing.comparator_witness
val must_be_none : Core.Nothing.t option -> unit @@ portable

Ignores None and guarantees there is no Some _. A better replacement for ignore.

val must_be_empty : Core.Nothing.t list -> unit @@ portable

Ignores [] and guarantees there is no _ :: _. A better replacement for ignore.

val must_be_ok : ('ok, Core.Nothing.t) Base.Result.t -> 'ok @@ portable

Returns ok from Ok ok and guarantees there is no Error _.

val must_be_error : (Core.Nothing.t, 'err) Base.Result.t -> 'err @@ portable

Returns err from Error err and guarantees there is no Ok _.

val must_be_first : ('fst, Core.Nothing.t) Base.Either.t -> 'fst @@ portable

Returns fst from First fst and guarantees there is no Second _.

val must_be_second : (Core.Nothing.t, 'snd) Base.Either.t -> 'snd @@ portable

Returns snd from Second snd and guarantees there is no First _.

It may seem weird that this is identifiable, but we're just trying to anticipate all the contexts in which people may need this. It would be a crying shame if you had some variant type involving Nothing.t that you wished to make identifiable, but were prevented for lack of Identifiable.S here.

Obviously, of_string and t_of_sexp will raise an exception.

include Core.Identifiable.S__local with type t := Core.Nothing.t and type comparator_witness := Core.Nothing.comparator_witness
val bin_shape_t : Bin_prot.Shape.t
val t_of_sexp : Sexplib0.Sexp.t -> Core.Nothing.t
val sexp_of_t : Core.Nothing.t -> Sexplib0.Sexp.t
val of_string : string -> Core.Nothing.t
val to_string : Core.Nothing.t -> string
val pp : Base.Formatter.t -> Core.Nothing.t -> unit
val (>=) : Core.Nothing.t -> Core.Nothing.t -> bool
val (<=) : Core.Nothing.t -> Core.Nothing.t -> bool
val (=) : Core.Nothing.t -> Core.Nothing.t -> bool
val (>) : Core.Nothing.t -> Core.Nothing.t -> bool
val (<) : Core.Nothing.t -> Core.Nothing.t -> bool
val (<>) : Core.Nothing.t -> Core.Nothing.t -> bool
val equal : Core.Nothing.t -> Core.Nothing.t -> bool
val compare : Core.Nothing.t -> Core.Nothing.t -> int
val equal__local : Core.Nothing.t @ local -> Core.Nothing.t @ local -> bool
val compare__local : Core.Nothing.t @ local -> Core.Nothing.t @ local -> int
val ascending : Core.Nothing.t -> Core.Nothing.t -> int
val descending : Core.Nothing.t -> Core.Nothing.t -> int
val between : Core.Nothing.t -> low:Core.Nothing.t -> high:Core.Nothing.t -> bool
Sourcemodule Map : sig ... end
Sourcemodule Set : sig ... end
Sourcemodule Table : sig ... end
Sourcemodule Hash_set : sig ... end
Sourcemodule Hash_queue : sig ... end
include Diffable.S_atomic with type t := Core.Nothing.t
Sourcemodule Diff : sig ... end
Sourcemodule Stable : sig ... end