despair 0.0.2 → 0.0.6
raw patch · 2 files changed
+53/−42 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- despair.cabal +12/−12
- src/Despair.hs +41/−30
despair.cabal view
@@ -1,15 +1,15 @@-name: despair -category: Control -version: 0.0.2 -author: Heather Cynede -maintainer: Heather Cynede <Cynede@Gentoo.org> -license: BSD3 -license-file: LICENSE -synopsis: Despair -description: Despair +name: despair +category: Control +version: 0.0.6 +author: Heather Cynede +maintainer: Heather Cynede <Heather@live.ru> +license: BSD3 +license-file: LICENSE +synopsis: Despair +description: Despair -build-type: Simple -cabal-version: >= 1.8 +build-type: Simple +cabal-version: >= 1.8 library Hs-Source-Dirs: src @@ -17,6 +17,6 @@ exposed-modules: Despair - Build-Depends: + Build-Depends: base >= 4.3 && < 5, random
src/Despair.hs view
@@ -1,42 +1,53 @@+{-# LANGUAGE + UnicodeSyntax + , Safe + #-} + module Despair ( despairQuote , despair ) where -import Control.Exception +import Control.Monad (liftM) +import Control.Exception (bracket_) import System.Random (randomRIO) -weakQuotes :: [String] +weakQuotes ∷ [String] weakQuotes = [ - " This is the way the world ends. Not with a bang but a whimper. ", - " Heaven Conceal ", - " I have long since closed my eyes... My only goal is in the darkness. ", - " I want you to feel pain, to think about pain, to accept pain, to know pain. ", - " To hope for nothing, to expect nothing, to demand nothing. This is analytical despair. ", - " Hope is a gift we give ourselves in our darkest despair. ", - " Pain to the world ", - " Despair wishes their hope diminishes. ", - " Some stories end in despair, some begin there ", - " When You're Going Through the Hell, Just Keep Going ", - " There is no love of life without despair of life. ", - " When all else is lost, the future still remains ", - " My life is a perfect graveyard of buried hopes. ", + "This is the way the world ends. Not with a bang but a whimper.", + "I have long since closed my eyes... My only goal is in the darkness.", + "I want you to feel pain, to think about pain, to accept pain, to know pain.", + "To hope for nothing, to expect nothing, to demand nothing. This is analytical despair.", + "Hope is a gift we give ourselves in our darkest despair.", + "Pain to the world", "Despair wishes their hope diminishes.", + "Some stories end in despair, some begin there", "Heaven Conceal", + "When You're Going Through the Hell, Just Keep Going", + "There is no love of life without despair of life.", "Sadness is the ambrosia of all art.", + "When all else is lost, the future still remains", "My life is a perfect graveyard of buried hopes.", "It is not despair, for despair is only for those who see the end beyond all doubt. We do not", - " Schizophrenia cannot be understood without understanding despair ", - " To be Despair. It is a portrait. Only close your eyes and feel. ", - " Sadness is the ambrosia of all art. ", - " You can't truly heal from a loss until you allow yourself to really FEEL the loss. ", - " I can't shove the dark out of my way. ", - " THERE IS NO LIGHT NO HOPE THERE IS ONLY DESPAIR!!! " + "Schizophrenia cannot be understood without understanding despair", + "To be Despair. It is a portrait. Only close your eyes and feel.", + "You can't truly heal from a loss until you allow yourself to really FEEL the loss.", + "I can't shove the dark out of my way.", "Pain is just the Rest from Pain", + "THERE IS NO LIGHT NO HOPE THERE IS ONLY DESPAIR!", "Sleepless Despair!", + "Physical pain is pure emotion, there are a lot of things we want but afraid to tell it", + "Once ,I had a dream... then I woke up" ] -despairQuote :: IO String -despairQuote = randomRIO (0, length weakQuotes - 1) - >>= return . (weakQuotes !!) +despairQuote ∷ IO String +despairQuote = liftM (weakQuotes !!) + (randomRIO (0, length weakQuotes - 1)) -despair :: IO() -> IO() -despair = bracket_ ( despairQuote >>= \q -> - let cutLen = length $ takeWhile (== ' ') q - startQ = drop cutLen q - in putStrLn startQ - ) ( putStrLn =<< despairQuote ) +despairOffset ∷ String → IO String +despairOffset q = do + r ← randomRIO (0, lim) :: IO Int + return $ replicate r ' ' + where lim ∷ Int + lim = if length q > 40 then 5 + else 10 + +despair ∷ IO () → IO () +despair = bracket_ ( putStrLn =<< despairQuote ) + ( do q ← despairQuote + offset ← despairOffset q + putStrLn $ offset ++ q )