class - Haskell monoid foldable rose tree -


I need to create an alliance frequency for the data structure of the rose tree:
  Data rose a = a: & gt; [Daily A] Deriving (eq, show)   

with the following monoides and rosary-related classes / instances:

  Example factor everyday where fmap f ( A: & gt; BS) = (FA): & gt; (Map (FMAP F) BS) Class Monoid A where Mempati :: A (<> :: A -> A - & gt; An example monoid [a] where mempty = [] (  

Whatever I tried:

  Example Foldable Rose where fold (A:> B) = a  & Gt; (FoldMapMap b)   

Although this is not working properly, I get an error to check the system:

  *** Fail! Exception: 'Prelude. Delayed ': []: & gt; []   

But I'm not sure why this does not work, can someone help me?

Thanks in advance!

Best Regards, Skyfather

Your implementation of fold was right, there is no reason to change it.

The problem is that it is not enough to define fold Foldable

< / p>

square foldable where the source

Data structures can be combined.

Code> Folder Map or foldr .

Then you should define either foldMap or foldr (or both). Defining foldMap is easier and more natural (and in many cases even more effective). Then you should write something:

  Import data. Falthal import data Monod Data Daily A = A: & gt; [Rose A] deriving (one, show) instance fondable rose, where Foldmap F (X: & gt; xs) = FX and LT; & Gt; Folder Map (Folder f) X    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -