Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {-# LANGUAGE DataKinds #-}
- {-# LANGUAGE FlexibleContexts #-}
- {-# LANGUAGE GADTs #-}
- {-# LANGUAGE LambdaCase #-}
- {-# LANGUAGE PolyKinds #-}
- {-# LANGUAGE RankNTypes #-}
- {-# LANGUAGE ScopedTypeVariables #-}
- {-# LANGUAGE TemplateHaskell #-}
- {-# LANGUAGE TypeApplications #-}
- {-# LANGUAGE TypeFamilies #-}
- {-# LANGUAGE TypeOperators #-}
- module Main where
- import Polysemy
- data Console m a where
- ReadTTY :: Console m Text
- WriteTTY :: Text -> Console m ()
- makeSem ''Console
- runConsoleIO :: (Member (Lift IO) r) => Sem (Console ': r) a -> Sem r a
- runConsoleIO = interpret $ \case
- ReadTTY -> sendM getLine
- WriteTTY msg -> sendM $ putTextLn msg
- main :: IO ()
- main = runConsoleIO $ do
- input <- readTTY
- writeTTY input
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement