{- |
Description: Module representing universable unique identifiers ('UUID').
License: GNU LGPLv3
Maintainer: paul.bittner@uni-ulm.de

Module representing universable unique identifiers ('UUID').
We use these to identify nodes in abstract syntax trees ('AST') and track them across versions.
-}
module UUID where

import Control.Monad.State

-- | A universable unique identifiers (UUID) realised as an integer.
type UUID = Int

-- | Computes the successor 'UUID' of the current 'UUID'.
next :: State UUID ()
next :: State UUID ()
next = do
    UUID
num <- StateT UUID Identity UUID
forall s (m :: * -> *). MonadState s m => m s
get
    UUID -> State UUID ()
forall s (m :: * -> *). MonadState s m => s -> m ()
put (UUID
num UUID -> UUID -> UUID
forall a. Num a => a -> a -> a
+ 1)
    () -> State UUID ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

-- | Converts a 'UUID' to an 'Int'.
toInt :: UUID -> Int
toInt :: UUID -> UUID
toInt = UUID -> UUID
forall a. a -> a
id