使用WinGHCi实现第一个Haskell程序
这不是我的代码:使用WinGHCi实现第一个Haskell程序,haskell,Haskell,这不是我的代码: 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: -- -- >>> chainE
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"
我想在Haskell IDE中运行这个:
但是WinGhci只提供了一个类似repl的结构?如何将其作为haskell文件加载并运行 将其保存到文件,然后
文件->加载
所有这些,在它之后,您可以调用
main
Haskell平台不是IDE。它提供了编译器GHC和交互式REPL GHCi以及一组库。是否要将此代码编译为可执行文件?只需执行ghc--make myFile.hs。如果要以交互方式将其加载到GHCi中,请运行GHCi
,然后键入:l path/to/myFile.hs
@bheklir WinGhci包含在Haskell Platform for Windows中,并具有用于加载文件等的图形界面(请参阅Heather的答案)。但它不是一个完整的IDE。当然,作为ghci的包装器,您的:l命令也可以在其中使用。