小编Joe*_*son的帖子

Haskell:为自定义类型导出显示

我有这种类型的定义:

data Operace = Op (Int->Int->Int) String (Int->Int->Int) deriving Show
Run Code Online (Sandbox Code Playgroud)

我想将此类型打印到交互式shell(GHCi)中.所有应该打印的是该String领域.

我试过这个:

instance Show Operace where
    show (Op op str inv) = show str
Run Code Online (Sandbox Code Playgroud)

但我仍然坚持下去

No instance for (Show (Int -> Int -> Int))
  arising from the 'deriving' clause of a data type declaration
Possible fix:
  add an instance declaration for (Show (Int -> Int -> Int))
  or use a standalone 'deriving instance' declaration,
       so you can specify the instance context yourself
When deriving the instance for (Show …
Run Code Online (Sandbox Code Playgroud)

haskell show typeclass ghci

30
推荐指数
2
解决办法
2万
查看次数

Why does this lens function require a type signature?

I'm writing a function which uses the lenses library, but curiously, the code doesn't compile when I remove the type annotation.

{-# LANGUAGE TemplateHaskell, Rank2Types #-}

import Control.Lens
import Control.Monad.State

import Data.List (elemIndex)

data MyRecord = MyRecord { _someField :: [Int], _anotherField :: [String] }
makeLenses ''MyRecord

updateRecord :: Eq a => a -> Lens' b [a] -> (Int -> c) -> State b c
updateRecord elem lens f = do field <- view lens <$> get
                              case elemIndex elem …
Run Code Online (Sandbox Code Playgroud)

haskell haskell-lens

7
推荐指数
1
解决办法
99
查看次数

如何获取共享COM Office加载项中当前文件的路径?

我想知道如何获取在Microsoft Office的共享COM加载项中打开的当前文件的路径.我在C#中使用Visual Studio 2010

我知道这个问题已被问到"如何在Excel加载项中获取文件?" 但这不能回答我的问题.

com visual-studio-2010 c#-4.0

5
推荐指数
1
解决办法
1718
查看次数

使用clang从命令行链接.dylib库

我正在尝试使用库编写C程序。该库提供了include/lib/目录.dylib,分别包含头文件和文件。

我的文件与include/和在同一目录中lib/。我正在尝试使用以下命令进行编译:

clang -I"./include/" -L"./lib/" -lcsfml-graphics -lcsfml-window test.c
Run Code Online (Sandbox Code Playgroud)

但是,当我运行程序时,出现以下错误:

% ./a.out 
dyld: Library not loaded: @rpath/libcsfml-graphics.2.4.dylib
  Referenced from: ~/src/CSFML-2.4-osx-clang/./a.out
  Reason: image not found
zsh: abort      ./a.out
Run Code Online (Sandbox Code Playgroud)

使用这些库进行编译的正确方法是什么?我宁愿在编写小程序时简单地使用命令行,而不必设置Xcode等。

% ls -l lib/
-rwxr-xr-x@ 1  staff   50296 Mar  1  2017 libcsfml-audio.2.4.0.dylib*
lrwxr-xr-x@ 1  staff      26 Mar  1  2017 libcsfml-audio.2.4.dylib@ -> libcsfml-audio.2.4.0.dylib
lrwxr-xr-x@ 1  staff      24 Mar  1  2017 libcsfml-audio.dylib@ -> libcsfml-audio.2.4.dylib
-rwxr-xr-x@ 1  staff  163680 Mar  1  2017 libcsfml-graphics.2.4.0.dylib*
lrwxr-xr-x@ 1  staff …
Run Code Online (Sandbox Code Playgroud)

c macos clang dylib

3
推荐指数
1
解决办法
892
查看次数

标签 统计

haskell ×2

c ×1

c#-4.0 ×1

clang ×1

com ×1

dylib ×1

ghci ×1

haskell-lens ×1

macos ×1

show ×1

typeclass ×1

visual-studio-2010 ×1