@@ -6,7 +6,7 @@ module Ur.Deconstructor exposing
6 , int, signedInt, bigint
6 , int, signedInt, bigint
7 , float32, float64
7 , float32, float64
8 , cord, tape
8 , cord, tape
9− , bytes, sig, ignore, tar, lazy
9+ , bytes, sig, ignore, tar, lazy, debug
12{-| This module provides an API to deconstruct `Noun`s into arbitrary Elm data structures.
12{-| This module provides an API to deconstruct `Noun`s into arbitrary Elm data structures.
@@ -55,7 +55,7 @@ You would parse a `[%edit @ cord]` like this:
56# Miscellaneous
56# Miscellaneous
58−@docs bytes, sig, ignore, tar, lazy
58+@docs bytes, sig, ignore, tar, lazy, debug
@@ -66,7 +66,7 @@ import Bytes exposing (Bytes, Endianness(..))
66import Bytes.Decode as BD
66import Bytes.Decode as BD
67import Bytes.Encode as BE
67import Bytes.Encode as BE
68import Bytes.Extra
68import Bytes.Extra
69−import Ur.Jam exposing (cue)
69+import Ur.Jam exposing (cue, isSig)
70import Ur.Types exposing (..)
70import Ur.Types exposing (..)
@@ -337,3 +337,42 @@ Always succeeds.
337tar : Deconstructor Noun
337tar : Deconstructor Noun
342+{-| Debug a deconstructor.
343+If the deconstructor from the second argument fails then the failed nock will be printed to the console.
345+debug : (String -> String) -> Deconstructor a -> Deconstructor a
354+ log (prettyNoun noun)
359+prettyNoun : Noun -> String
371+ Cell ( lhs, rhs ) ->
373+ go False lhs ++ " " ++ go True rhs
376+ "[" ++ go False lhs ++ " " ++ go True rhs ++ "]"