当我运行这段代码: test1 :: Int -> String
test1 x = do
if x == 1
then "Hello"
我得到以下错误: test-if.hs:4:21: error:
parse error (possibly incorrect indentation or mismatched brackets)
我不知道这是为什么
我已经一个Haskell模块中的以下数据类型和我想写可储存instace经由FFI与C使用它: data MyType a =
TypeDouble Double
| TypeLst [a]
| TypeAdd (MyType a) (MyType a)
我开始通过定义sizeOf功能: instance Storable a => Storable (My
的较大的分支。如果我有数据类型: data Tree t = Leaf | Branch t t
我怎样才能让一个函数来获取一棵树的最长的分支?我想在列表中得到答案,该列表包含从根到树叶的最长分支节点的所有值。事情是这样的: longestBranch :: (Tree a) -> [a]
什么建议吗? 谢谢。
我试图通过绑结结构来形成像数据结构这样的无限网格。 这是我的方法: import Control.Lens
data Grid a = Grid {_val :: a,
_left :: Grid a,
_right :: Grid a,
_down :: Grid a,
_up :: Grid a}
makeLens