Skip to content

Commit

Permalink
Added a Pad type, for user scratchpads.
Browse files Browse the repository at this point in the history
  • Loading branch information
luqui committed Nov 17, 2008
1 parent 7f72467 commit e68a21b
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions udon-shell/UdonShell/Pad.hs
@@ -0,0 +1,26 @@
module UdonShell.Pad
(Pad, insert, delete, lookup)
where

import Data.Typeable
import Prelude hiding (lookup)
import Udon.API
import qualified Udon.DescCombinators as D
import qualified Data.Map as Map

newtype Pad = Pad { unPad :: Map.Map String DynRef }
deriving (Typeable)

conj f = Pad . f . unPad

instance Data Pad where
desc = D.wrap (Pad . Map.fromDistinctAscList, Map.toList . unPad) desc

insert :: String -> DynRef -> Pad -> Pad
insert str ref = conj (Map.insert str ref)

delete :: String -> Pad -> Pad
delete str = conj (Map.delete str)

lookup :: Pad -> String -> Maybe DynRef
lookup (Pad pad) str = Map.lookup str pad

0 comments on commit e68a21b

Please sign in to comment.