我想建立一个类型,以匹配任何东西,但永远不会被使用.
例:
type Any = forall a. a
f :: (x, Any) -> (Any, y) -> (x,y)
f (x,_) (_,y) = (x,y)
Run Code Online (Sandbox Code Playgroud)
{-# LANGUAGE ImpredicativeTypes #-}如果我尝试,这编译得很好
f ("hi", 2) (3, (1, 2))
Run Code Online (Sandbox Code Playgroud)
我收到错误:
<interactive>:19:9:
No instance for (Num a) arising from the literal `2'
Possible fix:
add (Num a) to the context of a type expected by the context: a
In the expression: 2
In the first argument of `f', namely `("hi", 2)'
In the expression: f ("hi", 2) …Run Code Online (Sandbox Code Playgroud) 我的印象是这段代码
#include <windows.h>
#include <stdio.h>
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
printf("WinMain\n");
return 0;
}
int main()
{
printf("main\n");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
会输出WinMain,但当然没有任何方法可以达到预期效果.
无论如何,有人可以告诉我如何让这个程序首先运行WinMain(我确实有理由同时使用它们).我正在运行带有mingw的Windows 7,如果这有帮助的话.