Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial commit; code copied from the base package

  • Loading branch information...
commit cf62d712253bb8999f691b0bf3846f514c6aa2fd 0 parents
igfoo igfoo authored
Showing with 164 additions and 0 deletions.
  1. +11 −0 GHC/Bool.hs
  2. +13 −0 GHC/Generics.hs
  3. +62 −0 LICENSE
  4. +57 −0 Setup.hs
  5. +21 −0 ghc-prim.cabal
11 GHC/Bool.hs
@@ -0,0 +1,11 @@
+
+{-# OPTIONS_GHC -fno-implicit-prelude #-}
+
+module GHC.Bool where
+
+-- We need Inl etc behind the scenes for the Bool definition
+import GHC.Generics
+
+default ()
+
+data Bool = False | True
13 GHC/Generics.hs
@@ -0,0 +1,13 @@
+
+{-# OPTIONS_GHC -fno-implicit-prelude #-}
+
+module GHC.Generics where
+
+default ()
+
+data Unit = Unit
+#ifndef __HADDOCK__
+data (:+:) a b = Inl a | Inr b
+data (:*:) a b = a :*: b
+#endif
+
62 LICENSE
@@ -0,0 +1,62 @@
+This library (libraries/ghc-prim) is derived from code from several
+sources:
+
+ * Code from the GHC project which is largely (c) The University of
+ Glasgow, and distributable under a BSD-style license (see below),
+
+ * Code from the Haskell 98 Report which is (c) Simon Peyton Jones
+ and freely redistributable (but see the full license for
+ restrictions).
+
+The full text of these licenses is reproduced below. All of the
+licenses are BSD-style or compatible.
+
+-----------------------------------------------------------------------------
+
+The Glasgow Haskell Compiler License
+
+Copyright 2004, The University Court of the University of Glasgow.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+- Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+
+- 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.
+
+- Neither name of the University nor the names of its contributors may be
+used to endorse or promote products derived from this software without
+specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY COURT OF THE UNIVERSITY OF
+GLASGOW AND THE 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
+UNIVERSITY COURT OF THE UNIVERSITY OF GLASGOW OR THE 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.
+
+-----------------------------------------------------------------------------
+
+Code derived from the document "Report on the Programming Language
+Haskell 98", is distributed under the following license:
+
+ Copyright (c) 2002 Simon Peyton Jones
+
+ The authors intend this Report to belong to the entire Haskell
+ community, and so we grant permission to copy and distribute it for
+ any purpose, provided that it is reproduced in its entirety,
+ including this Notice. Modified versions of this Report may also be
+ copied and distributed for any purpose, provided that the modified
+ version is clearly presented as such, and that it does not claim to
+ be a definition of the Haskell 98 Language.
+
57 Setup.hs
@@ -0,0 +1,57 @@
+
+-- We need to do some ugly hacks here because of GHC magic
+
+module Main (main) where
+
+import Control.Monad
+import Data.List
+import Distribution.PackageDescription
+import Distribution.Simple
+import Distribution.Simple.LocalBuildInfo
+import Distribution.Simple.Utils
+import System.Cmd
+import System.FilePath
+import System.Exit
+import System.Directory
+import Control.Exception (try)
+
+main :: IO ()
+main = do let hooks = defaultUserHooks {
+ buildHook = build_primitive_sources
+ $ buildHook defaultUserHooks,
+ makefileHook = build_primitive_sources
+ $ makefileHook defaultUserHooks,
+ haddockHook = build_primitive_sources
+ $ haddockHook defaultUserHooks }
+ defaultMainWithHooks hooks
+
+type Hook a = PackageDescription -> LocalBuildInfo -> UserHooks -> a -> IO ()
+
+build_primitive_sources :: Hook a -> Hook a
+build_primitive_sources f pd lbi uhs x
+ = do when (compilerFlavor (compiler lbi) == GHC) $ do
+ let genprimopcode = joinPath ["..", "..", "utils",
+ "genprimopcode", "genprimopcode"]
+ primops = joinPath ["..", "..", "compiler", "prelude",
+ "primops.txt"]
+ primhs = joinPath ["GHC", "Prim.hs"]
+ primopwrappers = joinPath ["GHC", "PrimopWrappers.hs"]
+ primhs_tmp = addExtension primhs "tmp"
+ primopwrappers_tmp = addExtension primopwrappers "tmp"
+ maybeExit $ system (genprimopcode ++ " --make-haskell-source < "
+ ++ primops ++ " > " ++ primhs_tmp)
+ maybeUpdateFile primhs_tmp primhs
+ maybeExit $ system (genprimopcode ++ " --make-haskell-wrappers < "
+ ++ primops ++ " > " ++ primopwrappers_tmp)
+ maybeUpdateFile primopwrappers_tmp primopwrappers
+ f pd lbi uhs x
+
+-- Replace a file only if the new version is different from the old.
+-- This prevents make from doing unnecessary work after we run 'setup makefile'
+maybeUpdateFile :: FilePath -> FilePath -> IO ()
+maybeUpdateFile source target = do
+ r <- rawSystem "cmp" ["-s" {-quiet-}, source, target]
+ case r of
+ ExitSuccess -> removeFile source
+ ExitFailure _ -> do try (removeFile target); renameFile source target
+
21 ghc-prim.cabal
@@ -0,0 +1,21 @@
+name: ghc-prim
+version: 0.1
+license: BSD3
+license-file: LICENSE
+maintainer: libraries@haskell.org
+synopsis: GHC primitives
+description:
+ GHC primitives.
+cabal-version: >=1.2
+build-type: Custom
+
+Library {
+ exposed-modules:
+ GHC.Bool
+ GHC.Generics
+ GHC.PrimopWrappers
+ extensions: CPP, MagicHash
+ -- We need to set the package name to ghc-prim (without a version number)
+ -- as it's magic.
+ ghc-options: -package-name ghc-prim
+}
Please sign in to comment.
Something went wrong with that request. Please try again.