This is not my code :
import Data.Monoid (Endo (..), appEndo)
import Data.Foldable (foldMap)
-- | chainEndos chain a list of endomorphisms to create a new one
-- Point-free version is feasible and redable.
-- Level: Easy
--
-- Examples:
--
-- >>> chainEndos [(+1),(*3)] 2
-- 7
-- >>> chainEndos [('h':),('e':)] "llo"
-- "hello"
--
-- >>> chainEndos [] (12 :: Int)
-- 12
--
chainEndos :: [a->a] -> a -> a
chainEndos = appEndo . foldMap Endo
chainEndos' :: [a->a] -> a -> a
chainEndos' = foldr (.) id
main = print $ chainEndos [('h':),('e':)] "llo"
I would like to run this in the Haskell IDE : http://www.haskell.org/platform/
But WinGhci offers just a repl like structure ? How can I load this as haskell file and run it ?
Save it to file, then
File -> Load
that's all, after it you can call main
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments