1

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 ?

2
  • 5
    The Haskell Platform isn't an IDE. It provides GHC, a compiler, and GHCi, an interactive REPL, along with a set of libraries. Are you wanting to compile this code into an executable? Just do ghc --make myFile.hs. If you want to load it into GHCi interactively, run ghci, then type :l path/to/myFile.hs. Commented Mar 5, 2014 at 22:18
  • @bheklilr WinGhci is included in the Haskell Platform for Windows, and has a graphical interface for loading files and the like (see Heather's answer). It's not a full IDE though. Of course, being a wrapper over ghci, your :l command will also work in it. Commented Mar 6, 2014 at 22:16

1 Answer 1

1

Save it to file, then

File -> Load

that's all, after it you can call main

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.