haskell - Is there any non-recursive term that folds over a scott-encoded list? -


suppose have scott-encoded list such as:

scott = (\ c n -> c 1 (\ c n -> c 2 (\ c n -> c 3 (\ c n -> n)))) 

i want function receives such kind of list , converts actual list ([1,2,3]), except such function can not recursive. is, must in eta-beta normal form. function exist?

ok, give shot. feel free correct me, because i'm not expert on this.

for arbitrary x , xs, must case tolist (\c n -> c x xs) reduces term convertible x : tolist xs.

this possible if reduce left hand side c x xs applying (\c n -> c x xs) c , n. tolist ~ (\f -> f ? ?). (btw, part couldn't think of nice rigorous argument; had ideas none nice. i'd happy hear tips).

now must case c x xs ~ (x : tolist xs). since x , xs distinct universal variables, , variables occurring in right hand side, equation in miller's pattern fragment, , therefore c ~ (\x xs -> x : tolist xs) general solution.

so, tolist must reduce (\f -> f (\x xs -> x : tolist xs) n) n. clearly, tolist can't have normal form, since can unfold recursive occurrence.


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -