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

Conduit Quiz (10) #99

Open
waddlaw opened this issue May 19, 2018 · 0 comments
Open

Conduit Quiz (10) #99

waddlaw opened this issue May 19, 2018 · 0 comments
Labels

Comments

@waddlaw
Copy link
Contributor

waddlaw commented May 19, 2018

Conduit クイズ 第10問 (***)

以下の実行結果はどうなるでしょう!

#!/usr/bin/env stack
-- stack script --resolver lts-11.0
{-# LANGUAGE ExtendedDefaultRules #-}
import Conduit
import Data.ByteString (ByteString)

myTakeCE :: Monad m => Int -> ConduitM ByteString ByteString m ()
myTakeCE n = go n
  where
    go 0 = return ()
    go n = do
      mx <- await
      case mx of
        Nothing -> return ()
        Just x  -> yield x >> go (n-1)

main :: IO ()
main = runConduitRes
     $ sourceFile "input.txt"
    .| myTakeCE 5
    .| printC

intpu.txt の内容は以下の通り

This is a test.
@waddlaw waddlaw added the Quiz label May 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

1 participant