recursivelyImportExternalClassValue :: L2.L2Model -> L2.Identifier -> L2.L2ClassValueID -> ModelTranslation L2.L2ClassValueID
recursivelyImportExternalClassValue =
  cacheWrapExternalImport mtsForeignToLocalClassValue (\x m -> m{mtsForeignToLocalClassValue=x}) $
    \foreignMod foreignURL foreignValueID -> do
      let Just (L2.L2ClassValueContents ss dt) = M.lookup foreignValueID . L2.l2AllClassValues $ foreignMod
      localValueContents <- L2.L2ClassValueContents ss <$>
                              (recursivelyImportExternalDomainExpression foreignMod foreignURL dt)
      newValueID <- L2.l2NextClassValueID <$> getL2Model
      modifyL2Model $ \mod -> mod {
        L2.l2NextClassValueID = (\(L2.L2ClassValueID i) -> L2.L2ClassValueID (i + 1)) newValueID,
        L2.l2AllClassValues = M.insert newValueID localValueContents
                                (L2.l2AllClassValues mod)
        }
      return newValueID
recursivelyImportExternalClassValue :: L2.L2Model -> L2.Identifier -> L2.L2ClassValueID -> ModelTranslation L2.L2ClassValueID
recursivelyImportExternalClassValue =
  cacheWrapExternalImport mtsForeignToLocalClassValue (\x m -> m{mtsForeignToLocalClassValue=x}) $
    \foreignMod foreignURL foreignValueID -> do
      let Just (L2.L2ClassValueContents ss dt) = M.lookup foreignValueID . L2.l2AllClassValues $ foreignMod
      localValueContents <- L2.L2ClassValueContents ss <$>
                              (recursivelyImportExternalDomainExpression foreignMod foreignURL dt)
      newValueID <- L2.l2NextClassValueID <$> getL2Model
      modifyL2Model $ \mod -> mod {
        L2.l2NextClassValueID = (\(L2.L2ClassValueID i) -> L2.L2ClassValueID (i + 1)) newValueID,
        L2.l2AllClassValues = M.insert newValueID localValueContents
                                (L2.l2AllClassValues mod)
        }
      return newValueID
recursivelyImportExternalClassValue =
  cacheWrapExternalImport mtsForeignToLocalClassValue (\x m -> m{mtsForeignToLocalClassValue=x}) $
    \foreignMod foreignURL foreignValueID -> do
      let Just (L2.L2ClassValueContents ss dt) = M.lookup foreignValueID . L2.l2AllClassValues $ foreignMod
      localValueContents <- L2.L2ClassValueContents ss <$>
                              (recursivelyImportExternalDomainExpression foreignMod foreignURL dt)
      newValueID <- L2.l2NextClassValueID <$> getL2Model
      modifyL2Model $ \mod -> mod {
        L2.l2NextClassValueID = (\(L2.L2ClassValueID i) -> L2.L2ClassValueID (i + 1)) newValueID,
        L2.l2AllClassValues = M.insert newValueID localValueContents
                                (L2.l2AllClassValues mod)
        }
      return newValueID