elm-community / json-extra

Convenience functions for working with Json.
http://package.elm-lang.org/packages/elm-community/json-extra/latest
MIT License
37 stars 16 forks source link

Why does lazy require a function? #5

Closed BrianHicks closed 7 years ago

BrianHicks commented 7 years ago

Lazy requires a function that takes unit and returns Decoder a. Why is the function necessary?

Concretely, in what case is the following not valid?

myLazy : Decoder a -> Decoder a
myLazy decoder =
    Json.Decode.Extra.lazy (\_ -> decoder)
BrianHicks commented 7 years ago

Oh duh, because it needs to be separated by a lambda from its definition in recursive data structures. Duh. Nevermind me, that was a brain fart :)