[GUI] Re: Platform-Specific Extensions

Alastair Reid alastair@reid-consulting-uk.ltd.uk
Sun, 27 Apr 2003 14:35:50 +0100


Wolfgang Thaller <wolfgang.thaller@gmx.net> writes:
> Proposal for Platform-Specific extensions:
> [...]
> Opinions?

Sounds like a fine plan.  

One little detail: what about datatype declarations?

Suppose the standard version provides a datatype like this:

  data T = A Int | B Float

and the foo backend has a third option 'C Char', I can either do:

  data T = A Int | B Float | C_ext Char

or

  data T     = A Int | B Float
  data T_ext = T_std T | C_ext Char

or 

  data T_ext = A_ext Int | B_ext Float | C_ext Char

The first is more pleasant to use.

The second makes the use of an extension more explicit and is less
liable to result in exceptions if user code does case analysis on this
type.

The third seems like a reasonable compromise between the two and is
probably my favourite at the moment.  We'd probably want to provide
helper functions with types like these:

  to_T_ext   :: T -> T_ext
  from_T_ext :: T_ext -> Maybe T


I'm not especially happy with any of these but I suspect they're
pretty much the best that can be done within Haskell's type system.


--
Alastair Reid                 alastair@reid-consulting-uk.ltd.uk  
Reid Consulting (UK) Limited  http://www.reid-consulting-uk.ltd.uk/alastair/