Use the loeb function: loeb :: Functor a => a (a x -> x) -> a x
loeb x = fmap (\a -> a (loeb x)) x
To implement a basic spreadsheet processor. The processor should accept input of the form: |##|A |B |C |D |
|01|(* B1 C1)|2 |3 |(* A1 2)|
The output from this example should be: |##|A |B |C |D |
|01|6 |2 |3 |12 |
Cells may contain number literals, references to other cells of the form <letter><number>, or function applications of the form (<function> *<args>).
>>82 Could not deduce (Functor m) from the context (Monad m)
arising from a use of `fmap' at <interactive>:1:13-16
Possible fix:
add (Functor m) to the context of an expression type signature
In the first argument of `(.)', namely `fmap'
In the second argument of `(=<<)', namely `fmap . flip id'
In the first argument of `fix', namely `(fmap . flip id =<<)'
Name:
Anonymous2009-07-02 5:05
new challenge: write the loeb function in a language that isn't haskell, and use it to do something useful.
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy