2
是否用於評估haskell表達式?如果是這樣,我該如何使用它?如何在Language.Haskell.Interpreter中使用解釋?
Language.Haskell.Interpreter> :t interpret
interpret :: (Data.Typeable.Internal.Typeable a, MonadInterpreter m) =>
String -> a -> m a
>interpret "1+1"
<interactive>:20:1:
Ambiguous type variable `m0' in the constraint:
(MonadInterpreter m0) arising from a use of `interpret'
Probable fix: add a type signature that fixes these type variable(s)
In the expression: interpret "1+1"
In an equation for `it': it = interpret "1+1"
問候!
與這個例子我得到了同樣的錯誤沒有實例(MonadInterpreter m0)由於使用'interpret'引起的。 我使用ghc 7.6.1 – 0xAX
@shk你需要告訴ghc(i)使用哪個monad。假設'IO'有一個'MonadInterpreter'實例,'interpret「head [True,False]」(as :: Bool):: IO Bool'應該可以工作。 –
>解讀「head [True,False]」(as :: Bool):: IO Bool --reports:沒有用於(MonadInterpreter IO)的實例... –