Introducing the "Prompt" library
Prompt: README / hackage / github
Have you ever wanted to specify a computation involving some limited form of IO — like querying a database, or asking stdio — but didn’t want a computation in the IO monad, opening the entire can of worms that is arbitrary IO? Have you ever looked at complicated IO a you wrote last week at 4am and prayed that it didn’t launch missiles if you decided to execute it? Do you want to be able to run an effectful computation and explicitly say what IO it can or cannot do?
Introducing the prompt library! It’s a small little lightweight library that allows you to specify and describe computations involving forms of effects where you “ask” with a value and receive a value in return (such as a database query, etc.), but not ever care about how the effects are fulfilled — freeing you from working directly with IO.
data Foo = Foo { fooBar :: String
, fooBaz :: Int
} deriving Show
-- ask with a String, receive a String as an answer
promptFoo :: Prompt String String Foo
promptFoo = Foo
<$> prompt "bar"
<*> fmap length (prompt "baz")