[Haskell-cafe] Type system extension

Bulat Ziganshin bulatz at HotPOP.com
Mon May 16 07:04:43 EDT 2005


Hello Thomas,

Sunday, May 15, 2005, 7:26:11 PM, you wrote:

TD> data SCode = SModule String [Export] | SUnknown

TD> It would be useful to specify a function as so:
TD> doSomethingToAModule :: SCode(SModule) -> SomeRandomOtherType

because constructor names are globally unique, this can be written just as:

doSomethingToAModule :: SModule -> SomeRandomOtherType

i also needed similar feature, but to keep data as part of complex
structure:

data X = X { field1 :: SModule
           , field2 :: ...
           }

if Haskell will allow to define new types by or'ing existing ones,
whis will solve both our problems (modulo syntax sugar):

data SModule  = SModule String [Export]
data SUnknown = SUnknown
data SCode    = SModule | SUnknown

this extension will even allow to create ad-hoc polymorphic functions
(!). but on other side - increased complexity and ambiguousity of type
inferencing

may be, adding only ability to "decompose" existing multi-variant
types, but not to compose arbitrary types will not give such pressure
on type inferencing system

-- 
Best regards,
 Bulat                            mailto:bulatz at HotPOP.com





More information about the Haskell-Cafe mailing list