prototype

prototype-based programming on Haskell

Latest on Hackage:0.5.3

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow stackage.org to host generated Haddocks.

BSD3 licensed and maintained by Yoshikuni Jujo

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 = flip evalProt initProtEnv $ do
	( dog, setName, sit ) <- package "dog" $ do
		dog <- clone object
		name	<- makeMember "name"
		setName	<- makeMember "setName"
		sit	<- makeMember "sit"
		setMethod dog setName $ \this [ n ] -> do
			setMember this name n
			return [ ]
		setMethod dog sit $ \this _ -> do
			n <- member this name
			liftProt $ putStrLn $ fromPrimStr n ++ " sitting."
			return [ ]
		return ( dog, setName, sit )
	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 ()
Depends on:
Used by 1 package:
comments powered byDisqus