radian 0.0.6 → 0.1
raw patch · 8 files changed
+102/−133 lines, 8 filesdep +HUnitdep +radiandep −QuickCheckdep −directorydep −doctestdep ~basedep ~lensdep ~profunctorssetup-changednew-uploader
Dependencies added: HUnit, radian
Dependencies removed: QuickCheck, directory, doctest, filepath, template-haskell
Dependency ranges changed: base, lens, profunctors
Files
- LICENCE +1/−0
- Setup.hs +2/−0
- Setup.lhs +0/−44
- changelog +4/−0
- radian.cabal +16/−20
- src/Data/Radian.hs +10/−37
- test/doctests.hs +0/−32
- test/hunit_tests.hs +69/−0
LICENCE view
@@ -1,4 +1,5 @@ Copyright 2014 NICTA Limited+Copyright 2018 Commonwealth Scientific and Industrial Research Organisation (CSIRO) ABN 41 687 119 230. All rights reserved.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
− Setup.lhs
@@ -1,44 +0,0 @@-#!/usr/bin/env runhaskell-\begin{code}-{-# OPTIONS_GHC -Wall #-}-module Main (main) where--import Data.List ( nub )-import Data.Version ( showVersion )-import Distribution.Package ( PackageName(PackageName), PackageId, InstalledPackageId, packageVersion, packageName )-import Distribution.PackageDescription ( PackageDescription(), TestSuite(..) )-import Distribution.Simple ( defaultMainWithHooks, UserHooks(..), simpleUserHooks )-import Distribution.Simple.Utils ( rewriteFile, createDirectoryIfMissingVerbose )-import Distribution.Simple.BuildPaths ( autogenModulesDir )-import Distribution.Simple.Setup ( BuildFlags(buildVerbosity), fromFlag )-import Distribution.Simple.LocalBuildInfo ( withLibLBI, withTestLBI, LocalBuildInfo(), ComponentLocalBuildInfo(componentPackageDeps) )-import Distribution.Verbosity ( Verbosity )-import System.FilePath ( (</>) )--main :: IO ()-main = defaultMainWithHooks simpleUserHooks- { buildHook = \pkg lbi hooks flags -> do- generateBuildModule (fromFlag (buildVerbosity flags)) pkg lbi- buildHook simpleUserHooks pkg lbi hooks flags- }--generateBuildModule :: Verbosity -> PackageDescription -> LocalBuildInfo -> IO ()-generateBuildModule verbosity pkg lbi = do- let dir = autogenModulesDir lbi- createDirectoryIfMissingVerbose verbosity True dir- withLibLBI pkg lbi $ \_ libcfg -> do- withTestLBI pkg lbi $ \suite suitecfg -> do- rewriteFile (dir </> "Build_" ++ testName suite ++ ".hs") $ unlines- [ "module Build_" ++ testName suite ++ " where"- , "deps :: [String]"- , "deps = " ++ (show $ formatdeps (testDeps libcfg suitecfg))- ]- where- formatdeps = map (formatone . snd)- formatone p = case packageName p of- PackageName n -> n ++ "-" ++ showVersion (packageVersion p)--testDeps :: ComponentLocalBuildInfo -> ComponentLocalBuildInfo -> [(InstalledPackageId, PackageId)]-testDeps xs ys = nub $ componentPackageDeps xs ++ componentPackageDeps ys--\end{code}
changelog view
@@ -1,3 +1,7 @@+0.1++* Replace doctest with HUnit+ 0.0.6 * Remove dependency on lens.
radian.cabal view
@@ -1,36 +1,35 @@ name: radian-version: 0.0.6+version: 0.1 license: BSD3 license-file: LICENCE author: Tony Morris <ʇǝu˙sıɹɹoɯʇ@ןןǝʞsɐɥ> maintainer: Tony Morris copyright: Copyright (C) 2014 NICTA Limited+ Copyright (C) 2018 Commonwealth Scientific and Industrial Research Organisation (CSIRO) ABN 41 687 119 230. synopsis: Isomorphisms for measurements that use radians. category: Development description: - <<http://i.imgur.com/Ns5hntl.jpg>>+ <<http://i.imgur.com/uZnp9ke.png>> . Isomorphisms for measurements that use radians.-homepage: https://github.com/NICTA/radian-bug-reports: https://github.com/NICTA/radian/issues+homepage: https://github.com/qfpl/radian+bug-reports: https://github.com/qfpl/radian/issues cabal-version: >= 1.10-build-type: Custom+build-type: Simple extra-source-files: changelog+tested-with: GHC == 8.4.1, GHC == 8.2.2, GHC == 8.0.2, GHC == 7.10.3, GHC == 7.8.4, GHC == 7.6.3, GHC == 7.4.2, GHC == 7.2.2, GHC == 7.0.4 source-repository head type: git- location: git@github.com:NICTA/radian.git--flag small_base- description: Choose the new, split-up base package.+ location: git@github.com:qfpl/radian.git library default-language: Haskell2010 build-depends:- base < 5 && >= 3- , profunctors >= 3.1.1+ base >= 3 && < 5+ , profunctors >= 3.1.1 && < 5.3 ghc-options: -Wall@@ -44,24 +43,21 @@ exposed-modules: Data.Radian -test-suite doctests+test-suite hunit type: exitcode-stdio-1.0 main-is:- doctests.hs+ hunit_tests.hs default-language: Haskell2010 build-depends:- base < 5 && >= 3- , doctest >= 0.9.7- , filepath >= 1.3- , directory >= 1.1- , QuickCheck >= 2.0- , template-haskell >= 2.8- , lens >= 4.0+ base >= 4.5 && < 5+ , lens >= 4 && < 4.17+ , HUnit >= 1.2 && < 1.7+ , radian ghc-options: -Wall
src/Data/Radian.hs view
@@ -1,6 +1,16 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE RankNTypes #-} +{-|+Module : Data.Radian+Copyright : (C) CSIRO 2018+License : BSD3+Maintainer : Tony Morris <ʇǝu˙sıɹɹoɯʇ@ןןǝʞsɐɥ>+Stability : experimental+Portability : portable++Isomorphisms between degrees and radians.+-} module Data.Radian( toRadians , fromRadians@@ -10,32 +20,7 @@ import Data.Profunctor(Profunctor(dimap)) import Prelude(Num((*)), Fractional((/)), Floating, pi) --- $setup--- >>> import Control.Lens((#))--- >>> import Prelude(Double)- -- | An isomorphism between radians and degrees.------ >>> toRadians # (180 :: Double)--- 3.141592653589793------ >>> toRadians # (90 :: Double)--- 1.5707963267948966------ >>> toRadians # (359 :: Double)--- 6.265732014659643------ >>> toRadians # (360 :: Double)--- 6.283185307179586------ >>> toRadians # (3600 :: Double)--- 62.83185307179586------ >>> toRadians # (1 :: Double)--- 1.7453292519943295e-2------ >>> toRadians # ((-180) :: Double)--- -3.141592653589793 toRadians :: (Floating a, Floating b) => Iso a b a b@@ -45,18 +30,6 @@ (fmap fr) -- | An isomorphism between degrees and radians.------ >>> fromRadians # (0 :: Double)--- 0.0------ >>> fromRadians # (1 :: Double)--- 57.29577951308232------ >>> fromRadians # ((-1) :: Double)--- -57.29577951308232------ >>> fromRadians # (3 :: Double)--- 171.88733853924697 fromRadians :: (Floating a, Floating b) => Iso a b a b
− test/doctests.hs
@@ -1,32 +0,0 @@-module Main where--import Build_doctests (deps)-import Control.Applicative-import Control.Monad-import Data.List-import System.Directory-import System.FilePath-import Test.DocTest--main ::- IO ()-main =- getSources >>= \sources -> doctest $- "-isrc"- : "-idist/build/autogen"- : "-optP-include"- : "-optPdist/build/autogen/cabal_macros.h"- : "-hide-all-packages"- : map ("-package="++) deps ++ sources--getSources :: IO [FilePath]-getSources = filter (isSuffixOf ".hs") <$> go "src"- where- go dir = do- (dirs, files) <- getFilesAndDirectories dir- (files ++) . concat <$> mapM go dirs--getFilesAndDirectories :: FilePath -> IO ([FilePath], [FilePath])-getFilesAndDirectories dir = do- c <- map (dir </>) . filter (`notElem` ["..", "."]) <$> getDirectoryContents dir- (,) <$> filterM doesDirectoryExist c <*> filterM doesFileExist c
+ test/hunit_tests.hs view
@@ -0,0 +1,69 @@+module Main (main) where++import Test.HUnit (Assertion, Test (TestCase, TestList), (@?=), runTestTT, failures, errors)++import Prelude+import Control.Lens ((#))+import Control.Monad (when)+import System.Exit (exitFailure)++import Data.Radian++(@??=) :: Show a => a -> a -> Assertion+x @??= y = show x @?= show y+infix 1 @??=++t180 :: Assertion+t180 = toRadians # (180 :: Double) @??= pi++t90 :: Assertion+t90 = toRadians # (90 :: Double) @??= 1.5707963267948966++t359 :: Assertion+t359 = toRadians # (359 :: Double) @??= 6.265732014659643++t360 :: Assertion+t360 = toRadians # (360 :: Double) @??= 6.283185307179586++t3600 :: Assertion+t3600 = toRadians # (3600 :: Double) @??= 62.83185307179586++t1 :: Assertion+t1 = toRadians # (1 :: Double) @??= 1.7453292519943295e-2++tneg180 :: Assertion+tneg180 = toRadians # ((-180) :: Double) @??= -pi++f0 :: Assertion+f0 = fromRadians # (0 :: Double) @??= 0.0++f1 :: Assertion+f1 = fromRadians # (1 :: Double) @??= 57.29577951308232++fneg1 :: Assertion+fneg1 = fromRadians # ((-1) :: Double) @??= -57.29577951308232++f3 :: Assertion+f3 = fromRadians # (3 :: Double) @??= 171.88733853924697++tests :: Test+tests =+ TestList $ fmap TestCase [+ t180+ , t90+ , t359+ , t360+ , t3600+ , t1+ , tneg180+ , f0+ , f1+ , fneg1+ , f3+ ]++main :: IO ()+main = do+ c <- runTestTT tests+ when (errors c > 0 || failures c > 0) exitFailure+