简体   繁体   English

haskell代码编译leksah但不是ghc

[英]haskell code compiles on leksah but not ghc

As the question states, I have some that compiles in leksah but does not compile using ghc --make filename.hs 正如问题所述,我有一些在leksah中编译,但不使用ghc --make filename.hs编译

The code: 编码:

module Main (
    main
) where

pair a b = (Pair (a, b))

newtype Pair a b = Pair (a,b)  deriving (Eq,Show)

instance (Num a,Num b) => Num (Pair a b) where
   Pair (a,b) + Pair (c,d) = Pair (a+c,b+d)
   Pair (a,b) * Pair (c,d) = Pair (a*c,b*d)
   Pair (a,b) - Pair (c,d) = Pair (a-c,b-d)
   abs    (Pair (a,b)) = Pair (abs a,    abs b) 
   signum (Pair (a,b)) = Pair (signum a, signum b) 
   fromInteger i = Pair (fromInteger i, fromInteger i)

main = do   
            a <- return (pair 1 3)   
            print a
            print "haha"  
            print 3.2  
            print [3,4,3]  

Is there an option I need to invoke to make it run with ghc --make ? 我需要调用一个选项来使其与ghc --make运行吗?

Disclaimer: I did not make the pair newtype . 免责声明:我没有成对新类型

Edit: 编辑:

When using ghc --make Bignumber.hs (Bignumber.hs is the filename) the output is 当使用ghc --make Bignumber.hs (Bignumber.hs是文件名)输出时

[1 of 1] Compiling Main             ( BigNumber.hs, BigNumber.o )

BigNumber.hs:20:13: parse error on input `print'

Check your indentation: maybe you're mixing tabs and spaces in a way that ghc interprets differently than leksah? 检查你的缩进:也许你正在以一种ghc解释方式与leksah不同的方式混合制表符和空格? I don't see another explanation for a parse error at print . 我没有看到print解析错误的另一种解释。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM