From: Dawid Toton <d0@wp.pl>
To: caml-list@inria.fr
Subject: [Caml-list] Forget a type without Obj.magic
Date: Fri, 03 Jun 2011 10:47:33 +0200 [thread overview]
Message-ID: <4DE89FA5.9040507@wp.pl> (raw)
I have the following situation:
______
type 'a consumer = 'a -> unit
type 'a inactive = ('a consumer -> unit) list
type active
val activate : 'a consumer -> 'a inactive -> active
type bottom = unit
val forget_type : 'a inactive -> bottom inactive
______
let activate consumer inactive =
let act inact = inact consumer in
List.map act inactive
let bottom = ()
let forget_type inactive =
let forget inact =
(fun simple_consumer ->
inact (fun _ -> simple_consumer bottom)
)
in
(List.map forget inactive
: unit inactive
)
______
I see that the function forget_type above is a waste of time: it
repackages functions that take () to functions that ignore the argument.
But the simple_consumer already ignores the () argument, since there is
no much use of it anyway.
My question is: how to change the above example, so that the forget_type
becomes just a typecast (or maybe a constant time operation)?
I think that the type and value called bottom in the above code are
currently not what I really want. Maybe even it should be called "top"
instead? The argument of simple_consumer should have a type of "values
impossible to use". How to express this?
Dawid
reply other threads:[~2011-06-03 8:47 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4DE89FA5.9040507@wp.pl \
--to=d0@wp.pl \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox