Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

P189最下面countCard的point-free写法错误 #55

Open
youwillbe opened this issue Mar 26, 2020 · 2 comments
Open

P189最下面countCard的point-free写法错误 #55

youwillbe opened this issue Mar 26, 2020 · 2 comments

Comments

@youwillbe
Copy link

pure . length的类型是CardStack -> State CardStack Int
此处应为

countCards :: State CardStack Int
countCards = State $ length >>= (,)
@SnowOnion
Copy link

同意。
此外,也可以朴素地 countCards = State $ \s -> (length s, s),也可以用后面定义的

gets :: (s -> a) -> State s a
gets f = State $ \s -> (f s, s)

来写成 countCards = gets length

@winterland1989
Copy link
Owner

看起来修正版的计划得赶紧提上日程啦

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants