Last active
August 29, 2015 14:18
-
-
Save fmap/d845f2b12a5086dd7f2c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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