[mercury-users] Maths and contexts.
Paul Bone
pbone at csse.unimelb.edu.au
Sat Apr 21 09:18:36 AEST 2012
On Sat, Apr 21, 2012 at 12:43:38AM +1000, Julien Fischer wrote:
> Specifically, how does a given context type get associated with the result
> value here? Since C is universally quantified it must be passed in
> by the caller, but nothing else in this API that will provide a binding
> for it.
>
> The signature for to_number actually needs to be something like:
>
> :- func to_number(C, string) = dec(C) <= context(C).
>
> i.e. at some point you need to actually associate a particular context
> with a (set of) dec/1 value(s).
I was thinking that "it would be constrained by the type system" and didn't
worry about it anymore, forgetting that you'd either have to construct a value
of this type or use a type declration as Mark suggested.
> The other limitation of this approach is that you are limited to the
> set of context types that are defined in your program. You cannot
> construct new contexts at runtime.
>
Thanks, I didn't notice these problems.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: Digital signature
URL: <http://lists.mercurylang.org/archives/users/attachments/20120421/ea8995cc/attachment.sig>
More information about the users
mailing list