diff --git a/.ghci b/.ghci new file mode 100644 index 0000000..eb9d82c --- /dev/null +++ b/.ghci @@ -0,0 +1 @@ +:set prompt "ghci> " diff --git a/donut-hs.cabal b/donut-hs.cabal index 3d3c297..9a86d0e 100644 --- a/donut-hs.cabal +++ b/donut-hs.cabal @@ -9,6 +9,7 @@ build-type: Simple executable donut-hs main-is: Main.hs + other-modules: Data.Vector build-depends: base >=4.14 && <4.15 hs-source-dirs: src default-language: Haskell2010 diff --git a/src/Data/Vector.hs b/src/Data/Vector.hs new file mode 100644 index 0000000..437b215 --- /dev/null +++ b/src/Data/Vector.hs @@ -0,0 +1,13 @@ +module Data.Vector +( Vector(Vector) ) where + +data Vector a = Vector a a a + deriving (Show, Eq) + +instance (Num a) => Num (Vector a) where + (Vector x1 y1 z1) + (Vector x2 y2 z2) = Vector (x1+x2) (y1+y2) (z1+z2) + (*) = undefined + abs = undefined + signum = undefined + fromInteger = undefined + negate = undefined diff --git a/src/Main.hs b/src/Main.hs index 65ae4a0..b4c3ff3 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -1,4 +1,22 @@ module Main where +import Data.Vector + +_r :: Float +_r = 1.0 +_R :: Float +_R = 2.0 + +drawCircle :: Vector Float -> [Vector Float] +drawCircle center = map ((+) center . vradius) [0,0.1..2*pi] + where + vradius :: Float -> Vector Float + vradius theta = Vector (_r * cos theta) (_r * sin theta) 0 + +render :: [[Char]] +render = ["hello", "world"] + main :: IO () -main = putStrLn "Hello, Haskell!" +main = do + let screen = unlines render + putStr screen