Skip to main content
1 vote
2 answers
124 views

I have been deeply studying foldTree function in Haskell, which is defined as follows: foldTree :: (a -> [b] -> b) -> Tree a -> b foldTree f = go where go (Node x ts) = f x (map go ts) ...
F. Zer's user avatar
  • 1,311
3 votes
1 answer
93 views

I have the fixed point functor defined as follows: newtype Fix f = Fix { unfix :: f (Fix f) } I would like to define a function which takes a Fix f and gives its Böhm-Beraducci ...
Wheat Wizard's user avatar
  • 4,236
2 votes
1 answer
146 views

I would like to write catamorphism in OCaml for any endofunctor (in terms of types) as a functor (in terms of OCaml): module type Functor = sig type 'a t (* ... *) end module Make(F : ...
ProgMiner's user avatar
1 vote
1 answer
103 views

I need to model a computation task and some sub-tasks depend on it: First I run a task, if it fails then it's over. If it succeeds then run a bunch of sub-tasks(zero or many), any of them can fail or ...
Annihilus's user avatar
5 votes
1 answer
278 views

Is it possible to memoize a recursion scheme? If so, how would you? For example, the following uses anamophism and catamorphism newtype Fix f = In (f (Fix f)) deriving instance (Eq (f (Fix f))) => ...
cocorudeboy's user avatar
12 votes
1 answer
333 views

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 ...
michid's user avatar
  • 10.9k
0 votes
1 answer
113 views

Lets say I have four components and I want to conditionally render them depending on a type prop using daggy: In this example type prop value can be the string a, b, c or d here is a working ...
rfc1484's user avatar
  • 9,927
1 vote
2 answers
190 views

I have a typical binary search tree data type: data Tree a = Empty | Branch a (Tree a) (Tree a) deriving Show and a catamorphism foldt :: b -> (a -> b -> b -> b) -> Tree a -> b ...
jmartinezmaes's user avatar
4 votes
2 answers
131 views

A catamorphism can either deconstruct a value [1,2,3].reduce((acc, x) => acc + x, 0); // 6 or maintain the structure and act like the identity of the underlying type: [1,2,3].reduce((acc, x) => ...
user avatar
1 vote
1 answer
57 views

Which one is the appropriate morphism (recursion scheme) to use when the given item's position (index, or path) is required in the transformer function? A simple example would be transforming a list [&...
P Varga's user avatar
  • 20.4k
1 vote
1 answer
300 views

I am trying to implement an expression tree in Haskell as follows: data ExprTr a b = Variable a | Constant b | Add (ExprTr a b) (ExprTr a b) ...
kiyih's user avatar
  • 45
4 votes
2 answers
386 views

I'm trying to make sure I understand the initial algebra and catamorphism concept using the basic case of natural numbers, but I'm definitely missing something (also my Haskell syntax might be a mess)....
jack malkovick's user avatar
11 votes
1 answer
405 views

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 cataNat ...
user avatar
5 votes
0 answers
252 views

I'm trying to build the following recursion scheme: {-# LANGUAGE DeriveFunctor #-} import Data.Functor.Foldable import Control.Comonad import Control.Comonad.Cofree data Term a = Str String | Array [...
Nastya Koroleva's user avatar
1 vote
1 answer
82 views

I am trying to translate the following piece of code from SML to haskell but I'm having a bit of trouble. type List_alg x u = (u, x->u->u) list_cata :: List_alg x u -> [x] -> u list_cata ...
dtran's user avatar
  • 35

15 30 50 per page