yaftee-conduit: Conduit implemented on Yaftee

[ bsd3, control, library ] [ Propose Tags ] [ Report a vulnerability ]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0
Change log CHANGELOG.md
Dependencies base (>=4.7 && <5), ftcqueue (>=0.1 && <0.2), higher-order-freer-monad (>=0.1 && <0.2), higher-order-open-union (>=0.1 && <0.2), yaftee (>=0.1 && <0.2), yaftee-basic-monads (>=0.1 && <0.2) [details]
License BSD-3-Clause
Copyright Copyright (c) 2025 Yoshikuni Jujo
Author Yoshikuni Jujo
Maintainer yoshikuni.jujo@gmail.com
Category Control
Home page https://github.com/YoshikuniJujo/yaftee-conduit#readme
Bug tracker https://github.com/YoshikuniJujo/yaftee-conduit/issues
Source repo head: git clone https://github.com/YoshikuniJujo/yaftee-conduit
Uploaded by YoshikuniJujo at 2025-11-15T05:09:43Z
Distributions
Downloads 0 total (0 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for yaftee-conduit-0.1.0.0

[back to package description]

yaftee-conduit

{-# LANGUAGE ImportQualifiedPost #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE FlexibleContexts #-}
{-# OPTIONS_GHC -Wall -fno-warn-tabs #-}

module TryConduit.FromOld where

import Prelude hiding (take, putStrLn)

import Control.Monad
import Control.Monad.Yaftee.Eff qualified as Eff
import Control.Monad.Yaftee.Pipe qualified as Pipe
import Control.Monad.Yaftee.Pipe.Tools qualified as PipeT
import Control.Monad.Yaftee.Pipe.IO qualified as PipeIO
import Control.Monad.Yaftee.IO qualified as IO
import Control.HigherOpenUnion qualified as U
import Data.Char
import System.IO (openFile, IOMode(..), hClose)

action :: FilePath -> IO ()
action fp = do
	h <- openFile fp ReadMode
	_ <- Eff.runM . Pipe.run $
		PipeIO.hGetLines h Pipe.=$=
		take 5 Pipe.=$=
		PipeT.convert (toUpper <$>) Pipe.=$=
		putStrLn
	hClose h

take :: U.Member Pipe.P es => Int -> Eff.E es a a ()
take = \case
	0 -> pure ()
	n -> Pipe.await >>= \x -> Pipe.yield x >> take (n - 1)

putStrLn :: (U.Member Pipe.P es, U.Base IO.I es) => Eff.E es String o r
putStrLn = forever $ IO.putStrLn =<< Pipe.await