chore: tidy
This commit is contained in:
@@ -31,6 +31,7 @@ export const hasAttr =
|
||||
(set: NixValue): boolean =>
|
||||
Object.hasOwn(forceAttrs(set), forceStringValue(s));
|
||||
|
||||
let counter = 0;
|
||||
export const mapAttrs =
|
||||
(f: NixValue) =>
|
||||
(attrs: NixValue): NixAttrs => {
|
||||
@@ -38,7 +39,8 @@ export const mapAttrs =
|
||||
const forcedF = forceFunction(f);
|
||||
const newAttrs: NixAttrs = {};
|
||||
for (const key in forcedAttrs) {
|
||||
newAttrs[key] = createThunk(() => forceFunction(forcedF(key))(forcedAttrs[key]));
|
||||
newAttrs[key] = createThunk(() => forceFunction(forcedF(key))(forcedAttrs[key]), `created by mapAttrs (${counter})`);
|
||||
counter += 1;
|
||||
}
|
||||
return newAttrs;
|
||||
};
|
||||
|
||||
@@ -249,11 +249,11 @@ export const builtins: any = {
|
||||
tryEval: mkPrimop(misc.tryEval, "tryEval", 1),
|
||||
zipAttrsWith: mkPrimop(misc.zipAttrsWith, "zipAttrsWith", 2),
|
||||
|
||||
builtins: createThunk(() => builtins),
|
||||
builtins: createThunk(() => builtins, "builtins"),
|
||||
currentSystem: createThunk(() => {
|
||||
return "x86_64-linux";
|
||||
}),
|
||||
currentTime: createThunk(() => Date.now()),
|
||||
}, "currentSystem"),
|
||||
currentTime: createThunk(() => Date.now(), "currentTime"),
|
||||
|
||||
false: false,
|
||||
true: true,
|
||||
|
||||
@@ -7,7 +7,7 @@ import { CatchableError } from "../types";
|
||||
import type { NixAttrs, NixBool, NixStrictValue, NixValue } from "../types";
|
||||
import { forceList, forceAttrs, forceFunction, forceStringValue, forceString } from "../type-assert";
|
||||
import * as context from "./context";
|
||||
import { compareValues, op } from "../operators";
|
||||
import { compareValues } from "../operators";
|
||||
import { isBool, isFloat, isInt, isList, isString, typeOf } from "./type-check";
|
||||
import { OrderedSet } from "js-sdsl";
|
||||
import {
|
||||
@@ -15,13 +15,13 @@ import {
|
||||
getStringValue,
|
||||
getStringContext,
|
||||
mkStringWithContext,
|
||||
mergeContexts,
|
||||
} from "../string-context";
|
||||
|
||||
export const addErrorContext =
|
||||
(e1: NixValue) =>
|
||||
(e2: NixValue): never => {
|
||||
throw new Error("Not implemented: addErrorContext");
|
||||
(e2: NixValue): NixValue => {
|
||||
console.log("[WARNING]: addErrorContext not implemented");
|
||||
return e2;
|
||||
};
|
||||
|
||||
export const appendContext = context.appendContext;
|
||||
|
||||
@@ -62,11 +62,16 @@ export class NixArgs {
|
||||
}
|
||||
}
|
||||
}
|
||||
export const mkFunction = (f: (arg: NixValue) => NixValue, required: string[], optional: string[], ellipsis: boolean): NixFunction => {
|
||||
export const mkFunction = (
|
||||
f: (arg: NixValue) => NixValue,
|
||||
required: string[],
|
||||
optional: string[],
|
||||
ellipsis: boolean,
|
||||
): NixFunction => {
|
||||
const func = f as NixFunction;
|
||||
func.args = new NixArgs(required, optional, ellipsis);
|
||||
return func
|
||||
}
|
||||
return func;
|
||||
};
|
||||
|
||||
/**
|
||||
* Interface for lazy thunk values
|
||||
|
||||
@@ -47,9 +47,6 @@ mod private {
|
||||
fn compile_code(&mut self, source: Source) -> Result<String> {
|
||||
self.as_mut().compile_code(source)
|
||||
}
|
||||
fn get_current_source(&self) -> Source {
|
||||
self.as_ref().get_current_source()
|
||||
}
|
||||
fn get_source(&self, id: usize) -> Source {
|
||||
self.as_ref().get_source(id)
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
#![allow(unused_assignments)]
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::Arc;
|
||||
|
||||
use miette::{Diagnostic, NamedSource, SourceSpan};
|
||||
use std::{
|
||||
path::{Path, PathBuf},
|
||||
sync::Arc,
|
||||
};
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::{context::Ctx, runtime::RuntimeContext};
|
||||
use crate::runtime::RuntimeContext;
|
||||
|
||||
pub type Result<T> = core::result::Result<T, Box<Error>>;
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
use rusqlite::{Connection, OptionalExtension, params};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::path::PathBuf;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use derive_more::{IsVariant, TryUnwrap, Unwrap};
|
||||
use hashbrown::{HashMap, HashSet};
|
||||
use hashbrown::HashMap;
|
||||
use rnix::{TextRange, ast};
|
||||
use string_interner::symbol::SymbolU32;
|
||||
|
||||
|
||||
@@ -401,7 +401,6 @@ impl<Ctx: DowngradeContext> Downgrade<Ctx> for ast::Lambda {
|
||||
pat_entries,
|
||||
alias,
|
||||
arg,
|
||||
ellipsis,
|
||||
ctx,
|
||||
|ctx, _| self.body().unwrap().downgrade(ctx),
|
||||
)?;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#![allow(unused)]
|
||||
|
||||
use rnix::TextRange;
|
||||
|
||||
pub fn merge_spans(spans: impl IntoIterator<Item = TextRange>) -> TextRange {
|
||||
@@ -11,10 +13,6 @@ pub fn merge_spans(spans: impl IntoIterator<Item = TextRange>) -> TextRange {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn point_span() -> TextRange {
|
||||
TextRange::new(0.into(), 0.into())
|
||||
}
|
||||
|
||||
pub fn synthetic_span() -> TextRange {
|
||||
TextRange::new(0.into(), 0.into())
|
||||
}
|
||||
|
||||
@@ -225,7 +225,6 @@ pub fn downgrade_pattern_bindings<Ctx>(
|
||||
pat_entries: impl Iterator<Item = ast::PatEntry>,
|
||||
alias: Option<SymId>,
|
||||
arg: ExprId,
|
||||
has_ellipsis: bool,
|
||||
ctx: &mut Ctx,
|
||||
body_fn: impl FnOnce(&mut Ctx, &[SymId]) -> Result<ExprId>,
|
||||
) -> Result<PatternBindings>
|
||||
|
||||
@@ -18,7 +18,6 @@ pub(crate) trait RuntimeContext: 'static {
|
||||
fn get_current_dir(&self) -> &Path;
|
||||
fn add_source(&mut self, path: Source);
|
||||
fn compile_code(&mut self, source: Source) -> Result<String>;
|
||||
fn get_current_source(&self) -> Source;
|
||||
fn get_source(&self, id: usize) -> Source;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
mod config;
|
||||
mod error;
|
||||
mod validation;
|
||||
|
||||
Reference in New Issue
Block a user