module Language.Drasil.Code.Imperative.Helpers (
  liftS, lookupC
) where

import Language.Drasil (UID, QuantityDict)
import Database.Drasil (symbResolve)
import Language.Drasil.Code.Imperative.DrasilState (DrasilState(..))
import Language.Drasil.CodeSpec (CodeSpec(..))

import Control.Monad.State (State)

-- | Puts a state-dependent value into a singleton list.
liftS :: State a b -> State a [b]
liftS :: forall a b. State a b -> State a [b]
liftS = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall a. a -> [a] -> [a]
: [])

-- | Gets the 'QuantityDict' corresponding to a 'UID'.
lookupC :: DrasilState -> UID -> QuantityDict
lookupC :: DrasilState -> UID -> QuantityDict
lookupC DrasilState
g = ChunkDB -> UID -> QuantityDict
symbResolve (CodeSpec -> ChunkDB
sysinfodb forall a b. (a -> b) -> a -> b
$ DrasilState -> CodeSpec
codeSpec DrasilState
g)