@hackage prototype0.1

prototype-based programming on Haskell

  • Categories

  • License

    BSD-3-Clause

  • Maintainer

    Yoshikuni Jujo <PAF01143@nifty.ne.jp>

  • Versions

    • 0.5.3 Mon, 15 Aug 2011
    • 0.5.0 Fri, 12 Aug 2011
    • 0.4.1 Thu, 11 Aug 2011
    • 0.3 Wed, 10 Aug 2011
    • 0.2 Wed, 10 Aug 2011
    • 0.1 Wed, 10 Aug 2011

prototype-based programming on Haskell

You can download source codes by git.

git clone git://github.com/YoshikuniJujo/prototype.git prototype

Example code

 module Main where

 import Control.Prototype

 main :: IO ()
 main = fmap fst $ flip runPT initPTEnv $ do
	dog <- clone object
	name <- makeMember "name"
	setName <- setMethod dog "setName" $ \this [ n ] -> do
		setMember this name n
		return [ ]
	sit <- setMethod dog "sit" $ \this _ -> do
		n <- member this name
		liftPT $ putStrLn $ fromPrimStr n ++ " sitting."
	myDog <- clone dog
	method myDog setName [ primStr "John" ]
	method myDog sit [ ]
	return ()

Another sample

 module Main where

 import MyToolkit

 main :: IO ()
 main = runToolKit $ do
	( textView, setText, setContentView ) <- importMyToolkit
	myTV <- clone textView
	method myTV setText [ primStr "Hello, world!" ]
	method myTV setContentView [ ]
	return ()