小编Cra*_*aig的帖子

带参考的Haskell数据类型

我正在实现Ukkonen的算法,它要求树的所有叶子都包含对同一整数的引用,并且我在Haskell中这样做以了解有关该语言的更多信息.但是,我很难写出执行此操作的数据类型.

-- Node has children, indexes of info on the edge
-- to it, and an optional suffix link.

-- Leaf has a beginning index of the info, but the
-- end index is always an incrementing variable index.
data STree = Node [STree] (Int, Int) (Maybe STree)
           | Leaf (Int, ??? )
Run Code Online (Sandbox Code Playgroud)

如何将引用放在Leaf类型声明中?

haskell reference mutable suffix-tree state-monad

7
推荐指数
0
解决办法
401
查看次数

如何在Haskell图表库中设置轴的范围

在haskell图表中,如何更改轴的范围?它似乎与镜头和视口有关,但作为Haskell的初学者,我很难阅读API:

http://hackage.haskell.org/package/Chart-0.14/docs/Graphics-Rendering-Chart-Axis-Types.html

谢谢你的帮助!

haskell haskell-lens haskell-chart

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

Scotty使用MongoDB

我对Haskell比较陌生,这是我第一次使用monad变换器.我真的很感激一些帮助.

runQuery :: Pipe -> Query -> ActionM (Either Failure [Document])
runQuery pipe query = access pipe master "nutrition" (find query >>= rest) 

main = do
pipe <- runIOE $ connect $ host "127.0.0.1"  

scotty 3000 $ do
post "/" $ do
        b <-  body
        let user :: Either String User = eitherDecode b
        case user of 
            Left err -> text . pack $ "Could not decode the user:" ++ err ++ ":\n" ++ (show b)
            Right u -> do …
Run Code Online (Sandbox Code Playgroud)

monads haskell mongodb monad-transformers scotty

4
推荐指数
1
解决办法
943
查看次数