Skip to content

Commit 8c5131b

Browse files
authored
Merge pull request #291 from 01mf02/def-debug
Make `Debug` format `load::parse::Def` like a tuple.
2 parents fcaec68 + a930ce6 commit 8c5131b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

jaq-core/src/load/parse.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use super::lex::{StrPart, Tok, Token};
44
use super::path::{self, Path};
55
use super::{ops, prec_climb};
66
use alloc::{boxed::Box, vec::Vec};
7+
use core::fmt::{self, Debug};
78

89
/// Parse error, storing what we expected and what we got instead.
910
pub type Error<S, T = S> = (Expect<S>, T);
@@ -828,7 +829,7 @@ pub(crate) struct Module<S, B> {
828829
/// def map(f): [.[] | f];
829830
/// def recurse(f; cond): recurse(f | select(cond));
830831
/// ~~~
831-
#[derive(Debug)]
832+
// TODO v3.0: Make this just a tuple?
832833
pub struct Def<S, F = Term<S>> {
833834
/// name, e.g. `"double"` or `"map"`
834835
pub name: S,
@@ -838,6 +839,13 @@ pub struct Def<S, F = Term<S>> {
838839
pub body: F,
839840
}
840841

842+
// required for Haskell interop
843+
impl<S: Debug, F: Debug> Debug for Def<S, F> {
844+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
845+
write!(f, "({:?}, {:?}, {:?})", self.name, self.args, self.body)
846+
}
847+
}
848+
841849
impl<S, F> Def<S, F> {
842850
pub(crate) fn new(name: S, args: Vec<S>, body: F) -> Self {
843851
Self { name, args, body }

0 commit comments

Comments
 (0)