Haskell で Ubigraph を使用しようとしていますが、私の問題はもっと一般的なものだと思います。私はコンパイルしようとしています:
import Graphics.Ubigraph
import Control.Monad
import System.Posix.Unistd
main = do
h <- initHubigraph "http://127.0.0.1:20738/RPC2"
runHubigraph op h
op = do
clear
vs <- mapM (const newVertex) [0..200]
mapM_ (setVAttr (VShape Sphere)) vs
putStrLn "something"
let bind i = zipWithM (\a b -> newEdge (a,b)) vs (drop i vs ++ take i vs)
mapM_ bind [1..15]
mapM_ (removeVertex) vs
return ()
そして私は得ています
Couldn't match expected type `Control.Monad.Trans.Reader.ReaderT Ubigraph IO a0' with actual type `IO ()' In the return type of a call of `putStrLn' In a stmt of a 'do' expression: putStrLn "something" In the expression: do { clear; vs <- mapM (const newVertex) [0 .. 200]; mapM_ (setVAttr (VShape Sphere)) vs; putStrLn "something"; .... }
op の型が putStrLn の戻り値の型とは異なるものとして暗示されていることはわかりますが、このコードを再設計して適切にコンパイルする方法がわかりません。op 関数の戻り値の型を変更することはできますか?
ありがとう