-
Notifications
You must be signed in to change notification settings - Fork 4
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
Addition of a Void module #31
Comments
In SML, "Forall t. t" serves the purposes of a void type and is occupied by the single “value” bottom (undefined, nontermination).
E.g.
fun fail (s: string) = raise Fail s
fail : string -> ‘a (fail : (Forall ‘a). string -> ‘a or fail : string -> (Forall ‘a). ‘a)
It is not clear to me what additional utility a “void” type would add.
Dave MacQueen
On Feb 9, 2021, at 4:40 PM, Harrison Grodin ***@***.***> wrote:
Unsure if this is the best format/place for a new proposal (or if I should, say, create a Wiki page). If there's something else I should do, please let me know!
Often, it is useful to have access to an empty "void" type. A simple proposal might look like this:
signature VOID =
sig
type void
type t = void
val absurd : t -> 'a
end
structure Void :> VOID =
struct
datatype void = Void of void
type t = void
fun absurd (Void v) = absurd v
end
Perhaps a few other auxiliary functions could be useful, as well. For example:
val fail : string -> t (* raises `Fail` *)
val asLeft : ('a,t) either -> 'a
val asRight : (t,'a) either -> 'a
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub <#31>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAGXNPOQ44XDGEC6FXU4DNDS6HIW7ANCNFSM4XL7STYA>.
David MacQueen
[email protected]
|
Also discussed in here: SMLFamily/Successor-ML#32 |
Yes, by that argument, no abstract type is ever needed, you can just hack it up by other means.
The point is that void is an abstract type with specified operation, namely absurd aka nullary case. It ought to be in the Standard Basis.
More generally, datatype specifications ought to induce signatures, and nullary datatypes ought to be allowed. In that case you’d get void “for free” as part of a more general improvement to the language that results from revamping datatypes as modes of use of modules.
Bob
(c) Robert Harper. All Rights Reserved.
…On Feb 14, 2021, 15:56 -0500, David MacQueen ***@***.***>, wrote:
In SML, "Forall t. t" serves the purposes of a void type and is occupied by the single “value” bottom (undefined, nontermination).
E.g.
fun fail (s: string) = raise Fail s
fail : string -> ‘a (fail : (Forall ‘a). string -> ‘a or fail : string -> (Forall ‘a). ‘a)
It is not clear to me what additional utility a “void” type would add.
Dave MacQueen
> On Feb 9, 2021, at 4:40 PM, Harrison Grodin ***@***.***> wrote:
>
>
> Unsure if this is the best format/place for a new proposal (or if I should, say, create a Wiki page). If there's something else I should do, please let me know!
>
> Often, it is useful to have access to an empty "void" type. A simple proposal might look like this:
>
> signature VOID =
> sig
> type void
> type t = void
> val absurd : t -> 'a
> end
>
> structure Void :> VOID =
> struct
> datatype void = Void of void
> type t = void
> fun absurd (Void v) = absurd v
> end
> Perhaps a few other auxiliary functions could be useful, as well. For example:
>
> val fail : string -> t (* raises `Fail` *)
> val asLeft : ('a,t) either -> 'a
> val asRight : (t,'a) either -> 'a
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub <#31>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAGXNPOQ44XDGEC6FXU4DNDS6HIW7ANCNFSM4XL7STYA>.
>
David MacQueen
***@***.***
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
While there isn't any particular reason to produce a value of type datatype 'a term = Var of 'a | Node of string * 'a term list
(* simple example *)
fun traverse (t : void term) : string list =
case t of
Var v => absurd v
| Node (s, children) => s :: List.concatMap traverse children Here, it's useful to discuss both val match : string term * void term -> void term StringDict.t Similarly, with intrinsically-scoped lambda terms, datatype 'a lam = Var of 'a | App of 'a lam * 'a lam | Lam of 'a option lam
type closed = void lam
val I : closed = Lam (Var NONE)
val K : closed = Lam (Lam (Var (SOME NONE)))
val invalid : closed = Var (raise Fail "impossible") |
Unsure if this is the best format/place for a new proposal (or if I should, say, create a Wiki page). If there's something else I should do, please let me know!
Often, it is useful to have access to an empty "void" type. A simple proposal might look like this:
Perhaps a few other auxiliary functions could be useful, as well. For example:
The text was updated successfully, but these errors were encountered: