summaryrefslogtreecommitdiff
path: root/examples/example0/Example0.hs
blob: a8e74c38e326132c70cfee5d179b1a21b45d9093 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
{-# LANGUAGE DataKinds           #-}
{-# LANGUAGE TypeApplications    #-}
{-# LANGUAGE OverloadedStrings   #-}
{-# LANGUAGE GADTs               #-}
{-# LANGUAGE Arrows              #-}

import           Data.DocRecord
import qualified Data.Text.Lazy as T
import           Porcupine


resultFile :: DataSink T.Text
resultFile = dataSink ["result"] $
  somePureSerial (PlainTextSerial (Just "txt"))

myTask :: (LogThrow m) => PTask m () ()
myTask = proc () -> do
  (FV char :& FV num :& _) <- getMyOptions -< ()
  let txt = T.replicate (fromIntegral num) (T.singleton char)
  writeData resultFile -< txt
  where
    getMyOptions =
      getOptions ["options"]
      (  docField @"char"         'a'       "The character to repeat"
      :& docField @"replications" (10::Int) "The number of replications"
      :& RNil)

main :: IO ()
-- main = simpleRunPTask myTask ()
main = runLocalPipelineTask (FullConfig "example0" "example0.yaml" "." ()) myTask ()