In my ventures through Haskell, I find that when I make a mistake with types in my code, I have a tough time trying to parse what it is that I did wrong and the compiler is complaining about. I think this is because of partial type inference before the compiler finds something wrong.
Of course, I'm used to languages where the type mismatches are very obvious. e.g. something along the lines of function foo expects an argument of type …
我一直在阅读 git 书。在这本书中,我了解到 git 是通过拍摄您使用的文件的快照而不是像其他 VCS 那样的增量来运行的。这有一些很好的好处。
然而,这让我想知道:随着时间的推移,包含这些快照的 .git/ 文件夹不应该变得太大吗?有些存储库具有 10,000 多个提交或更多,包含数百个文件。为什么 git 不会变大?
我发现我不知道如何处理Haskell if-else-then中do-blocks中的嵌套。
我已知道,我可以使用case,但将要求所有我的条件(a,b和c)返回同一类型(Bool,那么只有两种情况下,但我需要三个不同的),因此不能象一般(指正如果我错了)。我也尝试过在这里考虑使用守卫,但是我不知道如何在do语句中执行此操作,特别是如果-- something表达式要是type的话IO ()。
假设我在里面有以下代码do:
if a then
-- something
else
if b then
-- something
else
if c then
-- something
else
-- something
Run Code Online (Sandbox Code Playgroud)
如何创建等效逻辑但没有所有缩进?