[Haskell-cafe] Mapping Haskell Concepts To C# 3

Sebastian Sylvan sebastian.sylvan at gmail.com
Sat May 17 15:51:59 EDT 2008

2008/5/17 Kaveh Shahbazian <kaveh.shahbazian at gmail.com>:

> I have question on mapping some Haskell concepts to C# 3 ones. Maybe there
> are not any strict equivalents; yet it helps:
> 1 - What is the equivalent of "Type Constructor" in C#?

Class declaration. Generic ones. E.g. List<int>, is a type where the type
constructor List has been applied to the type int.

> 2 - What is the equivalent of "Data Constructor" in C#?

Constructors, I guess.

> 3 - What is the logical implementation of pattern matching in C#? (For
> example using structures with indicator fields or using interfaces and
> inheritance and dynamically dispatch in calling overloaded methods. Also
> this question contain a hidden one...GADTs!)

You can use an abstract base class, and then inherit one class for each
constructor (e.g. base class Expression, and concrete subclasses Mul, Add,
etc.). Then you can use runtime type reflection to figure out which kind of
Expression you have and branch on it.

Sebastian Sylvan
UIN: 44640862
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080517/91799cc2/attachment.htm

More information about the Haskell-Cafe mailing list