小编BT.*_*BT.的帖子

Haskell:如何构建异构类型Any

我想建立一个类型,以匹配任何东西,但永远不会被使用.

例:

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)

haskell types

3
推荐指数
2
解决办法
105
查看次数

在main之前没有调用WinMain(C/C++程序入口点问题)

我的印象是这段代码

#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,如果这有帮助的话.

c c++ winapi winmain

0
推荐指数
1
解决办法
1651
查看次数

标签 统计

c ×1

c++ ×1

haskell ×1

types ×1

winapi ×1

winmain ×1