Skip to content

Instantly share code, notes, and snippets.

@fmap
Last active August 29, 2015 14:18
Show Gist options
  • Save fmap/d845f2b12a5086dd7f2c to your computer and use it in GitHub Desktop.
Save fmap/d845f2b12a5086dd7f2c to your computer and use it in GitHub Desktop.
let
inherit (builtins) isAttrs typeOf toJSON;
inherit ((import <nixpkgs> {}).lib) mapAttrsRecursive;
in rec {
show = value: if typeOf value == "lambda" then "<LAMBDA>" else value; # XXX: Not sure how to discriminate between functions and 'PRIMOP'.
json = value: toJSON (if ! isAttrs value then show value else mapAttrsRecursive (_: show) value);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment