Skip to content

Instantly share code, notes, and snippets.

@kapranov-anton
Last active September 11, 2019 17:39
Show Gist options
  • Save kapranov-anton/86d44e4d382c2c38ffb5d59e331bc93a to your computer and use it in GitHub Desktop.
Save kapranov-anton/86d44e4d382c2c38ffb5d59e331bc93a to your computer and use it in GitHub Desktop.
Broken ana
import Html
type TreeF v a
= Node v (List a)
treeMap : (a -> b) -> TreeF v a -> TreeF v b
treeMap f (Node v xs) =
Node v <| List.map f xs
type Tree v
= Tree (TreeF v (Tree v))
treeAna : (a -> TreeF v a) -> a -> Tree v
treeAna alg =
Tree << treeMap (treeAna alg) << alg
-- treeAna alg a =
-- Tree << treeMap (treeAna alg) <| alg a
treeCoalgebra : Int -> TreeF Int Int
treeCoalgebra a =
Node 0 []
main =
Html.text <| Debug.toString <| treeAna treeCoalgebra 99
@kapranov-anton
Copy link
Author

screenshot_005

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment