kedgeree-demo-0.1.0
 
Safe HaskellNone

Geometry

Description

2D geometry primitives — a small module used to show off the Kedgeree Haddock theme.

It exercises the things a theme has to get right: section headings, data declarations with record fields, type classes with methods and instances, operators, and inline code / code blocks.

let unit = Circle origin 1
area unit  -- ≈ 3.14159

Bold like this, emphasis like this, and a link to Shape.

Synopsis

Points

data PointSource #

A point in the plane.

Constructors

Point 

Fields

  • px :: !Double

    the x coordinate

  • py :: !Double

    the y coordinate

Instances

Instances details
Semigroup Point

Points form a semigroup under componentwise addition. Both Point and Semigroup are defined elsewhere, so Haddock lists this under a separate Orphan instances section at the foot of the page.

Instance details

Defined in Showcase

Methods

(<>) :: Point -> Point -> Point

sconcat :: NonEmpty Point -> Point

stimes :: Integral b => b -> Point -> Point

Eq Point Source # 
Instance details

Defined in Geometry

Methods

(==) :: Point -> Point -> Bool

(/=) :: Point -> Point -> Bool

Show Point Source # 
Instance details

Defined in Geometry

Methods

showsPrec :: Int -> Point -> ShowS

show :: Point -> String

showList :: [Point] -> ShowS

Describe Point Source # 
Instance details

Defined in Showcase

Methods

describe :: Point -> StringSource #

origin :: PointSource #

The origin, Point 0 0.

translate :: Point -> Point -> PointSource #

Move a point by a delta given as another point.

Since: kedgeree-demo-0.1.0

(.+.) :: Point -> Point -> Point infixl 6Source #

Infix alias for translate.

Shapes

data ShapeSource #

A geometric shape.

Constructors

Circle Point Double

a circle given its centre and radius

Rectangle Point Point

an axis-aligned rectangle given two opposite corners

Instances

Instances details
Eq Shape Source # 
Instance details

Defined in Geometry

Methods

(==) :: Shape -> Shape -> Bool

(/=) :: Shape -> Shape -> Bool

Show Shape Source # 
Instance details

Defined in Geometry

Methods

showsPrec :: Int -> Shape -> ShowS

show :: Shape -> String

showList :: [Shape] -> ShowS

Measurable Shape Source # 
Instance details

Defined in Geometry

Methods

area :: Shape -> DoubleSource #

perimeter :: Shape -> DoubleSource #

circle :: Point -> Double -> ShapeSource #

Smart constructor for a circle.

rectangle :: Double -> Double -> ShapeSource #

Smart constructor for a rectangle from its width and height, anchored at the origin.

Measuring things

class Measurable a whereSource #

Things that have an area and a perimeter.

Methods

area :: a -> DoubleSource #

The enclosed area.

perimeter :: a -> DoubleSource #

The length of the boundary.

Instances

Instances details
Measurable Shape Source # 
Instance details

Defined in Geometry

Methods

area :: Shape -> DoubleSource #

perimeter :: Shape -> DoubleSource #