catamorphism Questions
1
Solved
I recently discovered how to simulate higher order types in Java in a somewhat roundabout way like so
interface H<F, T> { }
Here H encodes a higher order type that takes a type parameter F w...
Gerhan asked 12/1, 2022 at 12:19
1
Solved
Using the following catamorphism for natural numbers I can implement various arithmetic algorithms whithout having to deal with recursion:
cataNat :: b -> (b -> b) -> Natural -> b
cataN...
Mountford asked 20/6, 2020 at 20:29
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
2
Solved
Recently I've finally started to feel like I understand catamorphisms. I wrote some about them in a recent answer, but briefly I would say a catamorphism for a type abstracts over the process of re...
Rainy asked 4/10, 2017 at 9:11
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
I have this lovely fixana function here that performs about 5 times faster than her sister ana. (i have a criterion report to back me on this)
ana alg = Fix . fmap (ana alg) . alg
fixana alg = fi...
Pacify asked 9/2, 2018 at 12:5
1
Solved
I'm reading the wikipedia article about catamorphisms and for the moment I was able to reproduce the Haskell examples in F# except for this part :
type Algebra f a = f a -> a -- the generic f-a...
Disservice asked 12/9, 2017 at 9:43
3
Given are the two datatypes Color and Plant.
data Color = Red | Pink | White | Blue | Purple | Green | Yellow
deriving (Show, Eq)
data Plant =
Leaf
| Blossom Color
| Stalk Plant Plant
derivi...
Jugulate asked 4/7, 2017 at 22:12
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
1
Solved
I am trying to wrap my head around the concept of anamorphism.
In functional programming, an anamorphism is a generalization of the concept of unfolds on lists. Formally, anamorphisms are generi...
Liscomb asked 15/6, 2015 at 12:1
1
Many catamorphisms seem to be simple enough, mostly replacing each data constructor with a custom function, e.g.
data Bool = False | True
foldBool :: r -- False constructor
-> r -- True constr...
Leathers asked 12/6, 2015 at 18:40
4
Solved
I have a recursive datatype which has a Functor instance:
data Expr1 a
= Val1 a
| Add1 (Expr1 a) (Expr1 a)
deriving (Eq, Show, Functor)
Now, I'm interested in modifying this datatype to suppo...
Aflcio asked 19/11, 2014 at 22:14
1
Solved
The answer to this question suggests that the fold method on Option in Scala is a catamoprhism. From the wikipedia a catamophism is "the unique homomorphism from an initial algebra into some other ...
Latinism asked 18/5, 2014 at 16:27
2
Solved
After writing this article I decided to put my money where my mouth is and started to convert a previous project of mine to use recursion-schemes.
The data structure in question is a lazy kdtree....
Bangweulu asked 14/5, 2014 at 20:9
5
Solved
I'm trying to learn about catamorphisms and I've read the Wikipedia article and the first couple posts in the series of the topic for F# on the Inside F# blog.
I understand that it's a generaliza...
Flirtation asked 12/10, 2008 at 23:33
1
Solved
I 'invented' a recursion scheme which is a generalization of catamorphism. When you fold a data structure with catamorphism you don't have access to subterms, only to subresults of folding:
{-# LA...
Sawicki asked 2/8, 2013 at 9:36
2
Solved
I recently learned a bit about F-algebras:
https://www.fpcomplete.com/user/bartosz/understanding-algebras.
I wanted to lift this functionality to more advanced types (indexed and higher-kinded).
Fu...
Intrastate asked 6/7, 2013 at 12:48
1
Solved
Needless to say, the standard construction in Haskell
newtype Fix f = Fix { getFix :: f (Fix f) }
cata :: (Functor f) => (f a -> a) -> Fix f -> a
cata f = f . fmap (cata f) . getFix
...
Daubigny asked 5/2, 2013 at 2:43
1
Solved
I really like the idea of working with catamorphisms/anamorphisms in a generic way, but it seems to me it has a significant performance drawback:
Suppose we want to work with a tree structure in t...
Pasia asked 27/10, 2012 at 10:12
4
From page 3 of http://research.microsoft.com/en-us/um/people/emeijer/Papers/meijer94more.pdf:
it is not true in general that catamorphisms are closed under composition
Under what conditions do...
Cromagnon asked 24/8, 2012 at 4:50
2
Solved
Scalaz provides a method named fold for various ADTs such as Boolean, Option[_], Validation[_, _], Either[_, _] etc. This method basically takes functions corresponding to all possible cases for th...
Folse asked 16/12, 2011 at 20:48
2
Solved
I am impatient, looking forward to understanding catamorphism related to this SO question :)
I have only practiced the beginning of Real World Haskell tutorial. So, Maybe I'm gonna ask for way too...
Photovoltaic asked 13/12, 2010 at 22:54
3
Solved
Sometimes i find myself progamming the pattern "if the Bool is not false" or "if the list is not empty use it, otherwise use something else".
I am looking for functions for Bool and List that are ...
Gabrielegabriell asked 1/10, 2010 at 8:50
1
© 2022 - 2024 — McMap. All rights reserved.