recursion-schemes Questions
1
Solved
I'm trying to get more proficient with recursion schemes as they have so far been really helpful for turning gnarly explicit recursion code into something less spike-y. One of the other tools I ten...
Kandace asked 6/6, 2022 at 11:44
0
I'm exploring recursion-schemes recently and want to find some use cases for histomorphism - for which I think Catalan numbers could be a fun one (I'm aware there are better ways to implement Catal...
Wattage asked 20/2, 2022 at 7:19
2
Various recursion scheme boil down to specific instantiation of refold
refold :: Functor s => (s b -> b) -> (a -> s a) -> a -> b
refold f g = go where go a = f (fmap go (g a))
Wh...
Gory asked 6/2, 2022 at 17:47
1
Solved
I started with this type for leaf-valued trees with labeled nodes:
type Label = String
data Tree a = Leaf Label a
| Branch Label [Tree a]
I have some folds I'd like to write over this tree, and ...
Frontpage asked 18/12, 2021 at 14:40
1
Solved
In the recursion-schemes package the following types are defined:
newtype Fix f = Fix (f (Fix f))
newtype Mu f = Mu (forall a. (f a -> a) -> a)
Are they isomorphic? If so, how do you prov...
Dnieper asked 7/4, 2020 at 15:17
1
Solved
In recursion schemes, how can I construct something with type definition like (Recursive t, CoRecursive t) -> t -> ? -> t
I try to use recursion-schemes to update nodes. Taking list as an...
Loginov asked 3/10, 2019 at 17:52
2
Solved
Consider this code:
import Data.Maybe (fromMaybe)
data MyStructure = Foo Int | Bar String MyStructure | Baz MyStructure MyStructure | Qux Bool Bool MyStructure MyStructure deriving(Eq,Show)
make...
Totem asked 30/9, 2019 at 21:45
1
Solved
I'd like to see a Coq version of the Bananas, Lenses, etc. They are built up in the excellent series of blog posts at sumtypeofway Introduction to Recursion schemes
However, the blog post is in Ha...
Pike asked 9/9, 2019 at 7:45
2
Solved
I recently read about recursion schemes where catamorphisms are described as analogous to generalized foldr.
Is is possible to write an instance of Foldable (via either foldr or foldMap) in terms...
Hoopen asked 1/8, 2019 at 8:52
3
Solved
I feel like understanding the abstract concept of fixed point of a functor, however, I am still struggling to figure out the exact implementation of it and its catamorphism in Haskell.
For example...
Tetrabasic asked 27/11, 2018 at 4:28
1
Solved
Right now, I've got an AST for expression that's polymorphic over the type of recursion:
data Expr a = Const Int
| Add a a
This has been incredibly useful by allowing me to use a type for plain...
Skim asked 28/6, 2018 at 0:25
1
Solved
This question is part theory / part implementation. Background assumption: I'm using the monad-bayes library to represent probability distributions as monads. A distribution p(a|b) can be represent...
Roundsman asked 17/4, 2018 at 4:22
1
Solved
Wikipedia writes about Hylomorphism:
In [...] functional programming a hylomorphism is a recursive
function, corresponding to the composition of an anamorphism (which
first builds a set of res...
Abortionist asked 6/3, 2018 at 16:12
2
Solved
I have defined an F-Algebra, as per Bartosz Milewski's articles (one, two):
(This is not to say my code is an exact embodiment of Bartosz's ideas, it's merely my limited understanding of them, and...
Unvoiced asked 28/1, 2018 at 15:33
1
Solved
I've been looking at the recursion-schemes library, and I'm very confused about what prepro is supposed to be used for, or even what it does. The description of it as 'Fokkinga's prepromorphism' is...
Hypoderma asked 24/11, 2017 at 1:32
2
I wanted to be able to formulate the hindley-milner type inference algorithm using fix-point data types and recursion schemes.
Disregarding all detail apart from the actual recursion parts:
w env...
Lothair asked 8/9, 2017 at 23:43
1
Solved
In Ed Kmett's recursion-scheme package, there are three declarations:
newtype Fix f = Fix (f (Fix f))
newtype Mu f = Mu (forall a. (f a -> a) -> a)
data Nu f where
Nu :: (a -> f a) -&...
Eleanoreleanora asked 9/8, 2017 at 2:45
1
Solved
Given an arbitrary datastructure with a fixed point, can we construct an monoidal algebra without manually specifying all cases?
Assume we are given the datatype Expr as below. Using the recursion...
Warila asked 7/6, 2017 at 0:44
1
Solved
I've written a small program to find the prime factorization of a number. Everything seems to compile except for the main function, which complains about not being able to find a Show1 instance.
{...
Ennius asked 23/4, 2017 at 3:17
1
Solved
I want to write Foldable.toList for a non-empty rose tree using an anamorphism, but it seems impossible to extract the last element:
import Data.Functor.Foldable
data RoseTree a = RoseNode a [Ros...
Dambrosio asked 15/2, 2017 at 4:32
2
Solved
Still working on my text editor Rasa.
At the moment I'm building out the system for tracking viewports/splits (similar to vim splits). It seemed natural to me to represent this structure as a tree...
Chrystal asked 7/1, 2017 at 18:27
2
I have this AST
data ExprF r = Const Int | Add r r
type Expr = Fix ExprF
and I want to compare
x = Fix $ Add (Fix (Const 1)) (Fix (Const 1))
y = Fix $ Add (Fix (Const 1)) (Fix (Const 2))
But...
Kenzie asked 23/7, 2016 at 13:55
1
Solved
I have this simple Expr AST and I can easily convert it to String.
import Prelude hiding (Foldable)
import qualified Prelude
import Data.Foldable as F
import Data.Functor.Foldable
import Data.Mono...
Kareem asked 19/7, 2016 at 15:20
3
Solved
I ended up figuring it out. See the video and slides of a talk I gave:
slides/pdf
video
Original question:
In my effort to understand generic recursion schemes (i.e., that use Fix) I have foun...
Shere asked 25/4, 2016 at 21:53
4
Solved
I have heard the term "coalgebras" several times in functional programming and PLT circles, especially when the discussion is about objects, comonads, lenses, and such. Googling this term gives pag...
Bergschrund asked 15/4, 2013 at 12:20
1 Next >
© 2022 - 2024 — McMap. All rights reserved.