packages feed

simpleprelude 1.0.0.3 → 1.0.1.0

raw patch · 8 files changed

+135/−61 lines, 8 filesdep +haskell-src-extsdep +uniplatedep ~basenew-component:exe:simple-ppPVP ok

version bump matches the API change (PVP)

Dependencies added: haskell-src-exts, uniplate

Dependency ranges changed: base

API changes (from Hackage documentation)

Files

simpleprelude.cabal view
@@ -1,6 +1,6 @@ Name:                simpleprelude -Version:             1.0.0.3+Version:             1.0.1.0  Synopsis:            A simplified Haskell prelude for teaching @@ -8,7 +8,7 @@                      module for teaching as well as wrappers for ghc,                      and ghci to use them.                      .-		     The simplified Prelude omits the type classes+                     The simplified Prelude omits the type classes                      Num, Integral, and Ord. Instead it provides                      monomorphically typed arithmetic operators on                      Integer.@@ -18,6 +18,12 @@                      ghci. They are pre-configured to use the Prelude                      module of this library instead of base's Prelude                      module.+                     .+                     Release History:+                     .+                     - 1.0.1.0: Add a Haskell pre-processor to restore+                     the feel of an implicityly imported Prelude although+                     we use -XNoImplicitPrelude.  License:             BSD3 @@ -31,26 +37,26 @@  Build-type:          Simple -Extra-source-files:  LICENSE, README, src/Common.hs+Extra-source-files:  LICENSE, README, src-exec/Common.hs  -- Constraint on the version of Cabal needed to build this package. Cabal-version:       >=1.6   Library-  Exposed-modules:     Prelude      -  exposed:	       False-  +  Exposed-modules:     Prelude+  exposed:             False+   Build-depends:       base > 3 && <5   Hs-Source-Dirs:      src-  -  ++ Executable simple-ghc   Main-Is:              SimpleGHC.hs   Build-depends:        base,                         process >= 1.0 && < 1.2,                         ghc-paths >= 0.1 && < 0.2-  Hs-Source-Dirs:       src+  Hs-Source-Dirs:       src-exec   Executable simple-ghci@@ -58,7 +64,15 @@   Build-depends:        base,                         process >= 1.0 && < 1.2,                         ghc-paths >= 0.1 && < 0.2-  Hs-Source-Dirs:       src+  Hs-Source-Dirs:       src-exec++Executable simple-pp+  Main-Is:              PP.hs+  Build-depends:        base,+                        haskell-src-exts >= 1.11 && < 1.12,+                        uniplate >= 1.6 && < 1.7+  Hs-Source-Dirs:       src-exec+  Source-Repository head   Type:     Mercurial
+ src-exec/Common.hs view
@@ -0,0 +1,22 @@+{-# LANGUAGE CPP, PackageImports, NoImplicitPrelude  #-}++module Common where++import "base" Prelude++additionalArgs :: [String]+additionalArgs = [+      "-package", "simpleprelude"+    , "-hide-package", "base"+    , "-F", "-pgmF", "simple-pp"+    ]+    +-- Up till GHC 6.12 it was enough to use NoImplicitPrelude to use your+-- own fromInteger with numeric literals. From GHC 7 onwards a literal+-- is translated to base-Prelude.fromInteger unless RebindableSyntax+-- is activated.+#if __GLASGOW_HASKELL__ < 700 +    ++ [ "-XNoImplicitPrelude" ]+#else+    ++ [ "-XRebindableSyntax" ]+#endif
+ src-exec/PP.hs view
@@ -0,0 +1,59 @@++import Data.Generics.Uniplate.Data  +import Data.Generics.Biplate hiding (transformBi, childrenBi)+import Language.Haskell.Exts.Annotated +import Language.Haskell.Exts.SrcLoc+import System.Environment+++main :: IO ()+main = do+     [fileName, inputPath, outputPath] <- getArgs+     res <- parseFileWithComments (defaultParseMode { parseFilename = fileName }) inputPath+     case res of +          ParseFailed _ _ -> readFile inputPath >>= return . (header ++) >>= writeFile  outputPath+            where+              header = "{-# LINE 1 \"" ++ fileName ++ "\" #-}\n"+          ParseOk (mod, cs) -> do+                                   let (mod', cs') = case trans fileName mod of+                                                      (Nothing, _) -> (mod, cs) +                                                      (Just l, m)  -> (m, linePragma fileName (l+1) l : move l cs)+                                   writeFile outputPath $ exactPrint mod' cs'+  +++-- move :: Int -> Module SrcSpanInfo -> Module SrcSpanInfo+move boundary = transformBi move'+  where+    move' :: SrcSpan -> SrcSpan+    -- move' = id+    move' s@(SrcSpan n l c l' c')+        | boundary <= l           = SrcSpan n (l+2) c (l'+2) c' +        | otherwise               = s++trans fileName m@(Module l h ps is ds)+    | is == [] && ds == []    = (Nothing, m)+    | otherwise               = (Just insertLine, Module l h ps is' (map (move insertLine) ds))+  where+    insertLine = if length is > 0 then lineOf (head is)+                                  else lineOf (head ds)++    is' = new : map (move insertLine) is +    new = ImportDecl imp (ModuleName mod "Prelude") False False Nothing Nothing Nothing++    imp = infoSpan start [start]+    start = mkSrcSpan (SrcLoc fileName insertLine 1) (SrcLoc fileName insertLine 7)++    mod = infoSpan mod' []+    mod' = mkSrcSpan (SrcLoc fileName insertLine 8) (SrcLoc fileName insertLine 15)++lineOf :: Annotated ast => ast SrcSpanInfo -> Int+lineOf i = l+  where+    (l, _) = srcSpanStart (srcInfoSpan (ann i))++linePragma :: String -> Int -> Int -> Comment+linePragma fileName realLinePos virtualLinePos = Comment True pos commentString+  where+    commentString = "# LINE " ++ show virtualLinePos ++ " \"" ++ fileName ++ "\""++  " #"+    pos = mkSrcSpan (SrcLoc fileName realLinePos 1) (SrcLoc fileName realLinePos (length commentString + 4))
+ src-exec/SimpleGHC.hs view
@@ -0,0 +1,15 @@+{-# LANGUAGE PackageImports, NoImplicitPrelude  #-}++import Common             ( additionalArgs )+import GHC.Paths          ( ghc )+import System.Environment ( getArgs )+import System.Exit        ( exitWith )+import System.Process     ( rawSystem )++import "base" Prelude+++main :: IO ()+main = do+    args <- getArgs+    exitWith =<< rawSystem ghc (additionalArgs ++ args)
+ src-exec/SimpleGHCi.hs view
@@ -0,0 +1,15 @@+{-# LANGUAGE PackageImports, NoImplicitPrelude  #-}++import Common             ( additionalArgs )+import GHC.Paths          ( ghc )+import System.Environment ( getArgs )+import System.Exit        ( exitWith )+import System.Process     ( rawSystem )++import "base" Prelude+++main :: IO ()+main = do+    args <- getArgs+    exitWith =<< rawSystem ghc (["--interactive"] ++ additionalArgs ++ args)
− src/Common.hs
@@ -1,21 +0,0 @@-{-# LANGUAGE CPP, PackageImports, NoImplicitPrelude  #-}--module Common where--import "base" Prelude--additionalArgs :: [String]-additionalArgs = [-      "-package", "simpleprelude"-    , "-hide-package", "base"-    ]-    --- Up till GHC 6.12 it was enough to use NoImplicitPrelude to use your--- own fromInteger with numeric literals. From GHC 7 onwards a literal--- is translated to base-Prelude.fromInteger unless RebindableSyntax--- is activated.-#if __GLASGOW_HASKELL__ < 700 -    ++ [ "-XNoImplicitPrelude" ]-#else-    ++ [ "-XRebindableSyntax" ]-#endif
− src/SimpleGHC.hs
@@ -1,15 +0,0 @@-{-# LANGUAGE PackageImports, NoImplicitPrelude  #-}--import Common             ( additionalArgs )-import GHC.Paths          ( ghc )-import System.Environment ( getArgs )-import System.Exit        ( exitWith )-import System.Process     ( rawSystem )--import "base" Prelude---main :: IO ()-main = do-    args <- getArgs-    exitWith =<< rawSystem ghc (additionalArgs ++ args)
− src/SimpleGHCi.hs
@@ -1,15 +0,0 @@-{-# LANGUAGE PackageImports, NoImplicitPrelude  #-}--import Common             ( additionalArgs )-import GHC.Paths          ( ghc )-import System.Environment ( getArgs )-import System.Exit        ( exitWith )-import System.Process     ( rawSystem )--import "base" Prelude---main :: IO ()-main = do-    args <- getArgs-    exitWith =<< rawSystem ghc (["--interactive"] ++ additionalArgs ++ args)