我从"学习你是一个伟大的好的哈斯克尔"的第9章中学到了这一点
按照惯例,我们通常不会为其指定类型声明
main
.
据我所知,这个惯例很普遍.但是,如果我使用-Wall
标志编译一个缺少类型签名的程序main
,例如
-- test.hs
-- main :: IO ()
main = print (1 :: Int)
Run Code Online (Sandbox Code Playgroud)
GHC确实发出警告:
$ ghc -Wall test.hs
[1 of 1] Compiling Main ( test.hs, test.o )
test.hs:2:1: Warning:
Top-level binding with no type signature: main :: IO ()
Linking test ...
$
Run Code Online (Sandbox Code Playgroud)
我很困惑......如果类型签名main
确实是多余的,为什么-Wall
GHC会在它丢失时抱怨?是否有充分的理由(除了摆脱那个警告)指定main
的类型?
haskell program-entry-point conventions compiler-flags type-signature
我正在使用Android Studio,Gradle,git.
在每次推向主分支时,我想构建一个新的App版本,该版本已上传到Google Play商店的Alpha频道.为此,我需要为每个构建增加App的versionCode.
为此我似乎有几个选择:
目前,我最喜欢3.
有人有明确的方法吗?
我必须使用我的提交git show c36432
.文件非常大,有时需要很长时间才能逐行进行.
我可以做些什么来快速移动,例如逐页?我iterm
在Mac OS X上用作终端.
来自 Node.js,我可以做类似的事情:
// given an array `list` of objects with a field `fruit`:
fruits = list.map(el => el.fruit) # which will return an array of fruit strings
Run Code Online (Sandbox Code Playgroud)
有什么办法可以用 Go 中的优雅单行来做到这一点吗?
我知道我可以用范围循环来做到这一点,但我正在寻找单行解决方案的可能性。
我正在尝试使用git clone
从我的webfaction服务器下载代码
$ cd ../webapps/nameofwebapp/
$ git clone git@github.com:github-username/github-repo.git ./
Run Code Online (Sandbox Code Playgroud)
并且有错误:
fatal: destination path '.' already exists and is not an empty directory.
Run Code Online (Sandbox Code Playgroud)
我使用ls,并且有一些东西 nameofwebapp
auth git.cgi gitweb.cgi repos static
Run Code Online (Sandbox Code Playgroud)
我想问一下在哪里使用git clone
我是否需要创建一个新目录?
我今天安装了Git for Windows 7.我对Git还不太了解,我正在关注该主题的http://git-scm.com/book/en/Getting-Started-First-Time-Git-Setup和YouTube上的视频.在视频中人们安装Git并转到命令行并使用
git config --global user.name = "My Name"
Run Code Online (Sandbox Code Playgroud)
和
git config --global user.email = "email@example.com"
Run Code Online (Sandbox Code Playgroud)
并且它为它们创建具有正确值的.gitconfig
文件C:/Users/admin/.gitconfig
.
运行上面的代码行三次后,这就是我在该文件中得到的:
[user]
name = =
email = =
name = =
Run Code Online (Sandbox Code Playgroud)
为什么不工作?我遵循官方教程,我发现它适用于YouTube上的其他人但不适合我.
当我git lg
在本地开发分支上运行时,最新的提交如下所示:
* 7d21213 - (1 hours ago) update business rules - developer1 (HEAD, origin/develop, origin/HEAD, develop)
Run Code Online (Sandbox Code Playgroud)
但是,如果我通过运行git stash
然后运行来存储本地更改git lg
,我会得到以下内容:
* at12334 - (13 seconds ago) WIP on develop: 7d21213 update business rules - developer1 (refs/stash)
|\
| * ef9a11b - (14 seconds ago) index on develop: 7d21213 update business rules - developer1
|/
* 7d21213 - (1 hours ago) update business rules - developer1 (HEAD, origin/develop, origin/HEAD, develop)
Run Code Online (Sandbox Code Playgroud)
这是什么意思?看来,两个新的提交(标记index
和WIP
)的积攒后创建.是这样的,如果是这样,这些提交背后的逻辑是什么? …
我试图用最少的策略在Haskell中编写负载均衡器(部分是为了好玩......).我需要一个优先级队列,其中只需要以下操作"快速":
如果我有一个带指针的命令式语言,我可能会带来:
Head
|
Priority 0 -> Item <-> Item <-> Item <-> Item
|
Priority 1 -> Item <-> Item
|
Priority 4 -> Item <-> Item <-> Item
Run Code Online (Sandbox Code Playgroud)
优先级使用双向链表连接,每个优先级的项目也是如此.每个都Item
包含指向头部优先级的链接.这种结构会有复杂性:
是否存在一些行为大致相同的(功能?)数据结构?物品数量最多约为几百个.
git命令的顺序是什么
git diff [--options] <commit> <commit> [--] [<path>…]
Run Code Online (Sandbox Code Playgroud)
将不同的提交相互比较?似乎我想将新的与我需要做的旧的进行比较
git diff [--options] <New_commit> <Old_commit>
为了看到当前的差异?
我经常这样做 git diff [--options] <Old_commit> <New_commit>
但那似乎是错的?
当我做的时候
$ git diff `git rev-list --since="jun 30 2014" --reverse origin/master | head -1` `git rev-list --until="dec 31 2014" origin/master | head -1` --shortstat
1072 files changed, 389650 insertions(+), 39180 deletions(-)
Run Code Online (Sandbox Code Playgroud)
但是,当我这样做
$ git diff --stat `git rev-list --until="dec 31 2014" origin/master | head -1`
Run Code Online (Sandbox Code Playgroud)
我得到的打印输出:
384 files changed, 61255 insertions(+), 20526 deletions(-)
Run Code Online (Sandbox Code Playgroud)
哪个不是300000附近.所以我的问题是我是否应该首先插入新提交和旧提交sedond,如:
$ git diff `git …
Run Code Online (Sandbox Code Playgroud) 首先,公共子表达式消除(CSE)意味着如果表达式出现在多个位置,则重新排列代码,以便仅计算该表达式的值一次.例如:
Run Code Online (Sandbox Code Playgroud)foo x = (bar x) * (bar x)
可能会变成
Run Code Online (Sandbox Code Playgroud)foo x = let x' = bar x in x' * x'
因此,bar函数只被调用一次.(如果bar是一个特别昂贵的功能,这可能会节省很多工作.)GHC实际上并不像你期望的那样经常执行CSE.问题是,执行CSE会影响程序的严格性/懒惰性.所以GHC确实做了CSE,但仅在特定情况下---参见GHC手册.(部分??)
长话短说:"如果你关心CSE,那就亲手做吧."
我想知道在什么情况下CSE"影响"程序的严格/懒惰以及可能产生什么样的影响.
git ×6
haskell ×3
android ×1
conventions ×1
generics ×1
ghc ×1
git-config ×1
git-diff ×1
git-log ×1
git-stash ×1
go ×1
iterm ×1
jenkins ×1
macos ×1
webfaction ×1