Move stuff around + add lean and idris experiments
This commit is contained in:
parent
a45a4e94b3
commit
ca3f83d186
122 changed files with 1959 additions and 2 deletions
purescript/streams/src
38
purescript/streams/src/Main.purs
Normal file
38
purescript/streams/src/Main.purs
Normal file
|
@ -0,0 +1,38 @@
|
|||
module Main where
|
||||
|
||||
import Prelude
|
||||
|
||||
import Data.Tuple (Tuple(..))
|
||||
import Effect (Effect)
|
||||
import Effect.Class (class MonadEffect)
|
||||
import Effect.Class.Console (logShow)
|
||||
import Pipes (await, for, yield, (>->))
|
||||
import Pipes.Core (Consumer_, Producer_, runEffect)
|
||||
import Pipes.Prelude (take)
|
||||
import Pipes.Prelude as Pipes
|
||||
|
||||
naturals :: forall m. Monad m => Producer_ Int m Unit
|
||||
naturals = go 0
|
||||
where
|
||||
go n = do
|
||||
yield n
|
||||
go (n + 1)
|
||||
|
||||
logAll :: forall a m. MonadEffect m => Show a => Consumer_ a m Unit
|
||||
logAll = do
|
||||
showable <- await
|
||||
logShow showable
|
||||
logAll
|
||||
|
||||
nNaturals :: forall m. Monad m => Int -> Producer_ Int m Unit
|
||||
nNaturals n = naturals >-> take n
|
||||
|
||||
merger :: forall m. Monad m => Producer_ (Tuple Int Int) m Unit
|
||||
merger =
|
||||
for (nNaturals 3) \a ->
|
||||
for (nNaturals 3 >-> Pipes.map ((+) 4)) \b ->
|
||||
yield $ Tuple a b
|
||||
|
||||
|
||||
main :: Effect Unit
|
||||
main = runEffect ((nNaturals 3 <> nNaturals 3) >-> logAll)
|
Loading…
Add table
Add a link
Reference in a new issue