1

有人可以帮我吗?我有点卡住了,不知道为什么会收到此错误消息:不在作用域类型构造函数或类“点”中

--import Haste hiding (eval)
--import Haste.Graphics.Canvas
import Data.Maybe
import Expr

-- calculates all points of the graph in pixels
points :: Expr -> Double -> (Int,Int) -> [Point]
points exp sca (w,h) = [(x,realToPix(eval exp(pixToReal x))) | x<- [0..w]]      
 where        
   pixToReal :: Int -> Double 
   pixToReal x = sca*((fromIntegral x)-(fromIntegral w)/2) 
   realToPix :: Double -> Int 
   realToPix x = round ((x/sca) + ((fromIntegral w)/2))        

-- calculates the lines that are going to be drawn between the points
linez :: Expr -> Double -> (Int,Int) -> [(Point,Point)]
linez exp sca (w,h) = zip (points exp sca (w,h)) (drop 1 (points exp sca (w,h)))

-- width and height of the window
sizeX, sizeY :: Int
sizeX = 300
sizeY = 300

  --main :: IO ()
  --main = do 
  --Just can <- getCanvasById "canvas" 
  --Just canElem <- elemById "canvas" 
  --Just func <- elemById "formula" 
  --Just d <- elemById "draw" 
  --onEvent d OnClick $ \_ (x,y) -> do 
      --f <- getProp func "value" 
      --w <- getProp canElem "width" 
      --h <- getProp canElem "height" 
      --render can (stroke (path (points (fromJust (readExpr f)) 0.04 (read w,read h))))
  --return()                             
4

1 回答 1

2

您必须导入“Haste.Graphics.Canvas”,它定义了“Point”的类型别名。

于 2013-10-31T12:12:19.910 回答