fork download
  1. import qualified Data.Foldable as F
  2. import Data.Monoid
  3. import Control.Monad
  4. import Control.Monad.Instances
  5.  
  6. monkeyNum :: Integer -> Integer
  7. monkeyNum = F.foldMap ((^ 5) . read . (:[])) . show
  8.  
  9. isMonkey :: Integer -> Bool
  10. isMonkey = monkeyNum >>= (==)
  11.  
  12. main :: IO ()
  13. main = print $ sum $ filter isMonkey [10..99999]
  14.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
[1 of 1] Compiling Main             ( prog.hs, prog.o )

prog.hs:7:12:
    No instance for (Monoid Integer)
      arising from a use of `F.foldMap' at prog.hs:7:12-43
    Possible fix: add an instance declaration for (Monoid Integer)
    In the first argument of `(.)', namely
        `F.foldMap ((^ 5) . read . (: []))'
    In the expression: F.foldMap ((^ 5) . read . (: [])) . show
    In the definition of `monkeyNum':
        monkeyNum = F.foldMap ((^ 5) . read . (: [])) . show
stdout
Standard output is empty