Skip to content

sorki/polytype

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

polytype

🚧 Work in progress 🚧

What is this?

  • Polymorphic Teletype
  • Library for interacting with
    • programs
    • programs running in POXIS pseudo terminals via posix-pty
    • serial terminals via serialport
  • Expect on steroids
  • Program interaction library with Asciinema recorder
  • My first polysemy endeavour and a playground (for now)
  • Collection of useful effects related to the topic

What is it good for?

  • Interacting with and testing other programs
  • Testing of terminal UIs
  • Making demos of terminal UIs with Asciinema asciicast output
  • Testing hardware (or virtual machines) over serial connection
  • Streaming inputs and outputs of programs, terminals, serial connections
  • Variations of the previous ones

Why?

To explore effect systems and polymorphic IO automation framework. Originally the project was called multitype, based on Free monads which proved difficult to interpret with all the required bits like async and timeout. Later it was rewritten using transformers but never released because it still felt too opinionated about the use of e.g. character vs line based input or Text vs ByteString specialization.

This library tries to be much less picky about the type of its inputs and outputs allowing the user to choose what types to work with or convert between different Teletypes. polysemys effect system allows the user to write programs using the same eDSL and choosing interpreters according to the target environment.

Examples

import Polytype

main :: IO ()
main =
  . runM
  . teletypeToIO
  . runLogShow
  . teletypeLog
  $ do
    writeTTY "Type something"
    i <- readTTY
    writeTTY $ "You wrote: " ++ i

Provided examples

Asciinema output

asciicast

Development status

Types of effects are in pretty good shape. Names and interpreters are subject to change.

The library grew quite a bit since the work started and some parts will be split into sub-packages.

Related work

Inspired by:

About

Polymorphic Teletype

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published