我有这种类型的定义:
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) 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) 我想知道如何获取在Microsoft Office的共享COM加载项中打开的当前文件的路径.我在C#中使用Visual Studio 2010
我知道这个问题已被问到"如何在Excel加载项中获取文件?" 但这不能回答我的问题.
我正在尝试使用库编写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)