Re: Platform-Specific Extensions

Alastair Reid <[email protected]>
Newsgroups gmane.comp.lang.haskell.gui
Message-ID <[email protected]>
Wolfgang Thaller <[email protected]> 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                 [email protected]  
Reid Consulting (UK) Limited  http://www.reid-consulting-uk.ltd.uk/alastair/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.