Skip to content

Instantly share code, notes, and snippets.

@alphaneet
Created January 23, 2012 16:45
Show Gist options
  • Save alphaneet/1664182 to your computer and use it in GitHub Desktop.
Save alphaneet/1664182 to your computer and use it in GitHub Desktop.
haskellでコンソールチャットを作るお!

続くかどうかも分かんないで、とりあえず gist にアップ。
もうちょいなんかやんかなってきたら github に移すかもしらんっすー。
System.Console.ANSI がない言われた場合は http://alphaneet.hatenablog.com/entry/2012/01/23/022059 ここらへんを参考にしてくだしあ。

import System.IO
import System.Console.ANSI
type Log = [String]
main = do
hSetBuffering stdout NoBuffering
chat []
chat :: Log -> IO()
chat log = do
clearScreen
setCursorPosition 0 0
putStr (foldl (\x y -> x ++ y ++ "\n") "" log)
setCursorPosition 10 0
putStr "> "
text <- getLine
chat (text : log)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment