init
This commit is contained in:
commit
825eb48997
10 changed files with 245 additions and 0 deletions
12
.ghci
Normal file
12
.ghci
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
:set -isrc
|
||||||
|
:l src/Lets.hs
|
||||||
|
:set prompt ">> "
|
||||||
|
:set -Wall
|
||||||
|
:set -fno-warn-unused-binds
|
||||||
|
:set -fno-warn-unused-do-bind
|
||||||
|
:set -fno-warn-unused-imports
|
||||||
|
:set -fno-warn-type-defaults
|
||||||
|
:set -XNoImplicitPrelude
|
||||||
|
:set -XScopedTypeVariables
|
||||||
|
:set -XOverloadedStrings
|
||||||
|
:set -XRebindableSyntax
|
30
.gitignore
vendored
Normal file
30
.gitignore
vendored
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
*~
|
||||||
|
*#*
|
||||||
|
|
||||||
|
# CABAL
|
||||||
|
/dist
|
||||||
|
/cabal-dev
|
||||||
|
/.cabal-sandbox
|
||||||
|
/cabal.sandbox.config
|
||||||
|
|
||||||
|
# Haskell Program Coverage
|
||||||
|
/.hpc
|
||||||
|
|
||||||
|
# Leksah
|
||||||
|
*.lkshs
|
||||||
|
|
||||||
|
# Intellij IDEA
|
||||||
|
/.idea
|
||||||
|
|
||||||
|
# darcs
|
||||||
|
/_darcs
|
||||||
|
|
||||||
|
# ctags
|
||||||
|
TAGS
|
||||||
|
|
||||||
|
# sbt
|
||||||
|
/project
|
||||||
|
/target
|
||||||
|
|
||||||
|
*.swp
|
||||||
|
|
27
LICENCE
Normal file
27
LICENCE
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
Copyright 2012-2015 National ICT Australia Limited
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions
|
||||||
|
are met:
|
||||||
|
1. Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
3. Neither the name of the author nor the names of his contributors
|
||||||
|
may be used to endorse or promote products derived from this software
|
||||||
|
without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
|
||||||
|
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGE.
|
1
README.markdown
Normal file
1
README.markdown
Normal file
|
@ -0,0 +1 @@
|
||||||
|
# Let's Lens
|
44
Setup.lhs
Normal file
44
Setup.lhs
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
#!/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}
|
4
changelog
Normal file
4
changelog
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
0.0.1
|
||||||
|
|
||||||
|
Init
|
||||||
|
|
71
lets-lens.cabal
Normal file
71
lets-lens.cabal
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
name: lets-lens
|
||||||
|
version: 0.0.1
|
||||||
|
license: BSD3
|
||||||
|
license-file: LICENCE
|
||||||
|
author: Tony Morris <ʇǝu˙sıɹɹoɯʇ@ןןǝʞsɐɥ>
|
||||||
|
maintainer: Tony Morris <ʇǝu˙sıɹɹoɯʇ@ןןǝʞsɐɥ>
|
||||||
|
copyright: Copyright (C) 2015 National ICT Australia Limited
|
||||||
|
synopsis: Source code for exercises on the lens concept
|
||||||
|
category: Education
|
||||||
|
description: Source code for exercises on the lens concept
|
||||||
|
homepage: https://github.com/tonymorris/lets-lens
|
||||||
|
bug-reports: https://github.com/tonymorris/lets-lens/issues
|
||||||
|
cabal-version: >= 1.10
|
||||||
|
build-type: Custom
|
||||||
|
extra-source-files: changelog
|
||||||
|
|
||||||
|
source-repository head
|
||||||
|
type: git
|
||||||
|
location: git@github.com:tonymorris/lets-lens.git
|
||||||
|
|
||||||
|
flag small_base
|
||||||
|
description: Choose the new, split-up base package.
|
||||||
|
|
||||||
|
library
|
||||||
|
default-language: Haskell2010
|
||||||
|
|
||||||
|
build-depends: base < 5 && >= 4
|
||||||
|
, QuickCheck >= 2.0
|
||||||
|
, doctest >= 0.9.7
|
||||||
|
, containers >= 0.4.0.0
|
||||||
|
, array >= 0.4
|
||||||
|
|
||||||
|
ghc-options: -Wall
|
||||||
|
-fno-warn-unused-binds
|
||||||
|
-fno-warn-unused-do-bind
|
||||||
|
-fno-warn-unused-imports
|
||||||
|
-fno-warn-type-defaults
|
||||||
|
|
||||||
|
default-extensions: NoImplicitPrelude
|
||||||
|
ScopedTypeVariables
|
||||||
|
InstanceSigs
|
||||||
|
RebindableSyntax
|
||||||
|
|
||||||
|
hs-source-dirs: src
|
||||||
|
|
||||||
|
exposed-modules: Lets
|
||||||
|
|
||||||
|
test-suite doctests
|
||||||
|
type:
|
||||||
|
exitcode-stdio-1.0
|
||||||
|
|
||||||
|
main-is:
|
||||||
|
doctests.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
|
||||||
|
|
||||||
|
ghc-options:
|
||||||
|
-Wall
|
||||||
|
-threaded
|
||||||
|
|
||||||
|
hs-source-dirs:
|
||||||
|
test
|
2
src/Lets.hs
Normal file
2
src/Lets.hs
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
module Lets where
|
||||||
|
|
8
test/.gitignore
vendored
Normal file
8
test/.gitignore
vendored
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
# cabal
|
||||||
|
/dist
|
||||||
|
|
||||||
|
# cabal-dev
|
||||||
|
/cabal-dev
|
||||||
|
|
||||||
|
# Haskell Program Coverage
|
||||||
|
/.hpc
|
46
test/doctests.hs
Normal file
46
test/doctests.hs
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
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
|
||||||
|
|
||||||
|
sourceDirectories ::
|
||||||
|
[FilePath]
|
||||||
|
sourceDirectories =
|
||||||
|
[
|
||||||
|
"src"
|
||||||
|
]
|
||||||
|
|
||||||
|
isSourceFile ::
|
||||||
|
FilePath
|
||||||
|
-> Bool
|
||||||
|
isSourceFile p =
|
||||||
|
and [takeFileName p /= "Setup.hs", isSuffixOf ".hs" p]
|
||||||
|
|
||||||
|
getSources :: IO [FilePath]
|
||||||
|
getSources =
|
||||||
|
liftM (filter isSourceFile . concat) (mapM go sourceDirectories)
|
||||||
|
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
|
Loading…
Reference in a new issue