Skip to content

Commit

Permalink
Change ANormalisation not to use value-supply
Browse files Browse the repository at this point in the history
  • Loading branch information
batterseapower committed Jun 29, 2010
1 parent ad43480 commit 392a442
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions ANormalisation.hs
@@ -1,23 +1,21 @@
{-# LANGUAGE RankNTypes #-} {-# LANGUAGE RankNTypes #-}
import Text.PrettyPrint.HughesPJClass import Text.PrettyPrint.HughesPJClass


import Data.Supply

import System.IO.Unsafe import System.IO.Unsafe


import Control.Monad.State import Control.Monad.State




type UniqM = State (Supply Int) type UniqM = State [Int]


uniqSupply :: Supply Int uniqSupply :: [Int]
uniqSupply = unsafePerformIO $ newSupply 0 (+1) uniqSupply = [0..]


runUniq :: UniqM a -> a runUniq :: UniqM a -> a
runUniq = flip evalState uniqSupply runUniq = flip evalState uniqSupply


unique :: UniqM Int unique :: UniqM Int
unique = get >>= \s -> let (s1, s2) = split2 s in put s2 >> return (supplyValue s1) unique = get >>= \(x:ss) -> put ss >> return x




-- -- Codensity is the "mother of all monads": -- -- Codensity is the "mother of all monads":
Expand Down

0 comments on commit 392a442

Please sign in to comment.