{"action":"created","issue":{"url":"https://api.github.com/repos/elm-lang/elm-compiler/issues/999","labels_url":"https://api.github.com/repos/elm-lang/elm-compiler/issues/999/labels{/name}","comments_url":"https://api.github.com/repos/elm-lang/elm-compiler/issues/999/comments","events_url":"https://api.github.com/repos/elm-lang/elm-compiler/issues/999/events","html_url":"https://github.com/elm-lang/elm-compiler/issues/999","id":96608631,"number":999,"title":"Unexpected behavior in recursive data structure declarations","user":{"login":"jdavidberger","id":8194827,"avatar_url":"https://avatars.githubusercontent.com/u/8194827?v=3","gravatar_id":"","url":"https://api.github.com/users/jdavidberger","html_url":"https://github.com/jdavidberger","followers_url":"https://api.github.com/users/jdavidberger/followers","following_url":"https://api.github.com/users/jdavidberger/following{/other_user}","gists_url":"https://api.github.com/users/jdavidberger/gists{/gist_id}","starred_url":"https://api.github.com/users/jdavidberger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdavidberger/subscriptions","organizations_url":"https://api.github.com/users/jdavidberger/orgs","repos_url":"https://api.github.com/users/jdavidberger/repos","events_url":"https://api.github.com/users/jdavidberger/events{/privacy}","received_events_url":"https://api.github.com/users/jdavidberger/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/elm-lang/elm-compiler/labels/duplicate","name":"duplicate","color":"cccccc"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2015-07-22T16:22:44Z","updated_at":"2015-07-22T19:55:58Z","closed_at":"2015-07-22T19:49:56Z","body":"See: http://share-elm.com/sprout/55afc18ae4b06aacf0e8b605.\r\n\r\nIt seems like cyclic declarations are not always doing expected things. The output mechanism initializes b first, so it resolves a as undefined and this leads to crashes. Swap the order of declarations or which node you are inspecting and it works.\r\n\r\nI'm unsure on how tractable this issue will turn out to be given the current output mechanisms, but it'd be very nice to have supported. But even without that support, there should be a consistent cycle detector and a compile error for it. \r\n\r\nNote this related issue in an elm library: https://github.com/Dandandan/parser/issues/15#issuecomment-123765681\r\n"},"comment":{"url":"https://api.github.com/repos/elm-lang/elm-compiler/issues/comments/123845127","html_url":"https://github.com/elm-lang/elm-compiler/issues/999#issuecomment-123845127","issue_url":"https://api.github.com/repos/elm-lang/elm-compiler/issues/999","id":123845127,"user":{"login":"jdavidberger","id":8194827,"avatar_url":"https://avatars.githubusercontent.com/u/8194827?v=3","gravatar_id":"","url":"https://api.github.com/users/jdavidberger","html_url":"https://github.com/jdavidberger","followers_url":"https://api.github.com/users/jdavidberger/followers","following_url":"https://api.github.com/users/jdavidberger/following{/other_user}","gists_url":"https://api.github.com/users/jdavidberger/gists{/gist_id}","starred_url":"https://api.github.com/users/jdavidberger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdavidberger/subscriptions","organizations_url":"https://api.github.com/users/jdavidberger/orgs","repos_url":"https://api.github.com/users/jdavidberger/repos","events_url":"https://api.github.com/users/jdavidberger/events{/privacy}","received_events_url":"https://api.github.com/users/jdavidberger/received_events","type":"User","site_admin":false},"created_at":"2015-07-22T19:55:58Z","updated_at":"2015-07-22T19:55:58Z","body":"I see what you are saying about seemingly equivalent expressions giving differing results. And I'd agree that this isn't ideal. Even with very good error message support it could hard to determine exactly what is blocking compilation so that it could be resolved. \r\n\r\nIn terms of making (a' ()) equivalent to a: With memoization support I think it does what you expect, without it it would always hang. I think that is a large argument for memoizing these forms of expressions if this kind of data structure is included in the language. Without memoization head (ones ()) hangs; with it, it should return 1. \r\n\r\nIn practical terms, I'm not _that_ bothered by equivalent expressions having differing termination behaviors. Ideally everything would terminate with the 'right' answer, but sometimes there is no fixed-point right answer (sum ones)[Actually I guess Infinity would be correct, but there are other series which addition diverges on] and in other cases there is, but most compilers won't/shouldn't try to find it (sum zeroes), even though one does exist. \r\n\r\nI think we can both agree though that if both forms of the expression do terminate, they _must_ have the same value, or chaos ensues. :)\r\n\r\n@evancz Sounds good, thanks for looking into this!\r\n\r\n"}}