getRef :: Env -> Index -> IOThrowsError (IORef AtomoVal)
getRef e i = do m <- maybeRef e i
                case m of
                     Nothing -> case i of
                                     (Define n) -> error $ "Could not find definition `" ++ n ++ "'"
                                     (Class t) -> error $ "Could not find class `" ++ prettyType t ++ "'"
                                     (Process t) -> error $ "Could not find process `" ++ show t ++ "'"
                                     (Typeclass n) -> error $ "Could not find typeclass `" ++ n ++ "'"
                                     (Instance n t) -> error $ "Typeclass `" ++ n ++ "' does not have instance for `" ++ t ++ "'"
                     Just v -> return v
getRef :: Env -> Index -> IOThrowsError (IORef AtomoVal)
getRef e i = do m <- maybeRef e i
                case m of
                     Nothing -> case i of
                                     (Define n) -> error $ "Could not find definition `" ++ n ++ "'"
                                     (Class t) -> error $ "Could not find class `" ++ prettyType t ++ "'"
                                     (Process t) -> error $ "Could not find process `" ++ show t ++ "'"
                                     (Typeclass n) -> error $ "Could not find typeclass `" ++ n ++ "'"
                                     (Instance n t) -> error $ "Typeclass `" ++ n ++ "' does not have instance for `" ++ t ++ "'"
                     Just v -> return v
getRef e i = do m <- maybeRef e i
                case m of
                     Nothing -> case i of
                                     (Define n) -> error $ "Could not find definition `" ++ n ++ "'"
                                     (Class t) -> error $ "Could not find class `" ++ prettyType t ++ "'"
                                     (Process t) -> error $ "Could not find process `" ++ show t ++ "'"
                                     (Typeclass n) -> error $ "Could not find typeclass `" ++ n ++ "'"
                                     (Instance n t) -> error $ "Typeclass `" ++ n ++ "' does not have instance for `" ++ t ++ "'"
                     Just v -> return v