|
|
On 05/03/2015 06:37 PM, Orchid Win7 v1 wrote:
> On 03/03/2015 10:45 PM, Orchid Win7 v1 wrote:
>> It's a tad verbose (!!), but it works. The protocol is that every
>> top-level Haskell constant becomes a
>>
>> public static Thunk<...> OB_XXX = ...
>>
>> Any top-level constant that's a *function* also gets a
>>
>> public static T0 FN_XXX(Thunk<T1> arg1, Thunk<T2> arg2, Thunk<T3> args)
>> {
>> ...compiled code...
>> }
>
> ...yeah, that doesn't actually work.
>
> Haskell allows you to declare a "constant" who's type is polymorphic. C#
> does not.
In other fun news, C# allows you to use Func<Foo, Bar> to denote a
first-class function from type Foo to type Bar. It does *not* allow you
to represent a generic function in this manner, however. For example,
public List<TX> map<TX, TY>(Func<TX, TY>, List<TY>) {...}
is a valid generic method. But the *only* way to encode this as a Func<>
is to do
Func<Func<object, object>, List<object>, List<object>>
and then some nifty run-time type-checking. You know, the exact thing
that generics exists to prevent? :-P
Ah well, I suppose it's silly to expect the entire Haskell type system
to fit *exactly* into a radically different programming language. (I
suspect C++ could probably handle it though...)
Post a reply to this message
|
|