Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006219OCamlOCaml typingpublic2013-11-02 16:292014-05-05 19:19
Reporteryallop 
Assigned Toyallop 
PrioritynormalSeverityfeatureReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version4.02.0+dev 
Summary0006219: Existential types for exceptions
DescriptionIt would be useful for exceptions to support existential types via GADT-style declarations:

   exception E : 'a t -> exn
TagsNo tags attached.
Attached Files

- Relationships
related to 0005584resolvedgarrigue Open Extensible Types 

-  Notes
(0010576)
frisch (developer)
2013-11-04 13:58

Side note: the trunk version syntactically allows the suggested form, which is then rejected by the type-checker.
(0011172)
yallop (developer)
2014-04-02 14:48

This will be supported naturally if exceptions are subsumed by open types.
(0011358)
yallop (developer)
2014-05-05 19:18

This has been resolved by PR5584. Here's an example use, which now works in trunk:

   module type INT =
   sig
     type t
     val to_string : t -> string
     val div : t -> t -> t
     val zero : t
   end

   type 'i intmod = (module INT with type t = 'i)

   exception Division_by_zero : 'a intmod * 'a -> exn

   let div : type i. i intmod -> i -> i -> i =
     fun ((module I) as i) n d ->
       if d = I.zero then raise (Division_by_zero (i, n))
       else I.div n d

   let f (type i) ((module I : INT with type t = i) as i) x y =
     match div i x y with
       z ->
         Printf.printf "%s / %s => %s\n"
           (I.to_string x) (I.to_string y) (I.to_string z)
     | exception Division_by_zero ((module I), n) ->
         Printf.printf "%s / 0 => ERROR\n" (I.to_string n)

   (* prints "12 / 4 => 3" *)
   let _ = f (module Int32) 12l 4l

   (* prints "12 / 0 => ERROR" *)
   let _ = f (module Int64) 12L 0L

- Issue History
Date Modified Username Field Change
2013-11-02 16:29 yallop New Issue
2013-11-04 13:58 frisch Note Added: 0010576
2014-04-02 14:46 yallop Relationship added related to 0005584
2014-04-02 14:48 yallop Note Added: 0011172
2014-05-05 19:18 yallop Note Added: 0011358
2014-05-05 19:19 yallop Status new => resolved
2014-05-05 19:19 yallop Fixed in Version => 4.02.0+dev
2014-05-05 19:19 yallop Resolution open => fixed
2014-05-05 19:19 yallop Assigned To => yallop


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker