packages feed

tilia-0.2.0.0: corpora/vendored/expression/pattern/explicitly-bidirectional-pattern-synonyms-out'.hs

{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ViewPatterns #-}

module Geometry.Polar where

pattern Polar :: Double -> Double -> Point
pattern Polar r theta <- (toPolar -> (r, theta))
    where
        Polar r theta = Point (r * cos theta) (r * sin theta)

pattern Degrees :: Double -> Angle
pattern Degrees d <- (toDegrees -> d)
    where
        Degrees d
            | d < 0 = Degrees (d + 360)
            | otherwise = Radians (d * pi / 180)