├── .github └── FUNDING.yml ├── .gitignore ├── README.md ├── TODO.org ├── prana-boot ├── packages │ ├── base-4.11.1.0 │ │ ├── Control │ │ │ ├── Applicative.hs │ │ │ ├── Arrow.hs │ │ │ ├── Category.hs │ │ │ ├── Concurrent.hs │ │ │ ├── Concurrent │ │ │ │ ├── Chan.hs │ │ │ │ ├── MVar.hs │ │ │ │ ├── QSem.hs │ │ │ │ └── QSemN.hs │ │ │ ├── Exception.hs │ │ │ ├── Exception │ │ │ │ └── Base.hs │ │ │ ├── Monad.hs │ │ │ └── Monad │ │ │ │ ├── Fail.hs │ │ │ │ ├── Fix.hs │ │ │ │ ├── IO │ │ │ │ └── Class.hs │ │ │ │ ├── Instances.hs │ │ │ │ ├── ST.hs │ │ │ │ ├── ST │ │ │ │ ├── Imp.hs │ │ │ │ ├── Lazy.hs │ │ │ │ ├── Lazy │ │ │ │ │ ├── Imp.hs │ │ │ │ │ ├── Safe.hs │ │ │ │ │ └── Unsafe.hs │ │ │ │ ├── Safe.hs │ │ │ │ ├── Strict.hs │ │ │ │ └── Unsafe.hs │ │ │ │ └── Zip.hs │ │ ├── Data │ │ │ ├── Bifoldable.hs │ │ │ ├── Bifunctor.hs │ │ │ ├── Bitraversable.hs │ │ │ ├── Bits.hs │ │ │ ├── Bool.hs │ │ │ ├── Char.hs │ │ │ ├── Coerce.hs │ │ │ ├── Complex.hs │ │ │ ├── Data.hs │ │ │ ├── Dynamic.hs │ │ │ ├── Either.hs │ │ │ ├── Eq.hs │ │ │ ├── Fixed.hs │ │ │ ├── Foldable.hs │ │ │ ├── Function.hs │ │ │ ├── Functor.hs │ │ │ ├── Functor │ │ │ │ ├── Classes.hs │ │ │ │ ├── Compose.hs │ │ │ │ ├── Const.hs │ │ │ │ ├── Identity.hs │ │ │ │ ├── Product.hs │ │ │ │ ├── Sum.hs │ │ │ │ └── Utils.hs │ │ │ ├── IORef.hs │ │ │ ├── Int.hs │ │ │ ├── Ix.hs │ │ │ ├── Kind.hs │ │ │ ├── List.hs │ │ │ ├── List │ │ │ │ └── NonEmpty.hs │ │ │ ├── Maybe.hs │ │ │ ├── Monoid.hs │ │ │ ├── OldList.hs │ │ │ ├── Ord.hs │ │ │ ├── Proxy.hs │ │ │ ├── Ratio.hs │ │ │ ├── STRef.hs │ │ │ ├── STRef │ │ │ │ ├── Lazy.hs │ │ │ │ └── Strict.hs │ │ │ ├── Semigroup.hs │ │ │ ├── Semigroup │ │ │ │ ├── Internal.hs │ │ │ │ └── Internal.hs-boot │ │ │ ├── String.hs │ │ │ ├── Traversable.hs │ │ │ ├── Tuple.hs │ │ │ ├── Type │ │ │ │ ├── Bool.hs │ │ │ │ ├── Coercion.hs │ │ │ │ └── Equality.hs │ │ │ ├── Typeable.hs │ │ │ ├── Typeable │ │ │ │ └── Internal.hs │ │ │ ├── Unique.hs │ │ │ ├── Version.hs │ │ │ ├── Void.hs │ │ │ └── Word.hs │ │ ├── Debug │ │ │ ├── Trace.hs │ │ │ └── Trace.hs-boot │ │ ├── Foreign.hs │ │ ├── Foreign │ │ │ ├── C.hs │ │ │ ├── C │ │ │ │ ├── Error.hs │ │ │ │ ├── String.hs │ │ │ │ └── Types.hs │ │ │ ├── Concurrent.hs │ │ │ ├── ForeignPtr.hs │ │ │ ├── ForeignPtr │ │ │ │ ├── Imp.hs │ │ │ │ ├── Safe.hs │ │ │ │ └── Unsafe.hs │ │ │ ├── Marshal.hs │ │ │ ├── Marshal │ │ │ │ ├── Alloc.hs │ │ │ │ ├── Array.hs │ │ │ │ ├── Error.hs │ │ │ │ ├── Pool.hs │ │ │ │ ├── Safe.hs │ │ │ │ ├── Unsafe.hs │ │ │ │ └── Utils.hs │ │ │ ├── Ptr.hs │ │ │ ├── Safe.hs │ │ │ ├── StablePtr.hs │ │ │ └── Storable.hs │ │ ├── GHC │ │ │ ├── Arr.hs │ │ │ ├── Base.hs │ │ │ ├── Base.hs-boot │ │ │ ├── ByteOrder.hs │ │ │ ├── Char.hs │ │ │ ├── Clock.hsc │ │ │ ├── Conc.hs │ │ │ ├── Conc │ │ │ │ ├── IO.hs │ │ │ │ ├── Signal.hs │ │ │ │ ├── Sync.hs │ │ │ │ └── Windows.hs │ │ │ ├── ConsoleHandler.hs │ │ │ ├── Constants.hs │ │ │ ├── Desugar.hs │ │ │ ├── Enum.hs │ │ │ ├── Environment.hs │ │ │ ├── Err.hs │ │ │ ├── Event.hs │ │ │ ├── Event │ │ │ │ ├── Arr.hs │ │ │ │ ├── Array.hs │ │ │ │ ├── Control.hs │ │ │ │ ├── EPoll.hsc │ │ │ │ ├── IntTable.hs │ │ │ │ ├── Internal.hs │ │ │ │ ├── KQueue.hsc │ │ │ │ ├── Manager.hs │ │ │ │ ├── PSQ.hs │ │ │ │ ├── Poll.hsc │ │ │ │ ├── Thread.hs │ │ │ │ ├── TimerManager.hs │ │ │ │ └── Unique.hs │ │ │ ├── Exception.hs │ │ │ ├── Exception.hs-boot │ │ │ ├── ExecutionStack.hs │ │ │ ├── ExecutionStack │ │ │ │ └── Internal.hsc │ │ │ ├── Exts.hs │ │ │ ├── Fingerprint.hs │ │ │ ├── Fingerprint.hs-boot │ │ │ ├── Fingerprint │ │ │ │ └── Type.hs │ │ │ ├── Float.hs │ │ │ ├── Float │ │ │ │ ├── ConversionUtils.hs │ │ │ │ └── RealFracMethods.hs │ │ │ ├── Foreign.hs │ │ │ ├── ForeignPtr.hs │ │ │ ├── GHCi.hs │ │ │ ├── Generics.hs │ │ │ ├── IO.hs │ │ │ ├── IO.hs-boot │ │ │ ├── IO │ │ │ │ ├── Buffer.hs │ │ │ │ ├── BufferedIO.hs │ │ │ │ ├── Device.hs │ │ │ │ ├── Encoding.hs │ │ │ │ ├── Encoding.hs-boot │ │ │ │ ├── Encoding │ │ │ │ │ ├── CodePage.hs │ │ │ │ │ ├── CodePage │ │ │ │ │ │ ├── API.hs │ │ │ │ │ │ └── Table.hs │ │ │ │ │ ├── Failure.hs │ │ │ │ │ ├── Iconv.hs │ │ │ │ │ ├── Latin1.hs │ │ │ │ │ ├── Types.hs │ │ │ │ │ ├── UTF16.hs │ │ │ │ │ ├── UTF32.hs │ │ │ │ │ └── UTF8.hs │ │ │ │ ├── Exception.hs │ │ │ │ ├── Exception.hs-boot │ │ │ │ ├── FD.hs │ │ │ │ ├── Handle.hs │ │ │ │ ├── Handle.hs-boot │ │ │ │ ├── Handle │ │ │ │ │ ├── FD.hs │ │ │ │ │ ├── FD.hs-boot │ │ │ │ │ ├── Internals.hs │ │ │ │ │ ├── Lock.hsc │ │ │ │ │ ├── Text.hs │ │ │ │ │ └── Types.hs │ │ │ │ ├── IOMode.hs │ │ │ │ └── Unsafe.hs │ │ │ ├── IOArray.hs │ │ │ ├── IORef.hs │ │ │ ├── Int.hs │ │ │ ├── List.hs │ │ │ ├── MVar.hs │ │ │ ├── Natural.hs │ │ │ ├── Num.hs │ │ │ ├── OldList.hs │ │ │ ├── OverloadedLabels.hs │ │ │ ├── PArr.hs │ │ │ ├── Pack.hs │ │ │ ├── Profiling.hs │ │ │ ├── Ptr.hs │ │ │ ├── RTS │ │ │ │ └── Flags.hsc │ │ │ ├── Read.hs │ │ │ ├── Real.hs │ │ │ ├── Real.hs-boot │ │ │ ├── Records.hs │ │ │ ├── ST.hs │ │ │ ├── STRef.hs │ │ │ ├── Show.hs │ │ │ ├── Stable.hs │ │ │ ├── Stack.hs │ │ │ ├── Stack │ │ │ │ ├── CCS.hs-boot │ │ │ │ ├── CCS.hsc │ │ │ │ └── Types.hs │ │ │ ├── StaticPtr.hs │ │ │ ├── StaticPtr │ │ │ │ └── Internal.hs │ │ │ ├── Stats.hsc │ │ │ ├── Storable.hs │ │ │ ├── TopHandler.hs │ │ │ ├── TypeLits.hs │ │ │ ├── TypeNats.hs │ │ │ ├── Unicode.hs │ │ │ ├── Weak.hs │ │ │ ├── Windows.hs │ │ │ └── Word.hs │ │ ├── LICENSE │ │ ├── Numeric.hs │ │ ├── Numeric │ │ │ └── Natural.hs │ │ ├── Prelude.hs │ │ ├── Setup.hs │ │ ├── System │ │ │ ├── CPUTime.hsc │ │ │ ├── CPUTime │ │ │ │ ├── Posix │ │ │ │ │ ├── ClockGetTime.hsc │ │ │ │ │ ├── RUsage.hsc │ │ │ │ │ └── Times.hsc │ │ │ │ ├── Unsupported.hs │ │ │ │ ├── Utils.hs │ │ │ │ └── Windows.hsc │ │ │ ├── Console │ │ │ │ └── GetOpt.hs │ │ │ ├── Environment.hs │ │ │ ├── Environment │ │ │ │ ├── Blank.hsc │ │ │ │ └── ExecutablePath.hsc │ │ │ ├── Exit.hs │ │ │ ├── IO.hs │ │ │ ├── IO │ │ │ │ ├── Error.hs │ │ │ │ └── Unsafe.hs │ │ │ ├── Info.hs │ │ │ ├── Mem.hs │ │ │ ├── Mem │ │ │ │ ├── StableName.hs │ │ │ │ └── Weak.hs │ │ │ ├── Posix │ │ │ │ ├── Internals.hs │ │ │ │ └── Types.hs │ │ │ └── Timeout.hs │ │ ├── Text │ │ │ ├── ParserCombinators │ │ │ │ ├── ReadP.hs │ │ │ │ └── ReadPrec.hs │ │ │ ├── Printf.hs │ │ │ ├── Read.hs │ │ │ ├── Read │ │ │ │ └── Lex.hs │ │ │ ├── Show.hs │ │ │ └── Show │ │ │ │ └── Functions.hs │ │ ├── Type │ │ │ ├── Reflection.hs │ │ │ └── Reflection │ │ │ │ └── Unsafe.hs │ │ ├── Unsafe │ │ │ └── Coerce.hs │ │ ├── aclocal.m4 │ │ ├── autom4te.cache │ │ │ ├── output.0 │ │ │ └── traces.0 │ │ ├── base.buildinfo │ │ ├── base.buildinfo.in │ │ ├── base.cabal │ │ ├── cbits │ │ │ ├── DarwinUtils.c │ │ │ ├── PrelIOUtils.c │ │ │ ├── SetEnv.c │ │ │ ├── WCsubst.c │ │ │ ├── Win32Utils.c │ │ │ ├── consUtils.c │ │ │ ├── iconv.c │ │ │ ├── inputReady.c │ │ │ ├── md5.c │ │ │ ├── primFloat.c │ │ │ └── sysconf.c │ │ ├── changelog.md │ │ ├── config.guess │ │ ├── config.log │ │ ├── config.status │ │ ├── config.sub │ │ ├── configure.ac │ │ ├── include │ │ │ ├── CTypes.h │ │ │ ├── EventConfig.h.in │ │ │ ├── HsBase.h │ │ │ ├── HsBaseConfig.h.in │ │ │ ├── MachDeps.h │ │ │ ├── WCsubst.h │ │ │ ├── consUtils.h │ │ │ ├── ieee-flpt.h │ │ │ └── md5.h │ │ └── install-sh │ ├── ghc-prim-0.5.2.0 │ │ ├── GHC │ │ │ ├── CString.hs │ │ │ ├── Classes.hs │ │ │ ├── Debug.hs │ │ │ ├── IntWord64.hs │ │ │ ├── Magic.hs │ │ │ ├── PrimopWrappers.hs │ │ │ ├── Tuple.hs │ │ │ └── Types.hs │ │ ├── LICENSE │ │ ├── Setup.hs │ │ ├── cbits │ │ │ ├── atomic.c │ │ │ ├── bswap.c │ │ │ ├── clz.c │ │ │ ├── ctz.c │ │ │ ├── debug.c │ │ │ ├── longlong.c │ │ │ ├── pdep.c │ │ │ ├── pext.c │ │ │ ├── popcnt.c │ │ │ └── word2float.c │ │ ├── changelog.md │ │ ├── ghc-prim.cabal │ │ └── primops.txt │ └── integer-gmp-1.0.2.0 │ │ ├── LICENSE │ │ ├── Setup.hs │ │ ├── aclocal.m4 │ │ ├── cbits │ │ └── wrappers.c │ │ ├── changelog.md │ │ ├── config.guess │ │ ├── config.sub │ │ ├── configure │ │ ├── configure.ac │ │ ├── gmp │ │ └── config.mk.in │ │ ├── include │ │ └── HsIntegerGmp.h.in │ │ ├── install-sh │ │ ├── integer-gmp.buildinfo.in │ │ ├── integer-gmp.cabal │ │ └── src │ │ └── GHC │ │ ├── Integer.hs │ │ └── Integer │ │ ├── GMP │ │ └── Internals.hs │ │ ├── Logarithms.hs │ │ ├── Logarithms │ │ └── Internals.hs │ │ └── Type.hs └── prana-boot.cabal ├── prana-ffi-types.txt ├── prana-ghc ├── .gitignore ├── README.md ├── app │ ├── Intero │ │ └── Compat.hs │ └── Main.hs ├── cbits │ ├── HsVersions.h │ ├── PosixSource.h │ └── hschooks.c ├── prana-ghc.cabal ├── regenerate.sh └── src │ └── Prana │ ├── Collect.hs │ ├── FFI.hs │ ├── Ghc.hs │ ├── Index.hs │ ├── Reconstruct.hs │ └── Rename.hs ├── prana-interpreter ├── README.md ├── TODO ├── prana-interpreter.cabal ├── src │ └── Prana │ │ ├── Interpreter.hs │ │ └── Interpreter │ │ ├── Binding.hs │ │ ├── Boxing.hs │ │ ├── Eval.hs │ │ ├── PrimOps.hs │ │ ├── PrimOps │ │ └── TH.hs │ │ └── Types.hs └── test │ ├── Main.hs │ └── assets │ ├── ArrayLoopTest.hs │ ├── ArrayTest.hs │ ├── Atan2.hs │ ├── CharTest.hs │ ├── DoubleTest.hs │ ├── FibCodata.hs │ ├── FibIterative.hs │ └── Foreign.hs ├── prana-primops ├── app │ └── Main.hs ├── prana-primops.cabal ├── primops.txt └── src │ ├── Lexer.x │ ├── Parser.y │ ├── ParserM.hs │ ├── Prana │ ├── PrimOp.hs │ └── PrimOp │ │ └── Type.hs │ └── Syntax.hs ├── prana-types ├── README.md ├── prana-types.cabal └── src │ └── Prana │ ├── Pretty.hs │ └── Types.hs ├── stack.yaml └── stack.yaml.lock /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | patreon: chrisdone 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .stack-work 2 | *.hi 3 | *.o 4 | *.prana 5 | dist/ 6 | prana-boot/packages/ghc-prim-0.5.2.0/GHC/Prim.hs 7 | prana-boot/packages/ghc-prim-0.5.2.0/Setup 8 | prana-boot/packages/base-4.11.1.0/configure 9 | prana-boot/packages/base-4.11.1.0/Setup 10 | prana-boot/packages/base-4.11.1.0/autom4te.cache/requests 11 | prana-boot/packages/integer-gmp-1.0.2.0/Setup 12 | -------------------------------------------------------------------------------- /TODO.org: -------------------------------------------------------------------------------- 1 | * DONE Write a simple C runtime linker and function call 2 | CLOSED: [2019-11-09 Sat 17:28] 3 | - State "DONE" from "TODO" [2019-11-09 Sat 17:28] 4 | #+BEGIN_SRC 5 | import System.Posix.DynamicLinker 6 | import Foreign.Ptr 7 | import Foreign.LibFFI 8 | main = do 9 | malloc <- dlsym Default "malloc" 10 | memset <- dlsym Default "memset" 11 | p <- callFFI malloc (retPtr retVoid) [argCSize (2^30)] 12 | callFFI memset (retPtr retVoid) [argPtr p, argCInt 0, argCSize (2^30)] 13 | callFFI memset (retPtr retVoid) [argPtr nullPtr, argCInt 0, argCSize 1] 14 | #+END_SRC 15 | 16 | From 17 | http://hackage.haskell.org/package/libffi-0.1/docs/Foreign-LibFFI.html 18 | 19 | * TODO Add foreign calls to the index 20 | * DONE Add ForeignOp constructor to Op (ref'ing CCallSpec) 21 | CLOSED: [2019-10-27 Sun 11:38] 22 | - State "DONE" from "TODO" [2019-10-27 Sun 11:38] 23 | #+BEGIN_SRC 24 | data Op 25 | = PrimOp PrimOp 26 | + | ForeignOp CCallSpec 27 | #+END_SRC 28 | * Deal with this issue: 29 | 30 | #+BEGIN_SRC 31 | prana-interpreter> [1 of 1] Recompiling Atan2 [prana] 32 | prana-interpreter> [1 of 1] Converting Atan2 [prana] 33 | prana-interpreter> prana-interpreter-test: panic! (the 'impossible' happened) 34 | prana-interpreter> (GHC version 8.4.3 for x86_64-unknown-linux): 35 | prana-interpreter> Unexpected function for data alt case scrutinee. 36 | #+END_SRC 37 | 38 | #+BEGIN_SRC 39 | {-# LANGUAGE NoImplicitPrelude #-} 40 | 41 | -- | Demonstrate various use of the FFI. 42 | 43 | module Atan2 where 44 | 45 | import Foreign.C 46 | 47 | foreign import ccall "math.h atan2" 48 | atan2 :: CDouble -> CDouble -> CDouble 49 | 50 | it :: CDouble 51 | it = atan2 (-10) (10) * 180 / 3.14159265 52 | #+END_SRC 53 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Control/Category.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Trustworthy #-} 2 | {-# LANGUAGE GADTs #-} 3 | {-# LANGUAGE NoImplicitPrelude #-} 4 | {-# LANGUAGE PolyKinds #-} 5 | {-# OPTIONS_GHC -Wno-inline-rule-shadowing #-} 6 | -- The RULES for the methods of class Category may never fire 7 | -- e.g. identity/left, identity/right, association; see Trac #10528 8 | 9 | ----------------------------------------------------------------------------- 10 | -- | 11 | -- Module : Control.Category 12 | -- Copyright : (c) Ashley Yakeley 2007 13 | -- License : BSD-style (see the LICENSE file in the distribution) 14 | -- 15 | -- Maintainer : ashley@semantic.org 16 | -- Stability : experimental 17 | -- Portability : portable 18 | 19 | -- http://ghc.haskell.org/trac/ghc/ticket/1773 20 | 21 | module Control.Category where 22 | 23 | import qualified GHC.Base (id,(.)) 24 | import Data.Type.Coercion 25 | import Data.Type.Equality 26 | import GHC.Prim (coerce) 27 | 28 | infixr 9 . 29 | infixr 1 >>>, <<< 30 | 31 | -- | A class for categories. Instances should satisfy the laws 32 | -- 33 | -- @ 34 | -- f '.' 'id' = f -- (right identity) 35 | -- 'id' '.' f = f -- (left identity) 36 | -- f '.' (g '.' h) = (f '.' g) '.' h -- (associativity) 37 | -- @ 38 | class Category cat where 39 | -- | the identity morphism 40 | id :: cat a a 41 | 42 | -- | morphism composition 43 | (.) :: cat b c -> cat a b -> cat a c 44 | 45 | {-# RULES 46 | "identity/left" forall p . 47 | id . p = p 48 | "identity/right" forall p . 49 | p . id = p 50 | "association" forall p q r . 51 | (p . q) . r = p . (q . r) 52 | #-} 53 | 54 | -- | @since 3.0 55 | instance Category (->) where 56 | id = GHC.Base.id 57 | (.) = (GHC.Base..) 58 | 59 | -- | @since 4.7.0.0 60 | instance Category (:~:) where 61 | id = Refl 62 | Refl . Refl = Refl 63 | 64 | -- | @since 4.10.0.0 65 | instance Category (:~~:) where 66 | id = HRefl 67 | HRefl . HRefl = HRefl 68 | 69 | -- | @since 4.7.0.0 70 | instance Category Coercion where 71 | id = Coercion 72 | (.) Coercion = coerce 73 | 74 | -- | Right-to-left composition 75 | (<<<) :: Category cat => cat b c -> cat a b -> cat a c 76 | (<<<) = (.) 77 | 78 | -- | Left-to-right composition 79 | (>>>) :: Category cat => cat a b -> cat b c -> cat a c 80 | f >>> g = g . f 81 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Control/Monad/Fail.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Trustworthy #-} 2 | {-# LANGUAGE NoImplicitPrelude #-} 3 | 4 | -- | 5 | -- Module : Control.Monad.Fail 6 | -- Copyright : (C) 2015 David Luposchainsky, 7 | -- (C) 2015 Herbert Valerio Riedel 8 | -- License : BSD-style (see the file LICENSE) 9 | -- 10 | -- Maintainer : libraries@haskell.org 11 | -- Stability : provisional 12 | -- Portability : portable 13 | -- 14 | -- Transitional module providing the 'MonadFail' class and primitive 15 | -- instances. 16 | -- 17 | -- This module can be imported for defining forward compatible 18 | -- 'MonadFail' instances: 19 | -- 20 | -- @ 21 | -- import qualified Control.Monad.Fail as Fail 22 | -- 23 | -- instance Monad Foo where 24 | -- (>>=) = {- ...bind impl... -} 25 | -- 26 | -- -- Provide legacy 'fail' implementation for when 27 | -- -- new-style MonadFail desugaring is not enabled. 28 | -- fail = Fail.fail 29 | -- 30 | -- instance Fail.MonadFail Foo where 31 | -- fail = {- ...fail implementation... -} 32 | -- @ 33 | -- 34 | -- See 35 | -- for more details. 36 | -- 37 | -- @since 4.9.0.0 38 | -- 39 | module Control.Monad.Fail ( MonadFail(fail) ) where 40 | 41 | import GHC.Base (String, Monad(), Maybe(Nothing), IO()) 42 | import {-# SOURCE #-} GHC.IO (failIO) 43 | 44 | -- | When a value is bound in @do@-notation, the pattern on the left 45 | -- hand side of @<-@ might not match. In this case, this class 46 | -- provides a function to recover. 47 | -- 48 | -- A 'Monad' without a 'MonadFail' instance may only be used in conjunction 49 | -- with pattern that always match, such as newtypes, tuples, data types with 50 | -- only a single data constructor, and irrefutable patterns (@~pat@). 51 | -- 52 | -- Instances of 'MonadFail' should satisfy the following law: @fail s@ should 53 | -- be a left zero for '>>=', 54 | -- 55 | -- @ 56 | -- fail s >>= f = fail s 57 | -- @ 58 | -- 59 | -- If your 'Monad' is also 'MonadPlus', a popular definition is 60 | -- 61 | -- @ 62 | -- fail _ = mzero 63 | -- @ 64 | -- 65 | -- @since 4.9.0.0 66 | class Monad m => MonadFail m where 67 | fail :: String -> m a 68 | 69 | 70 | -- | @since 4.9.0.0 71 | instance MonadFail Maybe where 72 | fail _ = Nothing 73 | 74 | -- | @since 4.9.0.0 75 | instance MonadFail [] where 76 | {-# INLINE fail #-} 77 | fail _ = [] 78 | 79 | -- | @since 4.9.0.0 80 | instance MonadFail IO where 81 | fail = failIO 82 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Control/Monad/IO/Class.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Safe #-} 2 | ----------------------------------------------------------------------------- 3 | -- | 4 | -- Module : Control.Monad.IO.Class 5 | -- Copyright : (c) Andy Gill 2001, 6 | -- (c) Oregon Graduate Institute of Science and Technology, 2001 7 | -- License : BSD-style (see the file LICENSE) 8 | -- 9 | -- Maintainer : R.Paterson@city.ac.uk 10 | -- Stability : experimental 11 | -- Portability : portable 12 | -- 13 | -- Class of monads based on @IO@. 14 | ----------------------------------------------------------------------------- 15 | 16 | module Control.Monad.IO.Class ( 17 | MonadIO(..) 18 | ) where 19 | 20 | -- | Monads in which 'IO' computations may be embedded. 21 | -- Any monad built by applying a sequence of monad transformers to the 22 | -- 'IO' monad will be an instance of this class. 23 | -- 24 | -- Instances should satisfy the following laws, which state that 'liftIO' 25 | -- is a transformer of monads: 26 | -- 27 | -- * @'liftIO' . 'return' = 'return'@ 28 | -- 29 | -- * @'liftIO' (m >>= f) = 'liftIO' m >>= ('liftIO' . f)@ 30 | 31 | class (Monad m) => MonadIO m where 32 | -- | Lift a computation from the 'IO' monad. 33 | liftIO :: IO a -> m a 34 | 35 | -- | @since 4.9.0.0 36 | instance MonadIO IO where 37 | liftIO = id 38 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Control/Monad/Instances.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Safe #-} 2 | 3 | ----------------------------------------------------------------------------- 4 | -- | 5 | -- Module : Control.Monad.Instances 6 | -- Copyright : (c) The University of Glasgow 2001 7 | -- License : BSD-style (see the file libraries/base/LICENSE) 8 | -- 9 | -- Maintainer : libraries@haskell.org 10 | -- Stability : provisional 11 | -- Portability : portable 12 | -- 13 | -- /This module is DEPRECATED and will be removed in the future!/ 14 | -- 15 | -- 'Functor' and 'Monad' instances for @(->) r@ and 16 | -- 'Functor' instances for @(,) a@ and @'Either' a@. 17 | 18 | module Control.Monad.Instances {-# DEPRECATED "This module now contains no instances and will be removed in the future" #-} -- deprecated in 7.8 19 | (Functor(..),Monad(..)) where 20 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Control/Monad/ST.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Trustworthy #-} 2 | 3 | ----------------------------------------------------------------------------- 4 | -- | 5 | -- Module : Control.Monad.ST 6 | -- Copyright : (c) The University of Glasgow 2001 7 | -- License : BSD-style (see the file libraries/base/LICENSE) 8 | -- 9 | -- Maintainer : libraries@haskell.org 10 | -- Stability : experimental 11 | -- Portability : non-portable (requires universal quantification for runST) 12 | -- 13 | -- This library provides support for /strict/ state threads, as 14 | -- described in the PLDI \'94 paper by John Launchbury and Simon Peyton 15 | -- Jones /Lazy Functional State Threads/. 16 | -- 17 | -- References (variables) that can be used within the @ST@ monad are 18 | -- provided by "Data.STRef", and arrays are provided by 19 | -- [Data.Array.ST](https://hackage.haskell.org/package/array/docs/Data-Array-ST.html). 20 | 21 | ----------------------------------------------------------------------------- 22 | 23 | module Control.Monad.ST ( 24 | -- * The 'ST' Monad 25 | ST, -- abstract, instance of Functor, Monad, Typeable. 26 | runST, 27 | fixST, 28 | 29 | -- * Converting 'ST' to 'IO' 30 | RealWorld, -- abstract 31 | stToIO, 32 | ) where 33 | 34 | import Control.Monad.ST.Imp 35 | 36 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Control/Monad/ST/Imp.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Unsafe #-} 2 | {-# OPTIONS_HADDOCK hide #-} 3 | 4 | ----------------------------------------------------------------------------- 5 | -- | 6 | -- Module : Control.Monad.ST.Imp 7 | -- Copyright : (c) The University of Glasgow 2001 8 | -- License : BSD-style (see the file libraries/base/LICENSE) 9 | -- 10 | -- Maintainer : libraries@haskell.org 11 | -- Stability : experimental 12 | -- Portability : non-portable (requires universal quantification for runST) 13 | -- 14 | -- This library provides support for /strict/ state threads, as 15 | -- described in the PLDI \'94 paper by John Launchbury and Simon Peyton 16 | -- Jones /Lazy Functional State Threads/. 17 | -- 18 | ----------------------------------------------------------------------------- 19 | 20 | module Control.Monad.ST.Imp ( 21 | -- * The 'ST' Monad 22 | ST, -- abstract, instance of Functor, Monad, Typeable. 23 | runST, 24 | fixST, 25 | 26 | -- * Converting 'ST' to 'IO' 27 | RealWorld, -- abstract 28 | stToIO, 29 | 30 | -- * Unsafe operations 31 | unsafeInterleaveST, 32 | unsafeDupableInterleaveST, 33 | unsafeIOToST, 34 | unsafeSTToIO 35 | ) where 36 | 37 | import GHC.ST ( ST, runST, fixST, unsafeInterleaveST 38 | , unsafeDupableInterleaveST ) 39 | import GHC.Base ( RealWorld ) 40 | import GHC.IO ( stToIO, unsafeIOToST, unsafeSTToIO ) 41 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Control/Monad/ST/Lazy.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Trustworthy #-} 2 | 3 | ----------------------------------------------------------------------------- 4 | -- | 5 | -- Module : Control.Monad.ST.Lazy 6 | -- Copyright : (c) The University of Glasgow 2001 7 | -- License : BSD-style (see the file libraries/base/LICENSE) 8 | -- 9 | -- Maintainer : libraries@haskell.org 10 | -- Stability : provisional 11 | -- Portability : non-portable (requires universal quantification for runST) 12 | -- 13 | -- This module presents an identical interface to "Control.Monad.ST", 14 | -- except that the monad delays evaluation of state operations until 15 | -- a value depending on them is required. 16 | -- 17 | ----------------------------------------------------------------------------- 18 | 19 | module Control.Monad.ST.Lazy ( 20 | -- * The 'ST' monad 21 | ST, 22 | runST, 23 | fixST, 24 | 25 | -- * Converting between strict and lazy 'ST' 26 | strictToLazyST, lazyToStrictST, 27 | 28 | -- * Converting 'ST' To 'IO' 29 | RealWorld, 30 | stToIO, 31 | ) where 32 | 33 | import Control.Monad.ST.Lazy.Imp 34 | 35 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Control/Monad/ST/Lazy/Safe.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Trustworthy #-} 2 | 3 | ----------------------------------------------------------------------------- 4 | -- | 5 | -- Module : Control.Monad.ST.Lazy.Safe 6 | -- Copyright : (c) The University of Glasgow 2001 7 | -- License : BSD-style (see the file libraries/base/LICENSE) 8 | -- 9 | -- Maintainer : libraries@haskell.org 10 | -- Stability : provisional 11 | -- Portability : non-portable (requires universal quantification for runST) 12 | -- 13 | -- This module presents an identical interface to "Control.Monad.ST", 14 | -- except that the monad delays evaluation of state operations until 15 | -- a value depending on them is required. 16 | -- 17 | -- Safe API only. 18 | -- 19 | ----------------------------------------------------------------------------- 20 | 21 | module Control.Monad.ST.Lazy.Safe {-# DEPRECATED "Safe is now the default, please use Control.Monad.ST.Lazy instead" #-} ( 22 | -- * The 'ST' monad 23 | ST, 24 | runST, 25 | fixST, 26 | 27 | -- * Converting between strict and lazy 'ST' 28 | strictToLazyST, lazyToStrictST, 29 | 30 | -- * Converting 'ST' To 'IO' 31 | RealWorld, 32 | stToIO, 33 | ) where 34 | 35 | import Control.Monad.ST.Lazy.Imp 36 | 37 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Control/Monad/ST/Lazy/Unsafe.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Unsafe #-} 2 | 3 | ----------------------------------------------------------------------------- 4 | -- | 5 | -- Module : Control.Monad.ST.Lazy.Unsafe 6 | -- Copyright : (c) The University of Glasgow 2001 7 | -- License : BSD-style (see the file libraries/base/LICENSE) 8 | -- 9 | -- Maintainer : libraries@haskell.org 10 | -- Stability : provisional 11 | -- Portability : non-portable (requires universal quantification for runST) 12 | -- 13 | -- This module presents an identical interface to "Control.Monad.ST", 14 | -- except that the monad delays evaluation of state operations until 15 | -- a value depending on them is required. 16 | -- 17 | -- Unsafe API. 18 | -- 19 | ----------------------------------------------------------------------------- 20 | 21 | module Control.Monad.ST.Lazy.Unsafe ( 22 | -- * Unsafe operations 23 | unsafeInterleaveST, 24 | unsafeIOToST 25 | ) where 26 | 27 | import Control.Monad.ST.Lazy.Imp 28 | 29 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Control/Monad/ST/Safe.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Trustworthy #-} 2 | 3 | ----------------------------------------------------------------------------- 4 | -- | 5 | -- Module : Control.Monad.ST.Safe 6 | -- Copyright : (c) The University of Glasgow 2001 7 | -- License : BSD-style (see the file libraries/base/LICENSE) 8 | -- 9 | -- Maintainer : libraries@haskell.org 10 | -- Stability : experimental 11 | -- Portability : non-portable (requires universal quantification for runST) 12 | -- 13 | -- This library provides support for /strict/ state threads, as 14 | -- described in the PLDI \'94 paper by John Launchbury and Simon Peyton 15 | -- Jones /Lazy Functional State Threads/. 16 | -- 17 | -- Safe API Only. 18 | -- 19 | ----------------------------------------------------------------------------- 20 | 21 | module Control.Monad.ST.Safe {-# DEPRECATED "Safe is now the default, please use Control.Monad.ST instead" #-} ( 22 | -- * The 'ST' Monad 23 | ST, -- abstract 24 | runST, 25 | fixST, 26 | 27 | -- * Converting 'ST' to 'IO' 28 | RealWorld, -- abstract 29 | stToIO, 30 | ) where 31 | 32 | import Control.Monad.ST.Imp 33 | 34 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Control/Monad/ST/Strict.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Safe #-} 2 | 3 | ----------------------------------------------------------------------------- 4 | -- | 5 | -- Module : Control.Monad.ST.Strict 6 | -- Copyright : (c) The University of Glasgow 2001 7 | -- License : BSD-style (see the file libraries/base/LICENSE) 8 | -- 9 | -- Maintainer : libraries@haskell.org 10 | -- Stability : provisional 11 | -- Portability : non-portable (requires universal quantification for runST) 12 | -- 13 | -- The strict ST monad (re-export of "Control.Monad.ST") 14 | -- 15 | ----------------------------------------------------------------------------- 16 | 17 | module Control.Monad.ST.Strict ( 18 | module Control.Monad.ST 19 | ) where 20 | 21 | import Control.Monad.ST 22 | 23 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Control/Monad/ST/Unsafe.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Unsafe #-} 2 | 3 | ----------------------------------------------------------------------------- 4 | -- | 5 | -- Module : Control.Monad.ST.Unsafe 6 | -- Copyright : (c) The University of Glasgow 2001 7 | -- License : BSD-style (see the file libraries/base/LICENSE) 8 | -- 9 | -- Maintainer : libraries@haskell.org 10 | -- Stability : experimental 11 | -- Portability : non-portable (requires universal quantification for runST) 12 | -- 13 | -- This library provides support for /strict/ state threads, as 14 | -- described in the PLDI \'94 paper by John Launchbury and Simon Peyton 15 | -- Jones /Lazy Functional State Threads/. 16 | -- 17 | -- Unsafe API. 18 | -- 19 | ----------------------------------------------------------------------------- 20 | 21 | module Control.Monad.ST.Unsafe ( 22 | -- * Unsafe operations 23 | unsafeInterleaveST, 24 | unsafeDupableInterleaveST, 25 | unsafeIOToST, 26 | unsafeSTToIO 27 | ) where 28 | 29 | import Control.Monad.ST.Imp 30 | 31 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Data/Bool.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Trustworthy #-} 2 | {-# LANGUAGE NoImplicitPrelude #-} 3 | 4 | ----------------------------------------------------------------------------- 5 | -- | 6 | -- Module : Data.Bool 7 | -- Copyright : (c) The University of Glasgow 2001 8 | -- License : BSD-style (see the file libraries/base/LICENSE) 9 | -- 10 | -- Maintainer : libraries@haskell.org 11 | -- Stability : experimental 12 | -- Portability : portable 13 | -- 14 | -- The 'Bool' type and related functions. 15 | -- 16 | ----------------------------------------------------------------------------- 17 | 18 | module Data.Bool ( 19 | -- * Booleans 20 | Bool(..), 21 | -- ** Operations 22 | (&&), 23 | (||), 24 | not, 25 | otherwise, 26 | bool, 27 | ) where 28 | 29 | import GHC.Base 30 | 31 | -- | Case analysis for the 'Bool' type. @'bool' x y p@ evaluates to @x@ 32 | -- when @p@ is 'False', and evaluates to @y@ when @p@ is 'True'. 33 | -- 34 | -- This is equivalent to @if p then y else x@; that is, one can 35 | -- think of it as an if-then-else construct with its arguments 36 | -- reordered. 37 | -- 38 | -- @since 4.7.0.0 39 | -- 40 | -- ==== __Examples__ 41 | -- 42 | -- Basic usage: 43 | -- 44 | -- >>> bool "foo" "bar" True 45 | -- "bar" 46 | -- >>> bool "foo" "bar" False 47 | -- "foo" 48 | -- 49 | -- Confirm that @'bool' x y p@ and @if p then y else x@ are 50 | -- equivalent: 51 | -- 52 | -- >>> let p = True; x = "bar"; y = "foo" 53 | -- >>> bool x y p == if p then y else x 54 | -- True 55 | -- >>> let p = False 56 | -- >>> bool x y p == if p then y else x 57 | -- True 58 | -- 59 | bool :: a -> a -> Bool -> a 60 | bool f _ False = f 61 | bool _ t True = t 62 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Data/Coerce.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Unsafe #-} 2 | {-# LANGUAGE NoImplicitPrelude #-} 3 | 4 | ----------------------------------------------------------------------------- 5 | -- | 6 | -- Module : Data.Coerce 7 | -- Copyright : (c) The University of Glasgow 2001 8 | -- License : BSD-style (see the file libraries/base/LICENSE) 9 | -- 10 | -- Maintainer : libraries@haskell.org 11 | -- Stability : provisional 12 | -- Portability : portable 13 | -- 14 | -- Safe coercions between data types. 15 | -- 16 | -- More in-depth information can be found on the 17 | -- 18 | -- 19 | -- @since 4.7.0.0 20 | ----------------------------------------------------------------------------- 21 | 22 | module Data.Coerce 23 | ( -- * Safe coercions 24 | coerce, Coercible, 25 | ) where 26 | import GHC.Prim (coerce) 27 | import GHC.Types (Coercible) 28 | 29 | import GHC.Base () -- for build ordering; see Notes in GHC.Base for more info 30 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Data/Eq.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Trustworthy #-} 2 | {-# LANGUAGE NoImplicitPrelude #-} 3 | 4 | ----------------------------------------------------------------------------- 5 | -- | 6 | -- Module : Data.Eq 7 | -- Copyright : (c) The University of Glasgow 2005 8 | -- License : BSD-style (see the file libraries/base/LICENSE) 9 | -- 10 | -- Maintainer : libraries@haskell.org 11 | -- Stability : stable 12 | -- Portability : portable 13 | -- 14 | -- Equality 15 | -- 16 | ----------------------------------------------------------------------------- 17 | 18 | module Data.Eq ( 19 | Eq(..), 20 | ) where 21 | 22 | import GHC.Base 23 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Data/Functor/Const.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE DeriveGeneric #-} 2 | {-# LANGUAGE GeneralizedNewtypeDeriving #-} 3 | {-# LANGUAGE NoImplicitPrelude #-} 4 | {-# LANGUAGE PolyKinds #-} 5 | {-# LANGUAGE ScopedTypeVariables #-} 6 | {-# LANGUAGE Trustworthy #-} 7 | 8 | ----------------------------------------------------------------------------- 9 | -- | 10 | -- Module : Data.Functor.Const 11 | -- Copyright : Conor McBride and Ross Paterson 2005 12 | -- License : BSD-style (see the LICENSE file in the distribution) 13 | -- 14 | -- Maintainer : libraries@haskell.org 15 | -- Stability : experimental 16 | -- Portability : portable 17 | 18 | -- The 'Const' functor. 19 | -- 20 | -- @since 4.9.0.0 21 | 22 | module Data.Functor.Const (Const(..)) where 23 | 24 | import Data.Bits (Bits, FiniteBits) 25 | import Data.Foldable (Foldable(foldMap)) 26 | import Foreign.Storable (Storable) 27 | 28 | import GHC.Arr (Ix) 29 | import GHC.Base 30 | import GHC.Enum (Bounded, Enum) 31 | import GHC.Float (Floating, RealFloat) 32 | import GHC.Generics (Generic, Generic1) 33 | import GHC.Num (Num) 34 | import GHC.Real (Fractional, Integral, Real, RealFrac) 35 | import GHC.Read (Read(readsPrec), readParen, lex) 36 | import GHC.Show (Show(showsPrec), showParen, showString) 37 | 38 | -- | The 'Const' functor. 39 | newtype Const a b = Const { getConst :: a } 40 | deriving ( Bits, Bounded, Enum, Eq, FiniteBits, Floating, Fractional 41 | , Generic, Generic1, Integral, Ix, Semigroup, Monoid, Num, Ord 42 | , Real, RealFrac, RealFloat, Storable) 43 | 44 | -- | This instance would be equivalent to the derived instances of the 45 | -- 'Const' newtype if the 'runConst' field were removed 46 | -- 47 | -- @since 4.8.0.0 48 | instance Read a => Read (Const a b) where 49 | readsPrec d = readParen (d > 10) 50 | $ \r -> [(Const x,t) | ("Const", s) <- lex r, (x, t) <- readsPrec 11 s] 51 | 52 | -- | This instance would be equivalent to the derived instances of the 53 | -- 'Const' newtype if the 'runConst' field were removed 54 | -- 55 | -- @since 4.8.0.0 56 | instance Show a => Show (Const a b) where 57 | showsPrec d (Const x) = showParen (d > 10) $ 58 | showString "Const " . showsPrec 11 x 59 | 60 | -- | @since 4.7.0.0 61 | instance Foldable (Const m) where 62 | foldMap _ _ = mempty 63 | 64 | -- | @since 2.01 65 | instance Functor (Const m) where 66 | fmap _ (Const v) = Const v 67 | 68 | -- | @since 2.0.1 69 | instance Monoid m => Applicative (Const m) where 70 | pure _ = Const mempty 71 | liftA2 _ (Const x) (Const y) = Const (x `mappend` y) 72 | (<*>) = coerce (mappend :: m -> m -> m) 73 | -- This is pretty much the same as 74 | -- Const f <*> Const v = Const (f `mappend` v) 75 | -- but guarantees that mappend for Const a b will have the same arity 76 | -- as the one for a; it won't create a closure to raise the arity 77 | -- to 2. 78 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Data/Int.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Trustworthy #-} 2 | {-# LANGUAGE NoImplicitPrelude #-} 3 | 4 | ----------------------------------------------------------------------------- 5 | -- | 6 | -- Module : Data.Int 7 | -- Copyright : (c) The University of Glasgow 2001 8 | -- License : BSD-style (see the file libraries/base/LICENSE) 9 | -- 10 | -- Maintainer : libraries@haskell.org 11 | -- Stability : experimental 12 | -- Portability : portable 13 | -- 14 | -- Signed integer types 15 | -- 16 | ----------------------------------------------------------------------------- 17 | 18 | module Data.Int 19 | ( 20 | -- * Signed integer types 21 | Int, 22 | Int8, Int16, Int32, Int64, 23 | 24 | -- * Notes 25 | 26 | -- $notes 27 | ) where 28 | 29 | import GHC.Base ( Int ) 30 | import GHC.Int ( Int8, Int16, Int32, Int64 ) 31 | 32 | {- $notes 33 | 34 | * All arithmetic is performed modulo 2^n, where @n@ is the number of 35 | bits in the type. 36 | 37 | * For coercing between any two integer types, use 'Prelude.fromIntegral', 38 | which is specialized for all the common cases so should be fast 39 | enough. Coercing word types (see "Data.Word") to and from integer 40 | types preserves representation, not sign. 41 | 42 | * The rules that hold for 'Prelude.Enum' instances over a 43 | bounded type such as 'Int' (see the section of the 44 | Haskell report dealing with arithmetic sequences) also hold for the 45 | 'Prelude.Enum' instances over the various 46 | 'Int' types defined here. 47 | 48 | * Right and left shifts by amounts greater than or equal to the width 49 | of the type result in either zero or -1, depending on the sign of 50 | the value being shifted. This is contrary to the behaviour in C, 51 | which is undefined; a common interpretation is to truncate the shift 52 | count to the width of the type, for example @1 \<\< 32 53 | == 1@ in some C implementations. 54 | -} 55 | 56 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Data/Ix.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Trustworthy #-} 2 | 3 | ----------------------------------------------------------------------------- 4 | -- | 5 | -- Module : Data.Ix 6 | -- Copyright : (c) The University of Glasgow 2001 7 | -- License : BSD-style (see the file libraries/base/LICENSE) 8 | -- 9 | -- Maintainer : libraries@haskell.org 10 | -- Stability : stable 11 | -- Portability : portable 12 | -- 13 | -- The 'Ix' class is used to map a contiguous subrange of values in 14 | -- type onto integers. It is used primarily for array indexing 15 | -- (see the array package). 'Ix' uses row-major order. 16 | -- 17 | ----------------------------------------------------------------------------- 18 | 19 | module Data.Ix 20 | ( 21 | -- * The 'Ix' class 22 | Ix 23 | ( range 24 | , index 25 | , inRange 26 | , rangeSize 27 | ) 28 | -- Ix instances: 29 | -- 30 | -- Ix Char 31 | -- Ix Int 32 | -- Ix Integer 33 | -- Ix Bool 34 | -- Ix Ordering 35 | -- Ix () 36 | -- (Ix a, Ix b) => Ix (a, b) 37 | -- ... 38 | 39 | -- * Deriving Instances of 'Ix' 40 | -- | Derived instance declarations for the class 'Ix' are only possible 41 | -- for enumerations (i.e. datatypes having only nullary constructors) 42 | -- and single-constructor datatypes, including arbitrarily large tuples, 43 | -- whose constituent types are instances of 'Ix'. 44 | -- 45 | -- * For an enumeration, the nullary constructors are assumed to be 46 | -- numbered left-to-right with the indices being 0 to n-1 inclusive. This 47 | -- is the same numbering defined by the 'Enum' class. For example, given 48 | -- the datatype: 49 | -- 50 | -- > data Colour = Red | Orange | Yellow | Green | Blue | Indigo | Violet 51 | -- 52 | -- we would have: 53 | -- 54 | -- > range (Yellow,Blue) == [Yellow,Green,Blue] 55 | -- > index (Yellow,Blue) Green == 1 56 | -- > inRange (Yellow,Blue) Red == False 57 | -- 58 | -- * For single-constructor datatypes, the derived instance declarations 59 | -- are as shown for tuples in chapter 19, section 2 of the Haskell 2010 report: 60 | -- . 61 | 62 | ) where 63 | 64 | import GHC.Arr 65 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Data/Kind.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Trustworthy, ExplicitNamespaces #-} 2 | 3 | ----------------------------------------------------------------------------- 4 | -- | 5 | -- Module : Data.Kind 6 | -- License : BSD-style (see the LICENSE file in the distribution) 7 | -- 8 | -- Maintainer : libraries@haskell.org 9 | -- Stability : experimental 10 | -- Portability : not portable 11 | -- 12 | -- Basic kinds 13 | -- 14 | -- @since 4.9.0.0 15 | ----------------------------------------------------------------------------- 16 | 17 | module Data.Kind ( Type, Constraint, type (*), type (★) ) where 18 | 19 | import GHC.Types 20 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Data/Ord.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Trustworthy #-} 2 | {-# LANGUAGE NoImplicitPrelude #-} 3 | {-# LANGUAGE GeneralizedNewtypeDeriving #-} 4 | 5 | ----------------------------------------------------------------------------- 6 | -- | 7 | -- Module : Data.Ord 8 | -- Copyright : (c) The University of Glasgow 2005 9 | -- License : BSD-style (see the file libraries/base/LICENSE) 10 | -- 11 | -- Maintainer : libraries@haskell.org 12 | -- Stability : stable 13 | -- Portability : portable 14 | -- 15 | -- Orderings 16 | -- 17 | ----------------------------------------------------------------------------- 18 | 19 | module Data.Ord ( 20 | Ord(..), 21 | Ordering(..), 22 | Down(..), 23 | comparing, 24 | ) where 25 | 26 | import GHC.Base 27 | import GHC.Show 28 | import GHC.Read 29 | import GHC.Num 30 | 31 | -- | 32 | -- > comparing p x y = compare (p x) (p y) 33 | -- 34 | -- Useful combinator for use in conjunction with the @xxxBy@ family 35 | -- of functions from "Data.List", for example: 36 | -- 37 | -- > ... sortBy (comparing fst) ... 38 | comparing :: (Ord a) => (b -> a) -> b -> b -> Ordering 39 | comparing p x y = compare (p x) (p y) 40 | 41 | -- | The 'Down' type allows you to reverse sort order conveniently. A value of type 42 | -- @'Down' a@ contains a value of type @a@ (represented as @'Down' a@). 43 | -- If @a@ has an @'Ord'@ instance associated with it then comparing two 44 | -- values thus wrapped will give you the opposite of their normal sort order. 45 | -- This is particularly useful when sorting in generalised list comprehensions, 46 | -- as in: @then sortWith by 'Down' x@ 47 | -- 48 | -- @since 4.6.0.0 49 | newtype Down a = Down a 50 | deriving 51 | ( Eq 52 | , Show -- ^ @since 4.7.0.0 53 | , Read -- ^ @since 4.7.0.0 54 | , Num -- ^ @since 4.11.0.0 55 | , Semigroup -- ^ @since 4.11.0.0 56 | , Monoid -- ^ @since 4.11.0.0 57 | ) 58 | 59 | -- | @since 4.6.0.0 60 | instance Ord a => Ord (Down a) where 61 | compare (Down x) (Down y) = y `compare` x 62 | 63 | -- | @since 4.11.0.0 64 | instance Functor Down where 65 | fmap = coerce 66 | 67 | -- | @since 4.11.0.0 68 | instance Applicative Down where 69 | pure = Down 70 | (<*>) = coerce 71 | 72 | -- | @since 4.11.0.0 73 | instance Monad Down where 74 | Down a >>= k = k a 75 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Data/Ratio.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Safe #-} 2 | 3 | ----------------------------------------------------------------------------- 4 | -- | 5 | -- Module : Data.Ratio 6 | -- Copyright : (c) The University of Glasgow 2001 7 | -- License : BSD-style (see the file libraries/base/LICENSE) 8 | -- 9 | -- Maintainer : libraries@haskell.org 10 | -- Stability : stable 11 | -- Portability : portable 12 | -- 13 | -- Standard functions on rational numbers 14 | -- 15 | ----------------------------------------------------------------------------- 16 | 17 | module Data.Ratio 18 | ( Ratio 19 | , Rational 20 | , (%) 21 | , numerator 22 | , denominator 23 | , approxRational 24 | 25 | ) where 26 | 27 | import GHC.Real -- The basic defns for Ratio 28 | 29 | -- ----------------------------------------------------------------------------- 30 | -- approxRational 31 | 32 | -- | 'approxRational', applied to two real fractional numbers @x@ and @epsilon@, 33 | -- returns the simplest rational number within @epsilon@ of @x@. 34 | -- A rational number @y@ is said to be /simpler/ than another @y'@ if 35 | -- 36 | -- * @'abs' ('numerator' y) <= 'abs' ('numerator' y')@, and 37 | -- 38 | -- * @'denominator' y <= 'denominator' y'@. 39 | -- 40 | -- Any real interval contains a unique simplest rational; 41 | -- in particular, note that @0\/1@ is the simplest rational of all. 42 | 43 | -- Implementation details: Here, for simplicity, we assume a closed rational 44 | -- interval. If such an interval includes at least one whole number, then 45 | -- the simplest rational is the absolutely least whole number. Otherwise, 46 | -- the bounds are of the form q%1 + r%d and q%1 + r'%d', where abs r < d 47 | -- and abs r' < d', and the simplest rational is q%1 + the reciprocal of 48 | -- the simplest rational between d'%r' and d%r. 49 | 50 | approxRational :: (RealFrac a) => a -> a -> Rational 51 | approxRational rat eps = 52 | -- We convert rat and eps to rational *before* subtracting/adding since 53 | -- otherwise we may overflow. This was the cause of #14425. 54 | simplest (toRational rat - toRational eps) (toRational rat + toRational eps) 55 | where 56 | simplest x y 57 | | y < x = simplest y x 58 | | x == y = xr 59 | | x > 0 = simplest' n d n' d' 60 | | y < 0 = - simplest' (-n') d' (-n) d 61 | | otherwise = 0 :% 1 62 | where xr = toRational x 63 | n = numerator xr 64 | d = denominator xr 65 | nd' = toRational y 66 | n' = numerator nd' 67 | d' = denominator nd' 68 | 69 | simplest' n d n' d' -- assumes 0 < n%d < n'%d' 70 | | r == 0 = q :% 1 71 | | q /= q' = (q+1) :% 1 72 | | otherwise = (q*n''+d'') :% n'' 73 | where (q,r) = quotRem n d 74 | (q',r') = quotRem n' d' 75 | nd'' = simplest' d' r' d r 76 | n'' = numerator nd'' 77 | d'' = denominator nd'' 78 | 79 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Data/STRef.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Trustworthy #-} 2 | 3 | ----------------------------------------------------------------------------- 4 | -- | 5 | -- Module : Data.STRef 6 | -- Copyright : (c) The University of Glasgow 2001 7 | -- License : BSD-style (see the file libraries/base/LICENSE) 8 | -- 9 | -- Maintainer : libraries@haskell.org 10 | -- Stability : experimental 11 | -- Portability : non-portable (uses Control.Monad.ST) 12 | -- 13 | -- Mutable references in the (strict) ST monad. 14 | -- 15 | ----------------------------------------------------------------------------- 16 | 17 | module Data.STRef ( 18 | -- * STRefs 19 | STRef, -- abstract 20 | newSTRef, 21 | readSTRef, 22 | writeSTRef, 23 | modifySTRef, 24 | modifySTRef' 25 | ) where 26 | 27 | import GHC.ST 28 | import GHC.STRef 29 | 30 | -- | Mutate the contents of an 'STRef'. 31 | -- 32 | -- >>> :{ 33 | -- runST (do 34 | -- ref <- newSTRef "" 35 | -- modifySTRef ref (const "world") 36 | -- modifySTRef ref (++ "!") 37 | -- modifySTRef ref ("Hello, " ++) 38 | -- readSTRef ref ) 39 | -- :} 40 | -- "Hello, world!" 41 | -- 42 | -- Be warned that 'modifySTRef' does not apply the function strictly. This 43 | -- means if the program calls 'modifySTRef' many times, but seldomly uses the 44 | -- value, thunks will pile up in memory resulting in a space leak. This is a 45 | -- common mistake made when using an STRef as a counter. For example, the 46 | -- following will leak memory and may produce a stack overflow: 47 | -- 48 | -- >>> import Control.Monad (replicateM_) 49 | -- >>> :{ 50 | -- print (runST (do 51 | -- ref <- newSTRef 0 52 | -- replicateM_ 1000 $ modifySTRef ref (+1) 53 | -- readSTRef ref )) 54 | -- :} 55 | -- 1000 56 | -- 57 | -- To avoid this problem, use 'modifySTRef'' instead. 58 | modifySTRef :: STRef s a -> (a -> a) -> ST s () 59 | modifySTRef ref f = writeSTRef ref . f =<< readSTRef ref 60 | 61 | -- | Strict version of 'modifySTRef' 62 | -- 63 | -- @since 4.6.0.0 64 | modifySTRef' :: STRef s a -> (a -> a) -> ST s () 65 | modifySTRef' ref f = do 66 | x <- readSTRef ref 67 | let x' = f x 68 | x' `seq` writeSTRef ref x' 69 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Data/STRef/Lazy.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Safe #-} 2 | 3 | ----------------------------------------------------------------------------- 4 | -- | 5 | -- Module : Data.STRef.Lazy 6 | -- Copyright : (c) The University of Glasgow 2001 7 | -- License : BSD-style (see the file libraries/base/LICENSE) 8 | -- 9 | -- Maintainer : libraries@haskell.org 10 | -- Stability : experimental 11 | -- Portability : non-portable (uses Control.Monad.ST.Lazy) 12 | -- 13 | -- Mutable references in the lazy ST monad. 14 | -- 15 | ----------------------------------------------------------------------------- 16 | 17 | module Data.STRef.Lazy ( 18 | -- * STRefs 19 | ST.STRef, -- abstract 20 | newSTRef, 21 | readSTRef, 22 | writeSTRef, 23 | modifySTRef 24 | ) where 25 | 26 | import Control.Monad.ST.Lazy 27 | import qualified Data.STRef as ST 28 | 29 | newSTRef :: a -> ST s (ST.STRef s a) 30 | readSTRef :: ST.STRef s a -> ST s a 31 | writeSTRef :: ST.STRef s a -> a -> ST s () 32 | modifySTRef :: ST.STRef s a -> (a -> a) -> ST s () 33 | 34 | newSTRef = strictToLazyST . ST.newSTRef 35 | readSTRef = strictToLazyST . ST.readSTRef 36 | writeSTRef r a = strictToLazyST (ST.writeSTRef r a) 37 | modifySTRef r f = strictToLazyST (ST.modifySTRef r f) 38 | 39 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Data/STRef/Strict.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Safe #-} 2 | 3 | ----------------------------------------------------------------------------- 4 | -- | 5 | -- Module : Data.STRef.Strict 6 | -- Copyright : (c) The University of Glasgow 2001 7 | -- License : BSD-style (see the file libraries/base/LICENSE) 8 | -- 9 | -- Maintainer : libraries@haskell.org 10 | -- Stability : provisional 11 | -- Portability : non-portable (uses Control.Monad.ST.Strict) 12 | -- 13 | -- Mutable references in the (strict) ST monad (re-export of "Data.STRef") 14 | -- 15 | ----------------------------------------------------------------------------- 16 | 17 | module Data.STRef.Strict ( 18 | module Data.STRef 19 | ) where 20 | 21 | import Data.STRef 22 | 23 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Data/Semigroup/Internal.hs-boot: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE NoImplicitPrelude #-} 2 | 3 | module Data.Semigroup.Internal where 4 | 5 | import {-# SOURCE #-} GHC.Real (Integral) 6 | import {-# SOURCE #-} GHC.Base (Semigroup,Monoid,Maybe) 7 | 8 | stimesIdempotentMonoid :: (Integral b, Monoid a) => b -> a -> a 9 | 10 | stimesDefault :: (Integral b, Semigroup a) => b -> a -> a 11 | stimesMaybe :: (Integral b, Semigroup a) => b -> Maybe a -> Maybe a 12 | stimesList :: Integral b => b -> [a] -> [a] 13 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Data/Tuple.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Trustworthy #-} 2 | {-# LANGUAGE NoImplicitPrelude #-} 3 | 4 | ----------------------------------------------------------------------------- 5 | -- | 6 | -- Module : Data.Tuple 7 | -- Copyright : (c) The University of Glasgow 2001 8 | -- License : BSD-style (see the file libraries/base/LICENSE) 9 | -- 10 | -- Maintainer : libraries@haskell.org 11 | -- Stability : experimental 12 | -- Portability : portable 13 | -- 14 | -- Functions associated with the tuple data types. 15 | -- 16 | ----------------------------------------------------------------------------- 17 | 18 | module Data.Tuple 19 | ( fst 20 | , snd 21 | , curry 22 | , uncurry 23 | , swap 24 | ) where 25 | 26 | import GHC.Base () -- Note [Depend on GHC.Tuple] 27 | 28 | default () -- Double isn't available yet 29 | 30 | -- --------------------------------------------------------------------------- 31 | -- Standard functions over tuples 32 | 33 | -- | Extract the first component of a pair. 34 | fst :: (a,b) -> a 35 | fst (x,_) = x 36 | 37 | -- | Extract the second component of a pair. 38 | snd :: (a,b) -> b 39 | snd (_,y) = y 40 | 41 | -- | 'curry' converts an uncurried function to a curried function. 42 | -- 43 | -- ==== __Examples__ 44 | -- 45 | -- >>> curry fst 1 2 46 | -- 1 47 | curry :: ((a, b) -> c) -> a -> b -> c 48 | curry f x y = f (x, y) 49 | 50 | -- | 'uncurry' converts a curried function to a function on pairs. 51 | -- 52 | -- ==== __Examples__ 53 | -- 54 | -- >>> uncurry (+) (1,2) 55 | -- 3 56 | -- 57 | -- >>> uncurry ($) (show, 1) 58 | -- "1" 59 | -- 60 | -- >>> map (uncurry max) [(1,2), (3,4), (6,8)] 61 | -- [2,4,8] 62 | uncurry :: (a -> b -> c) -> ((a, b) -> c) 63 | uncurry f p = f (fst p) (snd p) 64 | 65 | -- | Swap the components of a pair. 66 | swap :: (a,b) -> (b,a) 67 | swap (a,b) = (b,a) 68 | 69 | -- $setup 70 | -- >>> import Prelude hiding (curry, uncurry, fst, snd) 71 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Data/Type/Bool.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TypeFamilyDependencies, Safe, PolyKinds #-} 2 | {-# LANGUAGE TypeFamilies, TypeOperators, DataKinds, NoImplicitPrelude #-} 3 | 4 | ----------------------------------------------------------------------------- 5 | -- | 6 | -- Module : Data.Type.Bool 7 | -- License : BSD-style (see the LICENSE file in the distribution) 8 | -- 9 | -- Maintainer : libraries@haskell.org 10 | -- Stability : experimental 11 | -- Portability : not portable 12 | -- 13 | -- Basic operations on type-level Booleans. 14 | -- 15 | -- @since 4.7.0.0 16 | ----------------------------------------------------------------------------- 17 | 18 | module Data.Type.Bool ( 19 | If, type (&&), type (||), Not 20 | ) where 21 | 22 | import Data.Bool 23 | 24 | -- This needs to be in base because (&&) is used in Data.Type.Equality. 25 | -- The other functions do not need to be in base, but seemed to be appropriate 26 | -- here. 27 | 28 | -- | Type-level "If". @If True a b@ ==> @a@; @If False a b@ ==> @b@ 29 | type family If cond tru fls where 30 | If 'True tru fls = tru 31 | If 'False tru fls = fls 32 | 33 | -- | Type-level "and" 34 | type family a && b where 35 | 'False && a = 'False 36 | 'True && a = a 37 | a && 'False = 'False 38 | a && 'True = a 39 | a && a = a 40 | infixr 3 && 41 | 42 | -- | Type-level "or" 43 | type family a || b where 44 | 'False || a = a 45 | 'True || a = 'True 46 | a || 'False = a 47 | a || 'True = 'True 48 | a || a = a 49 | infixr 2 || 50 | 51 | -- | Type-level "not". An injective type family since @4.10.0.0@. 52 | -- 53 | -- @since 4.7.0.0 54 | type family Not a = res | res -> a where 55 | Not 'False = 'True 56 | Not 'True = 'False 57 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Data/Unique.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Trustworthy #-} 2 | {-# LANGUAGE MagicHash #-} 3 | 4 | ----------------------------------------------------------------------------- 5 | -- | 6 | -- Module : Data.Unique 7 | -- Copyright : (c) The University of Glasgow 2001 8 | -- License : BSD-style (see the file libraries/base/LICENSE) 9 | -- 10 | -- Maintainer : libraries@haskell.org 11 | -- Stability : experimental 12 | -- Portability : non-portable 13 | -- 14 | -- An abstract interface to a unique symbol generator. 15 | -- 16 | ----------------------------------------------------------------------------- 17 | 18 | module Data.Unique ( 19 | -- * Unique objects 20 | Unique, 21 | newUnique, 22 | hashUnique 23 | ) where 24 | 25 | import System.IO.Unsafe (unsafePerformIO) 26 | 27 | import GHC.Base 28 | import GHC.Num 29 | import Data.IORef 30 | 31 | -- | An abstract unique object. Objects of type 'Unique' may be 32 | -- compared for equality and ordering and hashed into 'Int'. 33 | -- 34 | -- >>> :{ 35 | -- do x <- newUnique 36 | -- print (x == x) 37 | -- y <- newUnique 38 | -- print (x == y) 39 | -- :} 40 | -- True 41 | -- False 42 | newtype Unique = Unique Integer deriving (Eq,Ord) 43 | 44 | uniqSource :: IORef Integer 45 | uniqSource = unsafePerformIO (newIORef 0) 46 | {-# NOINLINE uniqSource #-} 47 | 48 | -- | Creates a new object of type 'Unique'. The value returned will 49 | -- not compare equal to any other value of type 'Unique' returned by 50 | -- previous calls to 'newUnique'. There is no limit on the number of 51 | -- times 'newUnique' may be called. 52 | newUnique :: IO Unique 53 | newUnique = do 54 | r <- atomicModifyIORef' uniqSource $ \x -> let z = x+1 in (z,z) 55 | return (Unique r) 56 | 57 | -- SDM (18/3/2010): changed from MVar to STM. This fixes 58 | -- 1. there was no async exception protection 59 | -- 2. there was a space leak (now new value is strict) 60 | -- 3. using atomicModifyIORef would be slightly quicker, but can 61 | -- suffer from adverse scheduling issues (see #3838) 62 | -- 4. also, the STM version is faster. 63 | 64 | -- SDM (30/4/2012): changed to IORef using atomicModifyIORef. Reasons: 65 | -- 1. STM version could not be used inside unsafePerformIO, if it 66 | -- happened to be poked inside an STM transaction. 67 | -- 2. IORef version can be used with unsafeIOToSTM inside STM, 68 | -- because if the transaction retries then we just get a new 69 | -- Unique. 70 | -- 3. IORef version is very slightly faster. 71 | 72 | -- IGL (08/06/2013): changed to using atomicModifyIORef' instead. 73 | -- This feels a little safer, from the point of view of not leaking 74 | -- memory, but the resulting core is identical. 75 | 76 | -- | Hashes a 'Unique' into an 'Int'. Two 'Unique's may hash to the 77 | -- same value, although in practice this is unlikely. The 'Int' 78 | -- returned makes a good hash key. 79 | hashUnique :: Unique -> Int 80 | hashUnique (Unique i) = I# (hashInteger i) 81 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Data/Void.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE DeriveDataTypeable #-} 2 | {-# LANGUAGE DeriveGeneric #-} 3 | {-# LANGUAGE EmptyCase #-} 4 | {-# LANGUAGE EmptyDataDeriving #-} 5 | {-# LANGUAGE Safe #-} 6 | {-# LANGUAGE StandaloneDeriving #-} 7 | 8 | ----------------------------------------------------------------------------- 9 | -- | 10 | -- Copyright : (C) 2008-2014 Edward Kmett 11 | -- License : BSD-style (see the file libraries/base/LICENSE) 12 | -- 13 | -- Maintainer : Edward Kmett 14 | -- Stability : provisional 15 | -- Portability : portable 16 | -- 17 | -- A logically uninhabited data type, used to indicate that a given 18 | -- term should not exist. 19 | -- 20 | -- @since 4.8.0.0 21 | ---------------------------------------------------------------------------- 22 | module Data.Void 23 | ( Void 24 | , absurd 25 | , vacuous 26 | ) where 27 | 28 | import Control.Exception 29 | import Data.Data 30 | import Data.Ix 31 | import GHC.Generics 32 | import Data.Semigroup (Semigroup(..), stimesIdempotent) 33 | 34 | -- | Uninhabited data type 35 | -- 36 | -- @since 4.8.0.0 37 | data Void deriving 38 | ( Eq -- ^ @since 4.8.0.0 39 | , Data -- ^ @since 4.8.0.0 40 | , Generic -- ^ @since 4.8.0.0 41 | , Ord -- ^ @since 4.8.0.0 42 | , Read -- ^ Reading a 'Void' value is always a parse error, considering 43 | -- 'Void' as a data type with no constructors. 44 | -- 45 | -- @since 4.8.0.0 46 | , Show -- ^ @since 4.8.0.0 47 | ) 48 | 49 | -- | @since 4.8.0.0 50 | instance Ix Void where 51 | range _ = [] 52 | index _ = absurd 53 | inRange _ = absurd 54 | rangeSize _ = 0 55 | 56 | -- | @since 4.8.0.0 57 | instance Exception Void 58 | 59 | -- | @since 4.9.0.0 60 | instance Semigroup Void where 61 | a <> _ = a 62 | stimes = stimesIdempotent 63 | 64 | -- | Since 'Void' values logically don't exist, this witnesses the 65 | -- logical reasoning tool of \"ex falso quodlibet\". 66 | -- 67 | -- >>> let x :: Either Void Int; x = Right 5 68 | -- >>> :{ 69 | -- case x of 70 | -- Right r -> r 71 | -- Left l -> absurd l 72 | -- :} 73 | -- 5 74 | -- 75 | -- @since 4.8.0.0 76 | absurd :: Void -> a 77 | absurd a = case a of {} 78 | 79 | -- | If 'Void' is uninhabited then any 'Functor' that holds only 80 | -- values of type 'Void' is holding no values. 81 | -- 82 | -- @since 4.8.0.0 83 | vacuous :: Functor f => f Void -> f a 84 | vacuous = fmap absurd 85 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Data/Word.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Safe #-} 2 | {-# LANGUAGE NoImplicitPrelude #-} 3 | 4 | ----------------------------------------------------------------------------- 5 | -- | 6 | -- Module : Data.Word 7 | -- Copyright : (c) The University of Glasgow 2001 8 | -- License : BSD-style (see the file libraries/base/LICENSE) 9 | -- 10 | -- Maintainer : libraries@haskell.org 11 | -- Stability : experimental 12 | -- Portability : portable 13 | -- 14 | -- Unsigned integer types. 15 | -- 16 | ----------------------------------------------------------------------------- 17 | 18 | module Data.Word 19 | ( 20 | -- * Unsigned integral types 21 | 22 | Word, 23 | Word8, Word16, Word32, Word64, 24 | 25 | -- * byte swapping 26 | byteSwap16, byteSwap32, byteSwap64, 27 | 28 | -- * Notes 29 | 30 | -- $notes 31 | ) where 32 | 33 | import GHC.Word 34 | import GHC.Read () -- Need the `Read` instance for types defined in `GHC.Word`. 35 | 36 | {- $notes 37 | 38 | * All arithmetic is performed modulo 2^n, where n is the number of 39 | bits in the type. One non-obvious consequence of this is that 'Prelude.negate' 40 | should /not/ raise an error on negative arguments. 41 | 42 | * For coercing between any two integer types, use 43 | 'Prelude.fromIntegral', which is specialized for all the 44 | common cases so should be fast enough. Coercing word types to and 45 | from integer types preserves representation, not sign. 46 | 47 | * An unbounded size unsigned integer type is available with 48 | 'Numeric.Natural.Natural'. 49 | 50 | * The rules that hold for 'Prelude.Enum' instances over a bounded type 51 | such as 'Prelude.Int' (see the section of the Haskell report dealing 52 | with arithmetic sequences) also hold for the 'Prelude.Enum' instances 53 | over the various 'Word' types defined here. 54 | 55 | * Right and left shifts by amounts greater than or equal to the width 56 | of the type result in a zero result. This is contrary to the 57 | behaviour in C, which is undefined; a common interpretation is to 58 | truncate the shift count to the width of the type, for example @1 \<\< 59 | 32 == 1@ in some C implementations. 60 | -} 61 | 62 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Debug/Trace.hs-boot: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Unsafe #-} 2 | {-# LANGUAGE MagicHash #-} 3 | {-# LANGUAGE NoImplicitPrelude #-} 4 | {-# LANGUAGE UnboxedTuples #-} 5 | 6 | -- This boot file is necessary to allow GHC developers to 7 | -- use trace facilities in those (relatively few) modules that Debug.Trace 8 | -- itself depends on. It is also necessary to make DsMonad.pprRuntimeTrace 9 | -- trace injections work in those modules. 10 | 11 | ----------------------------------------------------------------------------- 12 | -- | 13 | -- Module : Debug.Trace 14 | -- Copyright : (c) The University of Glasgow 2001 15 | -- License : BSD-style (see the file libraries/base/LICENSE) 16 | -- 17 | -- Maintainer : libraries@haskell.org 18 | -- Stability : provisional 19 | -- Portability : portable 20 | -- 21 | -- Functions for tracing and monitoring execution. 22 | -- 23 | -- These can be useful for investigating bugs or performance problems. 24 | -- They should /not/ be used in production code. 25 | -- 26 | ----------------------------------------------------------------------------- 27 | 28 | module Debug.Trace ( 29 | -- * Tracing 30 | -- $tracing 31 | trace, 32 | traceId, 33 | traceShow, 34 | traceShowId, 35 | traceStack, 36 | traceIO, 37 | traceM, 38 | traceShowM, 39 | 40 | -- * Eventlog tracing 41 | -- $eventlog_tracing 42 | traceEvent, 43 | traceEventIO, 44 | 45 | -- * Execution phase markers 46 | -- $markers 47 | traceMarker, 48 | traceMarkerIO, 49 | ) where 50 | 51 | import GHC.Base 52 | import GHC.Show 53 | 54 | traceIO :: String -> IO () 55 | 56 | trace :: String -> a -> a 57 | 58 | traceId :: String -> String 59 | 60 | traceShow :: Show a => a -> b -> b 61 | 62 | traceShowId :: Show a => a -> a 63 | 64 | traceM :: Applicative f => String -> f () 65 | 66 | traceShowM :: (Show a, Applicative f) => a -> f () 67 | 68 | traceStack :: String -> a -> a 69 | 70 | traceEvent :: String -> a -> a 71 | 72 | traceEventIO :: String -> IO () 73 | 74 | traceMarker :: String -> a -> a 75 | 76 | traceMarkerIO :: String -> IO () 77 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Foreign.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Safe #-} 2 | {-# LANGUAGE NoImplicitPrelude #-} 3 | 4 | ----------------------------------------------------------------------------- 5 | -- | 6 | -- Module : Foreign 7 | -- Copyright : (c) The FFI task force 2001 8 | -- License : BSD-style (see the file libraries/base/LICENSE) 9 | -- 10 | -- Maintainer : ffi@haskell.org 11 | -- Stability : provisional 12 | -- Portability : portable 13 | -- 14 | -- A collection of data types, classes, and functions for interfacing 15 | -- with another programming language. 16 | -- 17 | ----------------------------------------------------------------------------- 18 | 19 | module Foreign 20 | ( module Data.Bits 21 | , module Data.Int 22 | , module Data.Word 23 | , module Foreign.Ptr 24 | , module Foreign.ForeignPtr 25 | , module Foreign.StablePtr 26 | , module Foreign.Storable 27 | , module Foreign.Marshal 28 | ) where 29 | 30 | import Data.Bits 31 | import Data.Int 32 | import Data.Word 33 | import Foreign.Ptr 34 | import Foreign.ForeignPtr 35 | import Foreign.StablePtr 36 | import Foreign.Storable 37 | import Foreign.Marshal 38 | 39 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Foreign/C.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Safe #-} 2 | {-# LANGUAGE NoImplicitPrelude #-} 3 | 4 | ----------------------------------------------------------------------------- 5 | -- | 6 | -- Module : Foreign.C 7 | -- Copyright : (c) The FFI task force 2001 8 | -- License : BSD-style (see the file libraries/base/LICENSE) 9 | -- 10 | -- Maintainer : ffi@haskell.org 11 | -- Stability : provisional 12 | -- Portability : portable 13 | -- 14 | -- Bundles the C specific FFI library functionality 15 | -- 16 | ----------------------------------------------------------------------------- 17 | 18 | module Foreign.C 19 | ( module Foreign.C.Types 20 | , module Foreign.C.String 21 | , module Foreign.C.Error 22 | ) where 23 | 24 | import Foreign.C.Types 25 | import Foreign.C.String 26 | import Foreign.C.Error 27 | 28 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Foreign/ForeignPtr.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Trustworthy #-} 2 | {-# LANGUAGE NoImplicitPrelude #-} 3 | 4 | ----------------------------------------------------------------------------- 5 | -- | 6 | -- Module : Foreign.ForeignPtr 7 | -- Copyright : (c) The University of Glasgow 2001 8 | -- License : BSD-style (see the file libraries/base/LICENSE) 9 | -- 10 | -- Maintainer : ffi@haskell.org 11 | -- Stability : provisional 12 | -- Portability : portable 13 | -- 14 | -- The 'ForeignPtr' type and operations. This module is part of the 15 | -- Foreign Function Interface (FFI) and will usually be imported via 16 | -- the "Foreign" module. 17 | -- 18 | -- For non-portable support of Haskell finalizers, see the 19 | -- "Foreign.Concurrent" module. 20 | -- 21 | ----------------------------------------------------------------------------- 22 | 23 | module Foreign.ForeignPtr ( 24 | -- * Finalised data pointers 25 | ForeignPtr 26 | , FinalizerPtr 27 | , FinalizerEnvPtr 28 | 29 | -- ** Basic operations 30 | , newForeignPtr 31 | , newForeignPtr_ 32 | , addForeignPtrFinalizer 33 | , newForeignPtrEnv 34 | , addForeignPtrFinalizerEnv 35 | , withForeignPtr 36 | , finalizeForeignPtr 37 | 38 | -- ** Low-level operations 39 | , touchForeignPtr 40 | , castForeignPtr 41 | , plusForeignPtr 42 | 43 | -- ** Allocating managed memory 44 | , mallocForeignPtr 45 | , mallocForeignPtrBytes 46 | , mallocForeignPtrArray 47 | , mallocForeignPtrArray0 48 | ) where 49 | 50 | import Foreign.ForeignPtr.Imp 51 | 52 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Foreign/ForeignPtr/Safe.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Trustworthy #-} 2 | {-# LANGUAGE NoImplicitPrelude #-} 3 | 4 | ----------------------------------------------------------------------------- 5 | -- | 6 | -- Module : Foreign.ForeignPtr.Safe 7 | -- Copyright : (c) The University of Glasgow 2001 8 | -- License : BSD-style (see the file libraries/base/LICENSE) 9 | -- 10 | -- Maintainer : ffi@haskell.org 11 | -- Stability : provisional 12 | -- Portability : portable 13 | -- 14 | -- The 'ForeignPtr' type and operations. This module is part of the 15 | -- Foreign Function Interface (FFI) and will usually be imported via 16 | -- the "Foreign" module. 17 | -- 18 | -- Safe API Only. 19 | -- 20 | ----------------------------------------------------------------------------- 21 | 22 | module Foreign.ForeignPtr.Safe {-# DEPRECATED "Safe is now the default, please use Foreign.ForeignPtr instead" #-} ( 23 | -- * Finalised data pointers 24 | ForeignPtr 25 | , FinalizerPtr 26 | , FinalizerEnvPtr 27 | 28 | -- ** Basic operations 29 | , newForeignPtr 30 | , newForeignPtr_ 31 | , addForeignPtrFinalizer 32 | , newForeignPtrEnv 33 | , addForeignPtrFinalizerEnv 34 | , withForeignPtr 35 | , finalizeForeignPtr 36 | 37 | -- ** Low-level operations 38 | , touchForeignPtr 39 | , castForeignPtr 40 | 41 | -- ** Allocating managed memory 42 | , mallocForeignPtr 43 | , mallocForeignPtrBytes 44 | , mallocForeignPtrArray 45 | , mallocForeignPtrArray0 46 | ) where 47 | 48 | import Foreign.ForeignPtr.Imp 49 | 50 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Foreign/ForeignPtr/Unsafe.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Unsafe #-} 2 | {-# LANGUAGE NoImplicitPrelude #-} 3 | 4 | ----------------------------------------------------------------------------- 5 | -- | 6 | -- Module : Foreign.ForeignPtr.Unsafe 7 | -- Copyright : (c) The University of Glasgow 2001 8 | -- License : BSD-style (see the file libraries/base/LICENSE) 9 | -- 10 | -- Maintainer : ffi@haskell.org 11 | -- Stability : provisional 12 | -- Portability : portable 13 | -- 14 | -- The 'ForeignPtr' type and operations. This module is part of the 15 | -- Foreign Function Interface (FFI) and will usually be imported via 16 | -- the "Foreign" module. 17 | -- 18 | -- Unsafe API Only. 19 | -- 20 | ----------------------------------------------------------------------------- 21 | 22 | module Foreign.ForeignPtr.Unsafe ( 23 | -- ** Unsafe low-level operations 24 | unsafeForeignPtrToPtr, 25 | ) where 26 | 27 | import Foreign.ForeignPtr.Imp 28 | 29 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Foreign/Marshal.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Safe #-} 2 | {-# LANGUAGE NoImplicitPrelude #-} 3 | 4 | ----------------------------------------------------------------------------- 5 | -- | 6 | -- Module : Foreign.Marshal 7 | -- Copyright : (c) The FFI task force 2003 8 | -- License : BSD-style (see the file libraries/base/LICENSE) 9 | -- 10 | -- Maintainer : ffi@haskell.org 11 | -- Stability : provisional 12 | -- Portability : portable 13 | -- 14 | -- Marshalling support 15 | -- 16 | ----------------------------------------------------------------------------- 17 | 18 | module Foreign.Marshal 19 | ( 20 | -- | The module "Foreign.Marshal.Safe" re-exports the other modules in the 21 | -- @Foreign.Marshal@ hierarchy (except for @Foreign.Marshal.Unsafe@): 22 | module Foreign.Marshal.Alloc 23 | , module Foreign.Marshal.Array 24 | , module Foreign.Marshal.Error 25 | , module Foreign.Marshal.Pool 26 | , module Foreign.Marshal.Utils 27 | ) where 28 | 29 | import Foreign.Marshal.Alloc 30 | import Foreign.Marshal.Array 31 | import Foreign.Marshal.Error 32 | import Foreign.Marshal.Pool 33 | import Foreign.Marshal.Utils 34 | 35 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Foreign/Marshal/Error.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Trustworthy #-} 2 | {-# LANGUAGE CPP, NoImplicitPrelude #-} 3 | 4 | ----------------------------------------------------------------------------- 5 | -- | 6 | -- Module : Foreign.Marshal.Error 7 | -- Copyright : (c) The FFI task force 2001 8 | -- License : BSD-style (see the file libraries/base/LICENSE) 9 | -- 10 | -- Maintainer : ffi@haskell.org 11 | -- Stability : provisional 12 | -- Portability : portable 13 | -- 14 | -- Routines for testing return values and raising a 'userError' exception 15 | -- in case of values indicating an error state. 16 | -- 17 | ----------------------------------------------------------------------------- 18 | 19 | module Foreign.Marshal.Error ( 20 | throwIf, 21 | throwIf_, 22 | throwIfNeg, 23 | throwIfNeg_, 24 | throwIfNull, 25 | 26 | -- Discard return value 27 | -- 28 | void 29 | ) where 30 | 31 | import Foreign.Ptr 32 | 33 | import GHC.Base 34 | import GHC.Num 35 | import GHC.IO.Exception 36 | 37 | -- exported functions 38 | -- ------------------ 39 | 40 | -- |Execute an 'IO' action, throwing a 'userError' if the predicate yields 41 | -- 'True' when applied to the result returned by the 'IO' action. 42 | -- If no exception is raised, return the result of the computation. 43 | -- 44 | throwIf :: (a -> Bool) -- ^ error condition on the result of the 'IO' action 45 | -> (a -> String) -- ^ computes an error message from erroneous results 46 | -- of the 'IO' action 47 | -> IO a -- ^ the 'IO' action to be executed 48 | -> IO a 49 | throwIf pred msgfct act = 50 | do 51 | res <- act 52 | (if pred res then ioError . userError . msgfct else return) res 53 | 54 | -- |Like 'throwIf', but discarding the result 55 | -- 56 | throwIf_ :: (a -> Bool) -> (a -> String) -> IO a -> IO () 57 | throwIf_ pred msgfct act = void $ throwIf pred msgfct act 58 | 59 | -- |Guards against negative result values 60 | -- 61 | throwIfNeg :: (Ord a, Num a) => (a -> String) -> IO a -> IO a 62 | throwIfNeg = throwIf (< 0) 63 | 64 | -- |Like 'throwIfNeg', but discarding the result 65 | -- 66 | throwIfNeg_ :: (Ord a, Num a) => (a -> String) -> IO a -> IO () 67 | throwIfNeg_ = throwIf_ (< 0) 68 | 69 | -- |Guards against null pointers 70 | -- 71 | throwIfNull :: String -> IO (Ptr a) -> IO (Ptr a) 72 | throwIfNull = throwIf (== nullPtr) . const 73 | 74 | -- |Discard the return value of an 'IO' action 75 | -- 76 | void :: IO a -> IO () 77 | void act = act >> return () 78 | {-# DEPRECATED void "use 'Control.Monad.void' instead" #-} -- deprecated in 7.6 79 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Foreign/Marshal/Safe.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Safe #-} 2 | {-# LANGUAGE NoImplicitPrelude #-} 3 | 4 | ----------------------------------------------------------------------------- 5 | -- | 6 | -- Module : Foreign.Marshal.Safe 7 | -- Copyright : (c) The FFI task force 2003 8 | -- License : BSD-style (see the file libraries/base/LICENSE) 9 | -- 10 | -- Maintainer : ffi@haskell.org 11 | -- Stability : provisional 12 | -- Portability : portable 13 | -- 14 | -- Marshalling support 15 | -- 16 | -- Safe API Only. 17 | -- 18 | ----------------------------------------------------------------------------- 19 | 20 | module Foreign.Marshal.Safe {-# DEPRECATED "Safe is now the default, please use Foreign.Marshal instead" #-} 21 | ( 22 | -- | The module "Foreign.Marshal.Safe" re-exports the other modules in the 23 | -- @Foreign.Marshal@ hierarchy: 24 | module Foreign.Marshal.Alloc 25 | , module Foreign.Marshal.Array 26 | , module Foreign.Marshal.Error 27 | , module Foreign.Marshal.Pool 28 | , module Foreign.Marshal.Utils 29 | ) where 30 | 31 | import Foreign.Marshal.Alloc 32 | import Foreign.Marshal.Array 33 | import Foreign.Marshal.Error 34 | import Foreign.Marshal.Pool 35 | import Foreign.Marshal.Utils 36 | 37 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Foreign/Marshal/Unsafe.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Unsafe #-} 2 | {-# LANGUAGE NoImplicitPrelude #-} 3 | 4 | ----------------------------------------------------------------------------- 5 | -- | 6 | -- Module : Foreign.Marshal.Unsafe 7 | -- Copyright : (c) The FFI task force 2003 8 | -- License : BSD-style (see the file libraries/base/LICENSE) 9 | -- 10 | -- Maintainer : ffi@haskell.org 11 | -- Stability : provisional 12 | -- Portability : portable 13 | -- 14 | -- Marshalling support. Unsafe API. 15 | -- 16 | ----------------------------------------------------------------------------- 17 | 18 | module Foreign.Marshal.Unsafe ( 19 | -- * Unsafe functions 20 | unsafeLocalState 21 | ) where 22 | 23 | import GHC.IO 24 | 25 | {- | 26 | Sometimes an external entity is a pure function, except that it passes 27 | arguments and/or results via pointers. The function 28 | @unsafeLocalState@ permits the packaging of such entities as pure 29 | functions. 30 | 31 | The only IO operations allowed in the IO action passed to 32 | @unsafeLocalState@ are (a) local allocation (@alloca@, @allocaBytes@ 33 | and derived operations such as @withArray@ and @withCString@), and (b) 34 | pointer operations (@Foreign.Storable@ and @Foreign.Ptr@) on the 35 | pointers to local storage, and (c) foreign functions whose only 36 | observable effect is to read and/or write the locally allocated 37 | memory. Passing an IO operation that does not obey these rules 38 | results in undefined behaviour. 39 | 40 | It is expected that this operation will be 41 | replaced in a future revision of Haskell. 42 | -} 43 | unsafeLocalState :: IO a -> a 44 | unsafeLocalState = unsafeDupablePerformIO 45 | 46 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Foreign/Safe.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Safe #-} 2 | {-# LANGUAGE NoImplicitPrelude #-} 3 | 4 | ----------------------------------------------------------------------------- 5 | -- | 6 | -- Module : Foreign.Safe 7 | -- Copyright : (c) The FFI task force 2001 8 | -- License : BSD-style (see the file libraries/base/LICENSE) 9 | -- 10 | -- Maintainer : ffi@haskell.org 11 | -- Stability : provisional 12 | -- Portability : portable 13 | -- 14 | -- A collection of data types, classes, and functions for interfacing 15 | -- with another programming language. 16 | -- 17 | -- Safe API Only. 18 | -- 19 | ----------------------------------------------------------------------------- 20 | 21 | module Foreign.Safe {-# DEPRECATED "Safe is now the default, please use Foreign instead" #-} 22 | ( module Data.Bits 23 | , module Data.Int 24 | , module Data.Word 25 | , module Foreign.Ptr 26 | , module Foreign.ForeignPtr 27 | , module Foreign.StablePtr 28 | , module Foreign.Storable 29 | , module Foreign.Marshal 30 | ) where 31 | 32 | import Data.Bits 33 | import Data.Int 34 | import Data.Word 35 | import Foreign.Ptr 36 | import Foreign.ForeignPtr 37 | import Foreign.StablePtr 38 | import Foreign.Storable 39 | import Foreign.Marshal 40 | 41 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Foreign/StablePtr.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Trustworthy #-} 2 | {-# LANGUAGE NoImplicitPrelude #-} 3 | 4 | ----------------------------------------------------------------------------- 5 | -- | 6 | -- Module : Foreign.StablePtr 7 | -- Copyright : (c) The University of Glasgow 2001 8 | -- License : BSD-style (see the file libraries/base/LICENSE) 9 | -- 10 | -- Maintainer : ffi@haskell.org 11 | -- Stability : provisional 12 | -- Portability : portable 13 | -- 14 | -- This module is part of the Foreign Function Interface (FFI) and will usually 15 | -- be imported via the module "Foreign". 16 | -- 17 | ----------------------------------------------------------------------------- 18 | 19 | 20 | module Foreign.StablePtr 21 | ( -- * Stable references to Haskell values 22 | StablePtr -- abstract 23 | , newStablePtr 24 | , deRefStablePtr 25 | , freeStablePtr 26 | , castStablePtrToPtr 27 | , castPtrToStablePtr 28 | , -- ** The C-side interface 29 | 30 | -- $cinterface 31 | ) where 32 | 33 | import GHC.Stable 34 | 35 | -- $cinterface 36 | -- 37 | -- The following definition is available to C programs inter-operating with 38 | -- Haskell code when including the header @HsFFI.h@. 39 | -- 40 | -- > typedef void *HsStablePtr; /* C representation of a StablePtr */ 41 | -- 42 | -- Note that no assumptions may be made about the values representing stable 43 | -- pointers. In fact, they need not even be valid memory addresses. The only 44 | -- guarantee provided is that if they are passed back to Haskell land, the 45 | -- function 'deRefStablePtr' will be able to reconstruct the 46 | -- Haskell value referred to by the stable pointer. 47 | 48 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/GHC/Base.hs-boot: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE NoImplicitPrelude #-} 2 | 3 | module GHC.Base where 4 | 5 | import GHC.Types () 6 | 7 | class Semigroup a 8 | class Monoid a 9 | 10 | data Maybe a = Nothing | Just a 11 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/GHC/ByteOrder.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE CPP #-} 2 | 3 | ----------------------------------------------------------------------------- 4 | -- | 5 | -- Module : GHC.ByteOrder 6 | -- Copyright : (c) The University of Glasgow, 1994-2000 7 | -- License : see libraries/base/LICENSE 8 | -- 9 | -- Maintainer : cvs-ghc@haskell.org 10 | -- Stability : internal 11 | -- Portability : non-portable (GHC extensions) 12 | -- 13 | -- Target byte ordering. 14 | -- 15 | ----------------------------------------------------------------------------- 16 | 17 | module GHC.ByteOrder where 18 | 19 | -- | Byte ordering. 20 | data ByteOrder 21 | = BigEndian -- ^ most-significant-byte occurs in lowest address. 22 | | LittleEndian -- ^ least-significant-byte occurs in lowest address. 23 | deriving (Eq, Ord, Bounded, Enum, Read, Show) 24 | 25 | -- | The byte ordering of the target machine. 26 | targetByteOrder :: ByteOrder 27 | #if defined(WORDS_BIGENDIAN) 28 | targetByteOrder = BigEndian 29 | #else 30 | targetByteOrder = LittleEndian 31 | #endif 32 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/GHC/Char.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Trustworthy #-} 2 | {-# LANGUAGE NoImplicitPrelude, MagicHash #-} 3 | 4 | module GHC.Char 5 | ( -- * Utilities 6 | chr 7 | 8 | -- * Monomorphic equality operators 9 | -- | See GHC.Classes#matching_overloaded_methods_in_rules 10 | , eqChar, neChar 11 | ) where 12 | 13 | import GHC.Base 14 | import GHC.Show 15 | 16 | -- | The 'Prelude.toEnum' method restricted to the type 'Data.Char.Char'. 17 | chr :: Int -> Char 18 | chr i@(I# i#) 19 | | isTrue# (int2Word# i# `leWord#` 0x10FFFF##) = C# (chr# i#) 20 | | otherwise 21 | = errorWithoutStackTrace ("Prelude.chr: bad argument: " ++ showSignedInt (I# 9#) i "") 22 | 23 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/GHC/Clock.hsc: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Trustworthy #-} 2 | {-# LANGUAGE NoImplicitPrelude #-} 3 | 4 | module GHC.Clock 5 | ( getMonotonicTime 6 | , getMonotonicTimeNSec 7 | ) where 8 | 9 | import GHC.Base 10 | import GHC.Real 11 | import Data.Word 12 | 13 | -- | Return monotonic time in seconds, since some unspecified starting point 14 | -- 15 | -- @since 4.11.0.0 16 | getMonotonicTime :: IO Double 17 | getMonotonicTime = do w <- getMonotonicTimeNSec 18 | return (fromIntegral w / 1000000000) 19 | 20 | -- | Return monotonic time in nanoseconds, since some unspecified starting point 21 | -- 22 | -- @since 4.11.0.0 23 | foreign import ccall unsafe "getMonotonicNSec" 24 | getMonotonicTimeNSec :: IO Word64 25 | 26 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/GHC/Constants.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Trustworthy #-} 2 | {-# LANGUAGE NoImplicitPrelude #-} 3 | 4 | module GHC.Constants where 5 | 6 | -- TODO: This used to include HaskellConstants.hs, but that has now gone. 7 | -- We probably want to include the constants in platformConstants somehow 8 | -- instead. 9 | 10 | import GHC.Base () -- dummy dependency 11 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/GHC/Desugar.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Trustworthy #-} 2 | {-# LANGUAGE NoImplicitPrelude 3 | , RankNTypes 4 | , ExistentialQuantification 5 | #-} 6 | {-# OPTIONS_HADDOCK hide #-} 7 | 8 | ----------------------------------------------------------------------------- 9 | -- | 10 | -- Module : GHC.Desugar 11 | -- Copyright : (c) The University of Glasgow, 2007 12 | -- License : see libraries/base/LICENSE 13 | -- 14 | -- Maintainer : cvs-ghc@haskell.org 15 | -- Stability : internal 16 | -- Portability : non-portable (GHC extensions) 17 | -- 18 | -- Support code for desugaring in GHC 19 | -- 20 | ----------------------------------------------------------------------------- 21 | 22 | module GHC.Desugar ((>>>), AnnotationWrapper(..), toAnnotationWrapper) where 23 | 24 | import Control.Arrow (Arrow(..)) 25 | import Control.Category ((.)) 26 | import Data.Data (Data) 27 | 28 | -- A version of Control.Category.>>> overloaded on Arrow 29 | (>>>) :: forall arr. Arrow arr => forall a b c. arr a b -> arr b c -> arr a c 30 | -- NB: the type of this function is the "shape" that GHC expects 31 | -- in tcInstClassOp. So don't put all the foralls at the front! 32 | -- Yes, this is a bit grotesque, but heck it works and the whole 33 | -- arrows stuff needs reworking anyway! 34 | f >>> g = g . f 35 | 36 | -- A wrapper data type that lets the typechecker get at the appropriate dictionaries for an annotation 37 | data AnnotationWrapper = forall a. (Data a) => AnnotationWrapper a 38 | 39 | toAnnotationWrapper :: (Data a) => a -> AnnotationWrapper 40 | toAnnotationWrapper what = AnnotationWrapper what 41 | 42 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/GHC/Environment.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Trustworthy #-} 2 | {-# LANGUAGE NoImplicitPrelude #-} 3 | {-# LANGUAGE CPP #-} 4 | 5 | module GHC.Environment (getFullArgs) where 6 | 7 | import Foreign 8 | import Foreign.C 9 | import GHC.Base 10 | import GHC.Real ( fromIntegral ) 11 | import GHC.IO.Encoding 12 | import qualified GHC.Foreign as GHC 13 | 14 | #if defined(mingw32_HOST_OS) 15 | # if defined(i386_HOST_ARCH) 16 | # define WINDOWS_CCONV stdcall 17 | # elif defined(x86_64_HOST_ARCH) 18 | # define WINDOWS_CCONV ccall 19 | # else 20 | # error Unknown mingw32 arch 21 | # endif 22 | #endif 23 | 24 | -- | Computation 'getFullArgs' is the "raw" version of 'getArgs', similar 25 | -- to @argv@ in other languages. It returns a list of the program's 26 | -- command line arguments, starting with the program name, and 27 | -- including those normally eaten by the RTS (+RTS ... -RTS). 28 | getFullArgs :: IO [String] 29 | getFullArgs = do 30 | alloca $ \ p_argc -> do 31 | alloca $ \ p_argv -> do 32 | getFullProgArgv p_argc p_argv 33 | p <- fromIntegral `liftM` peek p_argc 34 | argv <- peek p_argv 35 | enc <- argvEncoding 36 | peekArray p argv >>= mapM (GHC.peekCString enc) 37 | 38 | foreign import ccall unsafe "getFullProgArgv" 39 | getFullProgArgv :: Ptr CInt -> Ptr (Ptr CString) -> IO () 40 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/GHC/Event.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Trustworthy #-} 2 | {-# LANGUAGE NoImplicitPrelude #-} 3 | 4 | -- ---------------------------------------------------------------------------- 5 | -- | This module provides scalable event notification for file 6 | -- descriptors and timeouts. 7 | -- 8 | -- This module should be considered GHC internal. 9 | -- 10 | -- ---------------------------------------------------------------------------- 11 | 12 | module GHC.Event 13 | ( -- * Types 14 | EventManager 15 | , TimerManager 16 | 17 | -- * Creation 18 | , getSystemEventManager 19 | , new 20 | , getSystemTimerManager 21 | 22 | -- * Registering interest in I/O events 23 | , Event 24 | , evtRead 25 | , evtWrite 26 | , IOCallback 27 | , FdKey(keyFd) 28 | , Lifetime(..) 29 | , registerFd 30 | , unregisterFd 31 | , unregisterFd_ 32 | , closeFd 33 | 34 | -- * Registering interest in timeout events 35 | , TimeoutCallback 36 | , TimeoutKey 37 | , registerTimeout 38 | , updateTimeout 39 | , unregisterTimeout 40 | ) where 41 | 42 | import GHC.Event.Manager 43 | import GHC.Event.TimerManager (TimeoutCallback, TimeoutKey, registerTimeout, 44 | updateTimeout, unregisterTimeout, TimerManager) 45 | import GHC.Event.Thread (getSystemEventManager, getSystemTimerManager) 46 | 47 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/GHC/Event/Arr.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE MagicHash, NoImplicitPrelude, UnboxedTuples #-} 2 | 3 | module GHC.Event.Arr 4 | ( 5 | Arr(..) 6 | , new 7 | , size 8 | , read 9 | , write 10 | ) where 11 | 12 | import GHC.Base (($)) 13 | import GHC.Prim (MutableArray#, RealWorld, newArray#, readArray#, 14 | sizeofMutableArray#, writeArray#) 15 | import GHC.Types (IO(..), Int(..)) 16 | 17 | data Arr a = Arr (MutableArray# RealWorld a) 18 | 19 | new :: a -> Int -> IO (Arr a) 20 | new defval (I# n#) = IO $ \s0# -> 21 | case newArray# n# defval s0# of (# s1#, marr# #) -> (# s1#, Arr marr# #) 22 | 23 | size :: Arr a -> Int 24 | size (Arr a) = I# (sizeofMutableArray# a) 25 | 26 | read :: Arr a -> Int -> IO a 27 | read (Arr a) (I# n#) = IO $ \s0# -> 28 | case readArray# a n# s0# of (# s1#, val #) -> (# s1#, val #) 29 | 30 | write :: Arr a -> Int -> a -> IO () 31 | write (Arr a) (I# n#) val = IO $ \s0# -> 32 | case writeArray# a n# val s0# of s1# -> (# s1#, () #) 33 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/GHC/Event/Unique.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Trustworthy #-} 2 | {-# LANGUAGE BangPatterns, CPP, GeneralizedNewtypeDeriving, MagicHash, 3 | NoImplicitPrelude, UnboxedTuples #-} 4 | 5 | module GHC.Event.Unique 6 | ( 7 | UniqueSource 8 | , Unique(..) 9 | , newSource 10 | , newUnique 11 | ) where 12 | 13 | import GHC.Base 14 | import GHC.Num(Num) 15 | import GHC.Show(Show(..)) 16 | 17 | #include "MachDeps.h" 18 | 19 | data UniqueSource = US (MutableByteArray# RealWorld) 20 | 21 | newtype Unique = Unique { asInt :: Int } 22 | deriving (Eq, Ord, Num) 23 | 24 | -- | @since 4.3.1.0 25 | instance Show Unique where 26 | show = show . asInt 27 | 28 | newSource :: IO UniqueSource 29 | newSource = IO $ \s -> 30 | case newByteArray# size s of 31 | (# s', mba #) -> (# s', US mba #) 32 | where 33 | !(I# size) = SIZEOF_HSINT 34 | 35 | newUnique :: UniqueSource -> IO Unique 36 | newUnique (US mba) = IO $ \s -> 37 | case fetchAddIntArray# mba 0# 1# s of 38 | (# s', a #) -> (# s', Unique (I# a) #) 39 | {-# INLINE newUnique #-} 40 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/GHC/Exception.hs-boot: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Trustworthy #-} 2 | {-# LANGUAGE NoImplicitPrelude #-} 3 | 4 | {- 5 | This SOURCE-imported hs-boot module cuts a big dependency loop: 6 | 7 | GHC.Exception 8 | imports Data.Maybe 9 | imports GHC.Base 10 | imports GHC.Err 11 | imports {-# SOURCE #-} GHC.Exception 12 | 13 | More dramatically 14 | 15 | GHC.Exception 16 | imports Data.Typeable 17 | imports Data.Typeable.Internals 18 | imports GHC.Arr (fingerprint representation etc) 19 | imports GHC.Real 20 | imports {-# SOURCE #-} GHC.Exception 21 | 22 | However, GHC.Exceptions loop-breaking exports are all nice, 23 | well-behaved, non-bottom values. The clients use 'raise#' 24 | to get a visibly-bottom value. 25 | -} 26 | 27 | module GHC.Exception ( SomeException, errorCallException, 28 | errorCallWithCallStackException, 29 | divZeroException, overflowException, ratioZeroDenomException, 30 | underflowException 31 | ) where 32 | import GHC.Types ( Char ) 33 | import GHC.Stack.Types ( CallStack ) 34 | 35 | data SomeException 36 | divZeroException, overflowException, ratioZeroDenomException :: SomeException 37 | underflowException :: SomeException 38 | 39 | errorCallException :: [Char] -> SomeException 40 | errorCallWithCallStackException :: [Char] -> CallStack -> SomeException 41 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/GHC/ExecutionStack.hs: -------------------------------------------------------------------------------- 1 | ----------------------------------------------------------------------------- 2 | -- | 3 | -- Module : GHC.ExecutionStack 4 | -- Copyright : (c) The University of Glasgow 2013-2015 5 | -- License : see libraries/base/LICENSE 6 | -- 7 | -- Maintainer : cvs-ghc@haskell.org 8 | -- Stability : internal 9 | -- Portability : non-portable (GHC Extensions) 10 | -- 11 | -- This is a module for efficient stack traces. This stack trace implementation 12 | -- is considered low overhead. Basic usage looks like this: 13 | -- 14 | -- @ 15 | -- import GHC.ExecutionStack 16 | -- 17 | -- myFunction :: IO () 18 | -- myFunction = do 19 | -- putStrLn =<< showStackTrace 20 | -- @ 21 | -- 22 | -- Your GHC must have been built with @libdw@ support for this to work. 23 | -- 24 | -- @ 25 | -- user@host:~$ ghc --info | grep libdw 26 | -- ,("RTS expects libdw","YES") 27 | -- @ 28 | -- 29 | -- @since 4.9.0.0 30 | ----------------------------------------------------------------------------- 31 | 32 | module GHC.ExecutionStack ( 33 | Location (..) 34 | , SrcLoc (..) 35 | , getStackTrace 36 | , showStackTrace 37 | ) where 38 | 39 | import Control.Monad (join) 40 | import GHC.ExecutionStack.Internal 41 | 42 | -- | Get a trace of the current execution stack state. 43 | -- 44 | -- Returns @Nothing@ if stack trace support isn't available on host machine. 45 | getStackTrace :: IO (Maybe [Location]) 46 | getStackTrace = (join . fmap stackFrames) `fmap` collectStackTrace 47 | 48 | -- | Get a string representation of the current execution stack state. 49 | showStackTrace :: IO (Maybe String) 50 | showStackTrace = fmap (\st -> showStackFrames st "") `fmap` getStackTrace 51 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/GHC/Fingerprint.hs-boot: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Trustworthy #-} 2 | {-# LANGUAGE NoImplicitPrelude #-} 3 | 4 | module GHC.Fingerprint ( 5 | fingerprintString, 6 | fingerprintFingerprints 7 | ) where 8 | 9 | import GHC.Base 10 | import GHC.Fingerprint.Type 11 | 12 | fingerprintFingerprints :: [Fingerprint] -> Fingerprint 13 | fingerprintString :: String -> Fingerprint 14 | 15 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/GHC/Fingerprint/Type.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Trustworthy #-} 2 | {-# LANGUAGE NoImplicitPrelude #-} 3 | 4 | -- ---------------------------------------------------------------------------- 5 | -- 6 | -- (c) The University of Glasgow 2006 7 | -- 8 | -- Fingerprints for recompilation checking and ABI versioning, and 9 | -- implementing fast comparison of Typeable. 10 | -- 11 | -- ---------------------------------------------------------------------------- 12 | 13 | module GHC.Fingerprint.Type (Fingerprint(..)) where 14 | 15 | import GHC.Base 16 | import GHC.List (length, replicate) 17 | import GHC.Num 18 | import GHC.Show 19 | import GHC.Word 20 | import Numeric (showHex) 21 | 22 | -- Using 128-bit MD5 fingerprints for now. 23 | 24 | data Fingerprint = Fingerprint {-# UNPACK #-} !Word64 {-# UNPACK #-} !Word64 25 | deriving (Eq, Ord) 26 | 27 | -- | @since 4.7.0.0 28 | instance Show Fingerprint where 29 | show (Fingerprint w1 w2) = hex16 w1 ++ hex16 w2 30 | where 31 | -- | Formats a 64 bit number as 16 digits hex. 32 | hex16 :: Word64 -> String 33 | hex16 i = let hex = showHex i "" 34 | in replicate (16 - length hex) '0' ++ hex 35 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/GHC/GHCi.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE NoImplicitPrelude #-} 2 | {-# OPTIONS_HADDOCK hide #-} 3 | 4 | ----------------------------------------------------------------------------- 5 | -- | 6 | -- Module : GHC.GHCi 7 | -- Copyright : (c) The University of Glasgow 2012 8 | -- License : see libraries/base/LICENSE 9 | -- 10 | -- Maintainer : cvs-ghc@haskell.org 11 | -- Stability : internal 12 | -- Portability : non-portable (GHC Extensions) 13 | -- 14 | -- The GHCi Monad lifting interface. 15 | -- 16 | -- EXPERIMENTAL! DON'T USE. 17 | -- 18 | ----------------------------------------------------------------------------- 19 | 20 | module GHC.GHCi {-# WARNING "This is an unstable interface." #-} ( 21 | GHCiSandboxIO(..), NoIO() 22 | ) where 23 | 24 | import GHC.Base (IO(), Monad, Functor(fmap), Applicative(..), (>>=), id, (.), ap) 25 | 26 | -- | A monad that can execute GHCi statements by lifting them out of 27 | -- m into the IO monad. (e.g state monads) 28 | class (Monad m) => GHCiSandboxIO m where 29 | ghciStepIO :: m a -> IO a 30 | 31 | -- | @since 4.4.0.0 32 | instance GHCiSandboxIO IO where 33 | ghciStepIO = id 34 | 35 | -- | A monad that doesn't allow any IO. 36 | newtype NoIO a = NoIO { noio :: IO a } 37 | 38 | -- | @since 4.8.0.0 39 | instance Functor NoIO where 40 | fmap f (NoIO a) = NoIO (fmap f a) 41 | 42 | -- | @since 4.8.0.0 43 | instance Applicative NoIO where 44 | pure a = NoIO (pure a) 45 | (<*>) = ap 46 | 47 | -- | @since 4.4.0.0 48 | instance Monad NoIO where 49 | (>>=) k f = NoIO (noio k >>= noio . f) 50 | 51 | -- | @since 4.4.0.0 52 | instance GHCiSandboxIO NoIO where 53 | ghciStepIO = noio 54 | 55 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/GHC/IO.hs-boot: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Unsafe #-} 2 | {-# LANGUAGE NoImplicitPrelude #-} 3 | 4 | module GHC.IO where 5 | 6 | import GHC.Types 7 | 8 | failIO :: [Char] -> IO a 9 | mplusIO :: IO a -> IO a -> IO a 10 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/GHC/IO/Encoding.hs-boot: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Trustworthy #-} 2 | {-# LANGUAGE NoImplicitPrelude #-} 3 | 4 | module GHC.IO.Encoding where 5 | 6 | import GHC.IO (IO) 7 | import GHC.IO.Encoding.Types 8 | 9 | getLocaleEncoding, getFileSystemEncoding, getForeignEncoding :: IO TextEncoding 10 | 11 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/GHC/IO/Exception.hs-boot: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Trustworthy #-} 2 | {-# LANGUAGE NoImplicitPrelude #-} 3 | 4 | module GHC.IO.Exception where 5 | 6 | import GHC.Base 7 | import GHC.Exception 8 | 9 | data IOException 10 | instance Exception IOException 11 | 12 | type IOError = IOException 13 | userError :: String -> IOError 14 | unsupportedOperation :: IOError 15 | 16 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/GHC/IO/Handle.hs-boot: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Trustworthy #-} 2 | {-# LANGUAGE NoImplicitPrelude #-} 3 | 4 | module GHC.IO.Handle where 5 | 6 | import GHC.IO 7 | import GHC.IO.Handle.Types 8 | 9 | hFlush :: Handle -> IO () 10 | 11 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/GHC/IO/Handle/FD.hs-boot: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Trustworthy #-} 2 | {-# LANGUAGE NoImplicitPrelude #-} 3 | 4 | module GHC.IO.Handle.FD where 5 | 6 | import GHC.IO.Handle.Types 7 | 8 | -- used in GHC.Conc, which is below GHC.IO.Handle.FD 9 | stdout :: Handle 10 | 11 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/GHC/IO/IOMode.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Trustworthy #-} 2 | {-# LANGUAGE NoImplicitPrelude #-} 3 | {-# OPTIONS_HADDOCK hide #-} 4 | 5 | ----------------------------------------------------------------------------- 6 | -- | 7 | -- Module : GHC.IO.IOMode 8 | -- Copyright : (c) The University of Glasgow, 1994-2008 9 | -- License : see libraries/base/LICENSE 10 | -- 11 | -- Maintainer : libraries@haskell.org 12 | -- Stability : internal 13 | -- Portability : non-portable 14 | -- 15 | -- The IOMode type 16 | -- 17 | ----------------------------------------------------------------------------- 18 | 19 | module GHC.IO.IOMode (IOMode(..)) where 20 | 21 | import GHC.Base 22 | import GHC.Show 23 | import GHC.Read 24 | import GHC.Arr 25 | import GHC.Enum 26 | 27 | -- | See 'System.IO.openFile' 28 | data IOMode = ReadMode | WriteMode | AppendMode | ReadWriteMode 29 | deriving (Eq, Ord, Ix, Enum, Read, Show) 30 | 31 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/GHC/IOArray.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Unsafe #-} 2 | {-# LANGUAGE NoImplicitPrelude, RoleAnnotations #-} 3 | {-# OPTIONS_GHC -funbox-strict-fields #-} 4 | {-# OPTIONS_HADDOCK hide #-} 5 | 6 | ----------------------------------------------------------------------------- 7 | -- | 8 | -- Module : GHC.IOArray 9 | -- Copyright : (c) The University of Glasgow 2008 10 | -- License : see libraries/base/LICENSE 11 | -- 12 | -- Maintainer : cvs-ghc@haskell.org 13 | -- Stability : internal 14 | -- Portability : non-portable (GHC Extensions) 15 | -- 16 | -- The IOArray type 17 | -- 18 | ----------------------------------------------------------------------------- 19 | 20 | module GHC.IOArray ( 21 | IOArray(..), 22 | newIOArray, unsafeReadIOArray, unsafeWriteIOArray, 23 | readIOArray, writeIOArray, 24 | boundsIOArray 25 | ) where 26 | 27 | import GHC.Base 28 | import GHC.IO 29 | import GHC.Arr 30 | 31 | -- --------------------------------------------------------------------------- 32 | -- | An 'IOArray' is a mutable, boxed, non-strict array in the 'IO' monad. 33 | -- The type arguments are as follows: 34 | -- 35 | -- * @i@: the index type of the array (should be an instance of 'Ix') 36 | -- 37 | -- * @e@: the element type of the array. 38 | -- 39 | -- 40 | 41 | newtype IOArray i e = IOArray (STArray RealWorld i e) 42 | 43 | -- index type should have a nominal role due to Ix class. See also #9220. 44 | type role IOArray nominal representational 45 | 46 | -- explicit instance because Haddock can't figure out a derived one 47 | -- | @since 4.1.0.0 48 | instance Eq (IOArray i e) where 49 | IOArray x == IOArray y = x == y 50 | 51 | -- |Build a new 'IOArray' 52 | newIOArray :: Ix i => (i,i) -> e -> IO (IOArray i e) 53 | {-# INLINE newIOArray #-} 54 | newIOArray lu initial = stToIO $ do {marr <- newSTArray lu initial; return (IOArray marr)} 55 | 56 | -- | Read a value from an 'IOArray' 57 | unsafeReadIOArray :: IOArray i e -> Int -> IO e 58 | {-# INLINE unsafeReadIOArray #-} 59 | unsafeReadIOArray (IOArray marr) i = stToIO (unsafeReadSTArray marr i) 60 | 61 | -- | Write a new value into an 'IOArray' 62 | unsafeWriteIOArray :: IOArray i e -> Int -> e -> IO () 63 | {-# INLINE unsafeWriteIOArray #-} 64 | unsafeWriteIOArray (IOArray marr) i e = stToIO (unsafeWriteSTArray marr i e) 65 | 66 | -- | Read a value from an 'IOArray' 67 | readIOArray :: Ix i => IOArray i e -> i -> IO e 68 | readIOArray (IOArray marr) i = stToIO (readSTArray marr i) 69 | 70 | -- | Write a new value into an 'IOArray' 71 | writeIOArray :: Ix i => IOArray i e -> i -> e -> IO () 72 | writeIOArray (IOArray marr) i e = stToIO (writeSTArray marr i e) 73 | 74 | {-# INLINE boundsIOArray #-} 75 | boundsIOArray :: IOArray i e -> (i,i) 76 | boundsIOArray (IOArray marr) = boundsSTArray marr 77 | 78 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/GHC/IORef.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Unsafe #-} 2 | {-# LANGUAGE NoImplicitPrelude, MagicHash #-} 3 | {-# OPTIONS_GHC -funbox-strict-fields #-} 4 | {-# OPTIONS_HADDOCK hide #-} 5 | 6 | ----------------------------------------------------------------------------- 7 | -- | 8 | -- Module : GHC.IORef 9 | -- Copyright : (c) The University of Glasgow 2008 10 | -- License : see libraries/base/LICENSE 11 | -- 12 | -- Maintainer : cvs-ghc@haskell.org 13 | -- Stability : internal 14 | -- Portability : non-portable (GHC Extensions) 15 | -- 16 | -- The IORef type 17 | -- 18 | ----------------------------------------------------------------------------- 19 | 20 | module GHC.IORef ( 21 | IORef(..), 22 | newIORef, readIORef, writeIORef, atomicModifyIORef 23 | ) where 24 | 25 | import GHC.Base 26 | import GHC.STRef 27 | import GHC.IO 28 | 29 | -- --------------------------------------------------------------------------- 30 | -- IORefs 31 | 32 | -- |A mutable variable in the 'IO' monad 33 | newtype IORef a = IORef (STRef RealWorld a) 34 | deriving Eq 35 | -- ^ Pointer equality. 36 | -- 37 | -- @since 4.1.0.0 38 | 39 | -- |Build a new 'IORef' 40 | newIORef :: a -> IO (IORef a) 41 | newIORef v = stToIO (newSTRef v) >>= \ var -> return (IORef var) 42 | 43 | -- |Read the value of an 'IORef' 44 | readIORef :: IORef a -> IO a 45 | readIORef (IORef var) = stToIO (readSTRef var) 46 | 47 | -- |Write a new value into an 'IORef' 48 | writeIORef :: IORef a -> a -> IO () 49 | writeIORef (IORef var) v = stToIO (writeSTRef var v) 50 | 51 | atomicModifyIORef :: IORef a -> (a -> (a,b)) -> IO b 52 | atomicModifyIORef (IORef (STRef r#)) f = IO $ \s -> atomicModifyMutVar# r# f s 53 | 54 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/GHC/OldList.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE NoImplicitPrelude #-} 2 | {-# LANGUAGE Safe #-} 3 | 4 | ----------------------------------------------------------------------------- 5 | -- | 6 | -- Module : GHC.OldList 7 | -- Copyright : (c) The University of Glasgow 2001 8 | -- License : BSD-style (see the file libraries/base/LICENSE) 9 | -- 10 | -- Maintainer : libraries@haskell.org 11 | -- Stability : experimental 12 | -- Portability : portable 13 | -- 14 | -- This legacy module provides access to the list-specialised operations 15 | -- of "Data.List". This module may go away again in future GHC versions and 16 | -- is provided as transitional tool to access some of the list-specialised 17 | -- operations that had to be generalised due to the implementation of the 18 | -- . 19 | -- 20 | -- If the operations needed are available in "GHC.List", it's 21 | -- recommended to avoid importing this module and use "GHC.List" 22 | -- instead for now. 23 | -- 24 | -- @since 4.8.0.0 25 | ----------------------------------------------------------------------------- 26 | 27 | module GHC.OldList (module Data.OldList) where 28 | 29 | import Data.OldList 30 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/GHC/OverloadedLabels.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE AllowAmbiguousTypes 2 | , DataKinds 3 | , FlexibleInstances 4 | , KindSignatures 5 | , MultiParamTypeClasses 6 | , ScopedTypeVariables 7 | , TypeApplications 8 | #-} 9 | 10 | ----------------------------------------------------------------------------- 11 | -- | 12 | -- Module : GHC.OverloadedLabels 13 | -- Copyright : (c) Adam Gundry 2015-2016 14 | -- License : see libraries/base/LICENSE 15 | -- 16 | -- Maintainer : cvs-ghc@haskell.org 17 | -- Stability : internal 18 | -- Portability : non-portable (GHC extensions) 19 | -- 20 | -- This module defines the 'IsLabel' class is used by the 21 | -- @OverloadedLabels@ extension. See the 22 | -- 23 | -- for more details. 24 | -- 25 | -- When @OverloadedLabels@ is enabled, if GHC sees an occurrence of 26 | -- the overloaded label syntax @#foo@, it is replaced with 27 | -- 28 | -- > fromLabel @"foo" :: alpha 29 | -- 30 | -- plus a wanted constraint @IsLabel "foo" alpha@. 31 | -- 32 | -- Note that if @RebindableSyntax@ is enabled, the desugaring of 33 | -- overloaded label syntax will make use of whatever @fromLabel@ is in 34 | -- scope. 35 | -- 36 | ----------------------------------------------------------------------------- 37 | 38 | -- Note [Overloaded labels] 39 | -- ~~~~~~~~~~~~~~~~~~~~~~~~ 40 | -- An overloaded label is represented by the 'HsOverLabel' constructor 41 | -- of 'HsExpr', which stores the 'FastString' text of the label and an 42 | -- optional id for the 'fromLabel' function to use (if 43 | -- RebindableSyntax is enabled) . The type-checker transforms it into 44 | -- a call to 'fromLabel'. See Note [Type-checking overloaded labels] 45 | -- in TcExpr for more details in how type-checking works. 46 | 47 | module GHC.OverloadedLabels 48 | ( IsLabel(..) 49 | ) where 50 | 51 | import GHC.Base ( Symbol ) 52 | 53 | class IsLabel (x :: Symbol) a where 54 | fromLabel :: a 55 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/GHC/PArr.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Trustworthy #-} 2 | {-# LANGUAGE NoImplicitPrelude #-} 3 | {-# LANGUAGE ParallelArrays, MagicHash #-} 4 | {-# OPTIONS_GHC -funbox-strict-fields #-} 5 | {-# OPTIONS_HADDOCK hide #-} 6 | 7 | ----------------------------------------------------------------------------- 8 | -- | 9 | -- Module : GHC.PArr 10 | -- Copyright : (c) 2001-2011 The Data Parallel Haskell team 11 | -- License : see libraries/base/LICENSE 12 | -- 13 | -- Maintainer : cvs-ghc@haskell.org 14 | -- Stability : internal 15 | -- Portability : non-portable (GHC Extensions) 16 | -- 17 | -- BIG UGLY HACK: The desugarer special cases this module. Despite the uses of '-XParallelArrays', 18 | -- the desugarer does not load 'Data.Array.Parallel' into its global state. (Hence, 19 | -- the present module may not use any other piece of '-XParallelArray' syntax.) 20 | -- 21 | -- This will be cleaned up when we change the internal represention of '[::]' to not 22 | -- rely on a wired-in type constructor. 23 | 24 | module GHC.PArr where 25 | 26 | import GHC.Base 27 | 28 | -- Representation of parallel arrays 29 | -- 30 | -- Vanilla representation of parallel Haskell based on standard GHC arrays that is used if the 31 | -- vectorised is /not/ used. 32 | -- 33 | -- NB: This definition *must* be kept in sync with `TysWiredIn.parrTyCon'! 34 | -- 35 | data [::] e = PArr !Int (Array# e) 36 | 37 | type PArr = [::] -- this synonym is to get access to '[::]' without using the special syntax 38 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/GHC/Profiling.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Trustworthy #-} 2 | {-# LANGUAGE NoImplicitPrelude #-} 3 | 4 | -- | @since 4.7.0.0 5 | module GHC.Profiling where 6 | 7 | import GHC.Base 8 | 9 | -- | Stop attributing ticks to cost centres. Allocations will still be 10 | -- attributed. 11 | -- 12 | -- @since 4.7.0.0 13 | foreign import ccall stopProfTimer :: IO () 14 | 15 | -- | Start attributing ticks to cost centres. This is called by the RTS on 16 | -- startup. 17 | -- 18 | -- @since 4.7.0.0 19 | foreign import ccall startProfTimer :: IO () 20 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/GHC/Real.hs-boot: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE NoImplicitPrelude #-} 2 | 3 | module GHC.Real where 4 | 5 | import GHC.Types () 6 | 7 | class Integral a 8 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/GHC/Records.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE AllowAmbiguousTypes 2 | , FunctionalDependencies 3 | , KindSignatures 4 | , MultiParamTypeClasses 5 | , PolyKinds 6 | #-} 7 | 8 | ----------------------------------------------------------------------------- 9 | -- | 10 | -- Module : GHC.Records 11 | -- Copyright : (c) Adam Gundry 2015-2016 12 | -- License : see libraries/base/LICENSE 13 | -- 14 | -- Maintainer : cvs-ghc@haskell.org 15 | -- Stability : internal 16 | -- Portability : non-portable (GHC extensions) 17 | -- 18 | -- This module defines the 'HasField' class used by the 19 | -- @OverloadedRecordFields@ extension. See the 20 | -- for more details. 22 | -- 23 | ----------------------------------------------------------------------------- 24 | 25 | module GHC.Records 26 | ( HasField(..) 27 | ) where 28 | 29 | -- | Constraint representing the fact that the field @x@ belongs to 30 | -- the record type @r@ and has field type @a@. This will be solved 31 | -- automatically, but manual instances may be provided as well. 32 | class HasField (x :: k) r a | x r -> a where 33 | -- | Selector function to extract the field from the record. 34 | getField :: r -> a 35 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/GHC/STRef.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Unsafe #-} 2 | {-# LANGUAGE NoImplicitPrelude, MagicHash, UnboxedTuples #-} 3 | {-# OPTIONS_HADDOCK hide #-} 4 | 5 | ----------------------------------------------------------------------------- 6 | -- | 7 | -- Module : GHC.STRef 8 | -- Copyright : (c) The University of Glasgow, 1994-2002 9 | -- License : see libraries/base/LICENSE 10 | -- 11 | -- Maintainer : cvs-ghc@haskell.org 12 | -- Stability : internal 13 | -- Portability : non-portable (GHC Extensions) 14 | -- 15 | -- References in the 'ST' monad. 16 | -- 17 | ----------------------------------------------------------------------------- 18 | 19 | module GHC.STRef ( 20 | STRef(..), 21 | newSTRef, readSTRef, writeSTRef 22 | ) where 23 | 24 | import GHC.ST 25 | import GHC.Base 26 | 27 | -- $setup 28 | -- import Prelude 29 | 30 | data STRef s a = STRef (MutVar# s a) 31 | -- ^ a value of type @STRef s a@ is a mutable variable in state thread @s@, 32 | -- containing a value of type @a@ 33 | -- 34 | -- >>> :{ 35 | -- runST (do 36 | -- ref <- newSTRef "hello" 37 | -- x <- readSTRef ref 38 | -- writeSTRef ref (x ++ "world") 39 | -- readSTRef ref ) 40 | -- :} 41 | -- "helloworld" 42 | 43 | -- |Build a new 'STRef' in the current state thread 44 | newSTRef :: a -> ST s (STRef s a) 45 | newSTRef init = ST $ \s1# -> 46 | case newMutVar# init s1# of { (# s2#, var# #) -> 47 | (# s2#, STRef var# #) } 48 | 49 | -- |Read the value of an 'STRef' 50 | readSTRef :: STRef s a -> ST s a 51 | readSTRef (STRef var#) = ST $ \s1# -> readMutVar# var# s1# 52 | 53 | -- |Write a new value into an 'STRef' 54 | writeSTRef :: STRef s a -> a -> ST s () 55 | writeSTRef (STRef var#) val = ST $ \s1# -> 56 | case writeMutVar# var# val s1# of { s2# -> 57 | (# s2#, () #) } 58 | 59 | -- | Pointer equality. 60 | -- 61 | -- @since 2.01 62 | instance Eq (STRef s a) where 63 | STRef v1# == STRef v2# = isTrue# (sameMutVar# v1# v2#) 64 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/GHC/Stack/CCS.hs-boot: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE NoImplicitPrelude #-} 2 | module GHC.Stack.CCS where 3 | 4 | {- Cuts the following loop: 5 | 6 | GHC.Exception.errorCallWithCallStackException requires 7 | GHC.Stack.CCS.currentCallStack, which requires 8 | Foreign.C (for peeking CostCentres) 9 | GHC.Foreign, GHC.IO.Encoding (for decoding UTF-8 strings) 10 | .. lots of stuff ... 11 | GHC.Exception 12 | -} 13 | 14 | import GHC.Base 15 | 16 | currentCallStack :: IO [String] 17 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/GHC/StaticPtr/Internal.hs: -------------------------------------------------------------------------------- 1 | -- | 2 | -- Module : GHC.StaticPtr 3 | -- Copyright : (C) 2016 I/O Tweag 4 | -- License : see libraries/base/LICENSE 5 | -- 6 | -- Maintainer : cvs-ghc@haskell.org 7 | -- Stability : internal 8 | -- Portability : non-portable (GHC Extensions) 9 | -- 10 | -- Internal definitions needed for compiling static forms. 11 | -- 12 | 13 | -- By omitting interface pragmas, we drop the strictness annotations 14 | -- which otherwise would bias GHC to conclude that any code using 15 | -- the static form would fail. 16 | {-# OPTIONS_GHC -fomit-interface-pragmas #-} 17 | module GHC.StaticPtr.Internal (makeStatic) where 18 | 19 | import GHC.StaticPtr(StaticPtr) 20 | 21 | -- 'makeStatic' should never be called by the user. 22 | -- See Note [Grand plan for static forms] in StaticPtrTable. 23 | 24 | makeStatic :: (Int, Int) -> a -> StaticPtr a 25 | makeStatic (line, col) _ = 26 | error $ "GHC bug - makeStatic: Unresolved static form at line " 27 | ++ show line ++ ", column " ++ show col ++ "." 28 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Numeric/Natural.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE NoImplicitPrelude #-} 2 | {-# LANGUAGE Trustworthy #-} 3 | 4 | ----------------------------------------------------------------------------- 5 | -- | 6 | -- Module : Numeric.Natural 7 | -- Copyright : (C) 2014 Herbert Valerio Riedel, 8 | -- (C) 2011 Edward Kmett 9 | -- License : see libraries/base/LICENSE 10 | -- 11 | -- Maintainer : libraries@haskell.org 12 | -- Stability : provisional 13 | -- Portability : portable 14 | -- 15 | -- The arbitrary-precision 'Natural' number type. 16 | -- 17 | -- @since 4.8.0.0 18 | ----------------------------------------------------------------------------- 19 | 20 | module Numeric.Natural 21 | ( Natural 22 | ) where 23 | 24 | import GHC.Natural 25 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Setup.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE NoImplicitPrelude #-} 2 | module Main (main) where 3 | 4 | import Distribution.Simple 5 | 6 | main = defaultMainWithHooks autoconfUserHooks 7 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/System/CPUTime.hsc: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Trustworthy #-} 2 | {-# LANGUAGE CPP, CApiFFI #-} 3 | 4 | ----------------------------------------------------------------------------- 5 | -- | 6 | -- Module : System.CPUTime 7 | -- Copyright : (c) The University of Glasgow 2001 8 | -- License : BSD-style (see the file libraries/base/LICENSE) 9 | -- 10 | -- Maintainer : libraries@haskell.org 11 | -- Stability : provisional 12 | -- Portability : portable 13 | -- 14 | -- The standard CPUTime library. 15 | -- 16 | ----------------------------------------------------------------------------- 17 | 18 | #include "HsFFI.h" 19 | #include "HsBaseConfig.h" 20 | 21 | -- For various _POSIX_* #defines 22 | #if defined(HAVE_UNISTD_H) 23 | #include 24 | #endif 25 | 26 | module System.CPUTime 27 | ( getCPUTime 28 | , cpuTimePrecision 29 | ) where 30 | 31 | import System.IO.Unsafe (unsafePerformIO) 32 | 33 | -- Here is where we decide which backend to use 34 | #if defined(mingw32_HOST_OS) 35 | import qualified System.CPUTime.Windows as I 36 | 37 | #elif _POSIX_TIMERS > 0 && defined(_POSIX_CPUTIME) && _POSIX_CPUTIME >= 0 38 | import qualified System.CPUTime.Posix.ClockGetTime as I 39 | 40 | #elif defined(HAVE_GETRUSAGE) && ! solaris2_HOST_OS 41 | import qualified System.CPUTime.Posix.RUsage as I 42 | 43 | -- @getrusage()@ is right royal pain to deal with when targetting multiple 44 | -- versions of Solaris, since some versions supply it in libc (2.3 and 2.5), 45 | -- while 2.4 has got it in libucb (I wouldn't be too surprised if it was back 46 | -- again in libucb in 2.6..) 47 | -- 48 | -- Avoid the problem by resorting to times() instead. 49 | #elif defined(HAVE_TIMES) 50 | import qualified System.CPUTime.Posix.Times as I 51 | 52 | #else 53 | import qualified System.CPUTime.Unsupported as I 54 | #endif 55 | 56 | -- | The 'cpuTimePrecision' constant is the smallest measurable difference 57 | -- in CPU time that the implementation can record, and is given as an 58 | -- integral number of picoseconds. 59 | cpuTimePrecision :: Integer 60 | cpuTimePrecision = unsafePerformIO I.getCpuTimePrecision 61 | {-# NOINLINE cpuTimePrecision #-} 62 | 63 | -- | Computation 'getCPUTime' returns the number of picoseconds CPU time 64 | -- used by the current program. The precision of this result is 65 | -- implementation-dependent. 66 | getCPUTime :: IO Integer 67 | getCPUTime = I.getCPUTime 68 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/System/CPUTime/Posix/ClockGetTime.hsc: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE CPP, CApiFFI, NumDecimals #-} 2 | 3 | #include "HsFFI.h" 4 | #include "HsBaseConfig.h" 5 | #if HAVE_TIME_H 6 | #include 7 | #include 8 | #endif 9 | 10 | module System.CPUTime.Posix.ClockGetTime 11 | ( getCPUTime 12 | , getCpuTimePrecision 13 | ) where 14 | 15 | #if _POSIX_TIMERS > 0 && defined(_POSIX_CPUTIME) && _POSIX_CPUTIME >= 0 16 | 17 | import Foreign 18 | import Foreign.C 19 | import System.CPUTime.Utils 20 | 21 | getCPUTime :: IO Integer 22 | getCPUTime = fmap snd $ withTimespec $ \ts -> 23 | throwErrnoIfMinus1_ "clock_gettime" 24 | $ clock_gettime (#const CLOCK_PROCESS_CPUTIME_ID) ts 25 | 26 | getCpuTimePrecision :: IO Integer 27 | getCpuTimePrecision = fmap snd $ withTimespec $ \ts -> 28 | throwErrnoIfMinus1_ "clock_getres" 29 | $ clock_getres (#const CLOCK_PROCESS_CPUTIME_ID) ts 30 | 31 | data Timespec 32 | 33 | -- | Perform the given action to fill in a @struct timespec@, returning the 34 | -- result of the action and the value of the @timespec@ in picoseconds. 35 | withTimespec :: (Ptr Timespec -> IO a) -> IO (a, Integer) 36 | withTimespec action = 37 | allocaBytes (# const sizeof(struct timespec)) $ \p_ts -> do 38 | r <- action p_ts 39 | u_sec <- (#peek struct timespec,tv_sec) p_ts :: IO CTime 40 | u_nsec <- (#peek struct timespec,tv_nsec) p_ts :: IO CLong 41 | return (r, cTimeToInteger u_sec * 1e12 + fromIntegral u_nsec * 1e3) 42 | 43 | foreign import capi unsafe "time.h clock_getres" clock_getres :: CInt -> Ptr Timespec -> IO CInt 44 | foreign import capi unsafe "time.h clock_gettime" clock_gettime :: CInt -> Ptr Timespec -> IO CInt 45 | 46 | #else 47 | 48 | -- This should never happen 49 | getCPUTime :: IO Integer 50 | getCPUTime = error "System.CPUTime.Posix.ClockGetTime: Unsupported" 51 | 52 | getCpuTimePrecision :: IO Integer 53 | getCpuTimePrecision = error "System.CPUTime.Posix.ClockGetTime: Unsupported" 54 | 55 | #endif // _POSIX_CPUTIME 56 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/System/CPUTime/Posix/RUsage.hsc: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE CPP, CApiFFI, NumDecimals #-} 2 | 3 | #include "HsFFI.h" 4 | #include "HsBaseConfig.h" 5 | 6 | module System.CPUTime.Posix.RUsage 7 | ( getCPUTime 8 | , getCpuTimePrecision 9 | ) where 10 | 11 | import Data.Ratio 12 | import Foreign 13 | import Foreign.C 14 | import System.CPUTime.Utils 15 | 16 | -- For struct rusage 17 | #if HAVE_SYS_RESOURCE_H 18 | #include 19 | #endif 20 | 21 | getCPUTime :: IO Integer 22 | getCPUTime = allocaBytes (#const sizeof(struct rusage)) $ \ p_rusage -> do 23 | throwErrnoIfMinus1_ "getrusage" $ getrusage (#const RUSAGE_SELF) p_rusage 24 | 25 | let ru_utime = (#ptr struct rusage, ru_utime) p_rusage 26 | let ru_stime = (#ptr struct rusage, ru_stime) p_rusage 27 | u_sec <- (#peek struct timeval,tv_sec) ru_utime :: IO CTime 28 | u_usec <- (#peek struct timeval,tv_usec) ru_utime :: IO CSUSeconds 29 | s_sec <- (#peek struct timeval,tv_sec) ru_stime :: IO CTime 30 | s_usec <- (#peek struct timeval,tv_usec) ru_stime :: IO CSUSeconds 31 | let usec = cTimeToInteger u_sec * 1e6 + csuSecondsToInteger u_usec + 32 | cTimeToInteger s_sec * 1e6 + csuSecondsToInteger s_usec 33 | return (usec * 1e6) 34 | 35 | type CRUsage = () 36 | foreign import capi unsafe "HsBase.h getrusage" getrusage :: CInt -> Ptr CRUsage -> IO CInt 37 | 38 | getCpuTimePrecision :: IO Integer 39 | getCpuTimePrecision = 40 | return $ round ((1e12::Integer) % fromIntegral clk_tck) 41 | 42 | foreign import ccall unsafe clk_tck :: CLong 43 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/System/CPUTime/Posix/Times.hsc: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE CPP, CApiFFI, NumDecimals #-} 2 | 3 | #include "HsFFI.h" 4 | #include "HsBaseConfig.h" 5 | 6 | module System.CPUTime.Posix.Times 7 | ( getCPUTime 8 | , getCpuTimePrecision 9 | ) where 10 | 11 | import Data.Ratio 12 | import Foreign 13 | import Foreign.C 14 | import System.CPUTime.Utils 15 | 16 | -- for struct tms 17 | #if HAVE_SYS_TIMES_H 18 | #include 19 | #endif 20 | 21 | getCPUTime :: IO Integer 22 | getCPUTime = allocaBytes (#const sizeof(struct tms)) $ \ p_tms -> do 23 | _ <- times p_tms 24 | u_ticks <- (#peek struct tms,tms_utime) p_tms :: IO CClock 25 | s_ticks <- (#peek struct tms,tms_stime) p_tms :: IO CClock 26 | return (( (cClockToInteger u_ticks + cClockToInteger s_ticks) * 1e12) 27 | `div` fromIntegral clockTicks) 28 | 29 | type CTms = () 30 | foreign import ccall unsafe times :: Ptr CTms -> IO CClock 31 | 32 | getCpuTimePrecision :: IO Integer 33 | getCpuTimePrecision = 34 | return $ round ((1e12::Integer) % clockTicks) 35 | 36 | foreign import ccall unsafe clk_tck :: CLong 37 | 38 | clockTicks :: Integer 39 | clockTicks = fromIntegral clk_tck 40 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/System/CPUTime/Unsupported.hs: -------------------------------------------------------------------------------- 1 | module System.CPUTime.Unsupported 2 | ( getCPUTime 3 | , getCpuTimePrecision 4 | ) where 5 | 6 | import GHC.IO.Exception 7 | 8 | getCPUTime :: IO Integer 9 | getCPUTime = 10 | ioError (IOError Nothing UnsupportedOperation 11 | "getCPUTime" 12 | "can't get CPU time" 13 | Nothing Nothing) 14 | 15 | getCpuTimePrecision :: IO Integer 16 | getCpuTimePrecision = 17 | ioError (IOError Nothing UnsupportedOperation 18 | "cpuTimePrecision" 19 | "can't get CPU time" 20 | Nothing Nothing) 21 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/System/CPUTime/Utils.hs: -------------------------------------------------------------------------------- 1 | module System.CPUTime.Utils 2 | ( -- * Integer conversions 3 | -- | These types have no 'Integral' instances in the Haskell report 4 | -- so we must do this ourselves. 5 | cClockToInteger 6 | , cTimeToInteger 7 | , csuSecondsToInteger 8 | ) where 9 | 10 | import Foreign.C.Types 11 | 12 | cClockToInteger :: CClock -> Integer 13 | cClockToInteger (CClock n) = fromIntegral n 14 | 15 | cTimeToInteger :: CTime -> Integer 16 | cTimeToInteger (CTime n) = fromIntegral n 17 | 18 | csuSecondsToInteger :: CSUSeconds -> Integer 19 | csuSecondsToInteger (CSUSeconds n) = fromIntegral n 20 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/System/CPUTime/Windows.hsc: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE CPP, CApiFFI, NondecreasingIndentation, NumDecimals #-} 2 | 3 | #include "HsFFI.h" 4 | #include "HsBaseConfig.h" 5 | 6 | module System.CPUTime.Windows 7 | ( getCPUTime 8 | , getCpuTimePrecision 9 | ) where 10 | 11 | import Foreign 12 | import Foreign.C 13 | 14 | -- For FILETIME etc. on Windows 15 | #if HAVE_WINDOWS_H 16 | #include 17 | #endif 18 | 19 | getCPUTime :: IO Integer 20 | getCPUTime = do 21 | -- NOTE: GetProcessTimes() is only supported on NT-based OSes. 22 | -- The counts reported by GetProcessTimes() are in 100-ns (10^-7) units. 23 | allocaBytes (#const sizeof(FILETIME)) $ \ p_creationTime -> do 24 | allocaBytes (#const sizeof(FILETIME)) $ \ p_exitTime -> do 25 | allocaBytes (#const sizeof(FILETIME)) $ \ p_kernelTime -> do 26 | allocaBytes (#const sizeof(FILETIME)) $ \ p_userTime -> do 27 | pid <- getCurrentProcess 28 | ok <- getProcessTimes pid p_creationTime p_exitTime p_kernelTime p_userTime 29 | if toBool ok then do 30 | ut <- ft2psecs p_userTime 31 | kt <- ft2psecs p_kernelTime 32 | return (ut + kt) 33 | else return 0 34 | where 35 | ft2psecs :: Ptr FILETIME -> IO Integer 36 | ft2psecs ft = do 37 | high <- (#peek FILETIME,dwHighDateTime) ft :: IO Word32 38 | low <- (#peek FILETIME,dwLowDateTime) ft :: IO Word32 39 | -- Convert 100-ns units to picosecs (10^-12) 40 | -- => multiply by 10^5. 41 | return (((fromIntegral high) * (2^(32::Int)) + (fromIntegral low)) * 100000) 42 | 43 | -- ToDo: pin down elapsed times to just the OS thread(s) that 44 | -- are evaluating/managing Haskell code. 45 | 46 | -- While it's hard to get reliable numbers, the consensus is that Windows only provides 47 | -- 16 millisecond resolution in GetProcessTimes (see Python PEP 0418) 48 | getCpuTimePrecision :: IO Integer 49 | getCpuTimePrecision = return 16e9 50 | 51 | type FILETIME = () 52 | type HANDLE = () 53 | 54 | -- need proper Haskell names (initial lower-case character) 55 | #if defined(i386_HOST_ARCH) 56 | foreign import stdcall unsafe "GetCurrentProcess" getCurrentProcess :: IO (Ptr HANDLE) 57 | foreign import stdcall unsafe "GetProcessTimes" getProcessTimes :: Ptr HANDLE -> Ptr FILETIME -> Ptr FILETIME -> Ptr FILETIME -> Ptr FILETIME -> IO CInt 58 | #elif defined(x86_64_HOST_ARCH) 59 | foreign import ccall unsafe "GetCurrentProcess" getCurrentProcess :: IO (Ptr HANDLE) 60 | foreign import ccall unsafe "GetProcessTimes" getProcessTimes :: Ptr HANDLE -> Ptr FILETIME -> Ptr FILETIME -> Ptr FILETIME -> Ptr FILETIME -> IO CInt 61 | #else 62 | #error Unknown mingw32 arch 63 | #endif 64 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/System/Exit.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Trustworthy #-} 2 | 3 | ----------------------------------------------------------------------------- 4 | -- | 5 | -- Module : System.Exit 6 | -- Copyright : (c) The University of Glasgow 2001 7 | -- License : BSD-style (see the file libraries/base/LICENSE) 8 | -- 9 | -- Maintainer : libraries@haskell.org 10 | -- Stability : provisional 11 | -- Portability : portable 12 | -- 13 | -- Exiting the program. 14 | -- 15 | ----------------------------------------------------------------------------- 16 | 17 | module System.Exit 18 | ( 19 | ExitCode(ExitSuccess,ExitFailure) 20 | , exitWith 21 | , exitFailure 22 | , exitSuccess 23 | , die 24 | ) where 25 | 26 | import System.IO 27 | 28 | import GHC.IO 29 | import GHC.IO.Exception 30 | 31 | -- --------------------------------------------------------------------------- 32 | -- exitWith 33 | 34 | -- | Computation 'exitWith' @code@ throws 'ExitCode' @code@. 35 | -- Normally this terminates the program, returning @code@ to the 36 | -- program's caller. 37 | -- 38 | -- On program termination, the standard 'Handle's 'stdout' and 39 | -- 'stderr' are flushed automatically; any other buffered 'Handle's 40 | -- need to be flushed manually, otherwise the buffered data will be 41 | -- discarded. 42 | -- 43 | -- A program that fails in any other way is treated as if it had 44 | -- called 'exitFailure'. 45 | -- A program that terminates successfully without calling 'exitWith' 46 | -- explicitly is treated as if it had called 'exitWith' 'ExitSuccess'. 47 | -- 48 | -- As an 'ExitCode' is not an 'IOError', 'exitWith' bypasses 49 | -- the error handling in the 'IO' monad and cannot be intercepted by 50 | -- 'catch' from the "Prelude". However it is a 'SomeException', and can 51 | -- be caught using the functions of "Control.Exception". This means 52 | -- that cleanup computations added with 'Control.Exception.bracket' 53 | -- (from "Control.Exception") are also executed properly on 'exitWith'. 54 | -- 55 | -- Note: in GHC, 'exitWith' should be called from the main program 56 | -- thread in order to exit the process. When called from another 57 | -- thread, 'exitWith' will throw an 'ExitException' as normal, but the 58 | -- exception will not cause the process itself to exit. 59 | -- 60 | exitWith :: ExitCode -> IO a 61 | exitWith ExitSuccess = throwIO ExitSuccess 62 | exitWith code@(ExitFailure n) 63 | | n /= 0 = throwIO code 64 | | otherwise = ioError (IOError Nothing InvalidArgument "exitWith" "ExitFailure 0" Nothing Nothing) 65 | 66 | -- | The computation 'exitFailure' is equivalent to 67 | -- 'exitWith' @(@'ExitFailure' /exitfail/@)@, 68 | -- where /exitfail/ is implementation-dependent. 69 | exitFailure :: IO a 70 | exitFailure = exitWith (ExitFailure 1) 71 | 72 | -- | The computation 'exitSuccess' is equivalent to 73 | -- 'exitWith' 'ExitSuccess', It terminates the program 74 | -- successfully. 75 | exitSuccess :: IO a 76 | exitSuccess = exitWith ExitSuccess 77 | 78 | -- | Write given error message to `stderr` and terminate with `exitFailure`. 79 | -- 80 | -- @since 4.8.0.0 81 | die :: String -> IO a 82 | die err = hPutStrLn stderr err >> exitFailure 83 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/System/IO/Unsafe.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Unsafe #-} 2 | {-# LANGUAGE NoImplicitPrelude #-} 3 | 4 | ----------------------------------------------------------------------------- 5 | -- | 6 | -- Module : System.IO.Unsafe 7 | -- Copyright : (c) The University of Glasgow 2001 8 | -- License : BSD-style (see the file libraries/base/LICENSE) 9 | -- 10 | -- Maintainer : libraries@haskell.org 11 | -- Stability : provisional 12 | -- Portability : portable 13 | -- 14 | -- \"Unsafe\" IO operations. 15 | -- 16 | ----------------------------------------------------------------------------- 17 | 18 | module System.IO.Unsafe ( 19 | -- * Unsafe 'System.IO.IO' operations 20 | unsafePerformIO, 21 | unsafeDupablePerformIO, 22 | unsafeInterleaveIO, 23 | unsafeFixIO, 24 | ) where 25 | 26 | import GHC.Base 27 | import GHC.IO 28 | import GHC.IORef 29 | import GHC.Exception 30 | import Control.Exception 31 | 32 | -- | A slightly faster version of `System.IO.fixIO` that may not be 33 | -- safe to use with multiple threads. The unsafety arises when used 34 | -- like this: 35 | -- 36 | -- > unsafeFixIO $ \r -> do 37 | -- > forkIO (print r) 38 | -- > return (...) 39 | -- 40 | -- In this case, the child thread will receive a @NonTermination@ 41 | -- exception instead of waiting for the value of @r@ to be computed. 42 | -- 43 | -- @since 4.5.0.0 44 | unsafeFixIO :: (a -> IO a) -> IO a 45 | unsafeFixIO k = do 46 | ref <- newIORef (throw NonTermination) 47 | ans <- unsafeDupableInterleaveIO (readIORef ref) 48 | result <- k ans 49 | writeIORef ref result 50 | return result 51 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/System/Info.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Safe #-} 2 | {-# LANGUAGE CPP #-} 3 | 4 | ----------------------------------------------------------------------------- 5 | -- | 6 | -- Module : System.Info 7 | -- Copyright : (c) The University of Glasgow 2001 8 | -- License : BSD-style (see the file libraries/base/LICENSE) 9 | -- 10 | -- Maintainer : libraries@haskell.org 11 | -- Stability : experimental 12 | -- Portability : portable 13 | -- 14 | -- Information about the characteristics of the host 15 | -- system lucky enough to run your program. 16 | -- 17 | ----------------------------------------------------------------------------- 18 | 19 | module System.Info 20 | ( 21 | os, 22 | arch, 23 | compilerName, 24 | compilerVersion 25 | ) where 26 | 27 | import Data.Version 28 | 29 | -- | The version of 'compilerName' with which the program was compiled 30 | -- or is being interpreted. 31 | compilerVersion :: Version 32 | compilerVersion = Version [major, minor] [] 33 | where (major, minor) = compilerVersionRaw `divMod` 100 34 | 35 | #include "ghcplatform.h" 36 | 37 | -- | The operating system on which the program is running. 38 | os :: String 39 | os = HOST_OS 40 | 41 | -- | The machine architecture on which the program is running. 42 | arch :: String 43 | arch = HOST_ARCH 44 | 45 | -- | The Haskell implementation with which the program was compiled 46 | -- or is being interpreted. 47 | compilerName :: String 48 | compilerName = "ghc" 49 | 50 | compilerVersionRaw :: Int 51 | compilerVersionRaw = __GLASGOW_HASKELL__ 52 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/System/Mem.hs: -------------------------------------------------------------------------------- 1 | ----------------------------------------------------------------------------- 2 | -- | 3 | -- Module : System.Mem 4 | -- Copyright : (c) The University of Glasgow 2001 5 | -- License : BSD-style (see the file libraries/base/LICENSE) 6 | -- 7 | -- Maintainer : libraries@haskell.org 8 | -- Stability : provisional 9 | -- Portability : portable 10 | -- 11 | -- Memory-related system things. 12 | -- 13 | ----------------------------------------------------------------------------- 14 | 15 | {-# LANGUAGE Trustworthy #-} 16 | -- allocation counter stuff is safe, but GHC.Conc.Sync is Unsafe 17 | 18 | module System.Mem 19 | ( 20 | -- * Garbage collection 21 | performGC 22 | , performMajorGC 23 | , performMinorGC 24 | 25 | -- * Allocation counter and limits 26 | , setAllocationCounter 27 | , getAllocationCounter 28 | , enableAllocationLimit 29 | , disableAllocationLimit 30 | ) where 31 | 32 | import GHC.Conc.Sync 33 | 34 | -- | Triggers an immediate major garbage collection. 35 | performGC :: IO () 36 | performGC = performMajorGC 37 | 38 | -- | Triggers an immediate major garbage collection. 39 | -- 40 | -- @since 4.7.0.0 41 | foreign import ccall "performMajorGC" performMajorGC :: IO () 42 | 43 | -- | Triggers an immediate minor garbage collection. 44 | -- 45 | -- @since 4.7.0.0 46 | foreign import ccall "performGC" performMinorGC :: IO () 47 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Text/Show.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Safe #-} 2 | {-# LANGUAGE NoImplicitPrelude #-} 3 | 4 | ----------------------------------------------------------------------------- 5 | -- | 6 | -- Module : Text.Show 7 | -- Copyright : (c) The University of Glasgow 2001 8 | -- License : BSD-style (see the file libraries/base/LICENSE) 9 | -- 10 | -- Maintainer : libraries@haskell.org 11 | -- Stability : provisional 12 | -- Portability : portable 13 | -- 14 | -- Converting values to readable strings: 15 | -- the 'Show' class and associated functions. 16 | -- 17 | ----------------------------------------------------------------------------- 18 | 19 | module Text.Show ( 20 | ShowS, 21 | Show(showsPrec, show, showList), 22 | shows, 23 | showChar, 24 | showString, 25 | showParen, 26 | showListWith, 27 | ) where 28 | 29 | import GHC.Show 30 | 31 | -- | Show a list (using square brackets and commas), given a function 32 | -- for showing elements. 33 | showListWith :: (a -> ShowS) -> [a] -> ShowS 34 | showListWith = showList__ 35 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Text/Show/Functions.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Safe #-} 2 | -- This module deliberately declares orphan instances: 3 | {-# OPTIONS_GHC -Wno-orphans #-} 4 | 5 | ----------------------------------------------------------------------------- 6 | -- | 7 | -- Module : Text.Show.Functions 8 | -- Copyright : (c) The University of Glasgow 2001 9 | -- License : BSD-style (see the file libraries/base/LICENSE) 10 | -- 11 | -- Maintainer : libraries@haskell.org 12 | -- Stability : provisional 13 | -- Portability : portable 14 | -- 15 | -- Optional instance of 'Text.Show.Show' for functions: 16 | -- 17 | -- > instance Show (a -> b) where 18 | -- > showsPrec _ _ = showString \"\\" 19 | -- 20 | ----------------------------------------------------------------------------- 21 | 22 | module Text.Show.Functions () where 23 | 24 | -- | @since 2.01 25 | instance Show (a -> b) where 26 | showsPrec _ _ = showString "" 27 | 28 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Type/Reflection.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Trustworthy #-} 2 | {-# LANGUAGE NoImplicitPrelude #-} 3 | {-# LANGUAGE PatternSynonyms #-} 4 | 5 | ----------------------------------------------------------------------------- 6 | -- | 7 | -- Module : Type.Reflection 8 | -- Copyright : (c) The University of Glasgow, CWI 2001--2017 9 | -- License : BSD-style (see the file libraries/base/LICENSE) 10 | -- 11 | -- Maintainer : libraries@haskell.org 12 | -- Stability : experimental 13 | -- Portability : non-portable (requires GADTs and compiler support) 14 | -- 15 | -- This provides a type-indexed type representation mechanism, similar to that 16 | -- described by, 17 | -- 18 | -- * Simon Peyton-Jones, Stephanie Weirich, Richard Eisenberg, 19 | -- Dimitrios Vytiniotis. "A reflection on types." /Proc. Philip Wadler's 60th 20 | -- birthday Festschrift/, Edinburgh (April 2016). 21 | -- 22 | -- The interface provides 'TypeRep', a type representation which can 23 | -- be safely decomposed and composed. See "Data.Dynamic" for an example of this. 24 | -- 25 | -- @since 4.10.0.0 26 | -- 27 | ----------------------------------------------------------------------------- 28 | module Type.Reflection 29 | ( -- * The Typeable class 30 | I.Typeable 31 | , I.typeRep 32 | , I.withTypeable 33 | 34 | -- * Propositional equality 35 | , (:~:)(Refl) 36 | , (:~~:)(HRefl) 37 | 38 | -- * Type representations 39 | -- ** Type-Indexed 40 | , I.TypeRep 41 | , I.typeOf 42 | , pattern I.App, pattern I.Con, pattern I.Con', pattern I.Fun 43 | , I.typeRepTyCon 44 | , I.rnfTypeRep 45 | , I.eqTypeRep 46 | , I.typeRepKind 47 | , I.splitApps 48 | 49 | -- ** Quantified 50 | -- 51 | -- "Data.Typeable" exports a variant of this interface (named differently 52 | -- for backwards compatibility). 53 | , I.SomeTypeRep(..) 54 | , I.someTypeRep 55 | , I.someTypeRepTyCon 56 | , I.rnfSomeTypeRep 57 | 58 | -- * Type constructors 59 | , I.TyCon -- abstract, instance of: Eq, Show, Typeable 60 | -- For now don't export Module, to avoid name clashes 61 | , I.tyConPackage 62 | , I.tyConModule 63 | , I.tyConName 64 | , I.rnfTyCon 65 | 66 | -- * Module names 67 | , I.Module 68 | , I.moduleName, I.modulePackage, I.rnfModule 69 | ) where 70 | 71 | import qualified Data.Typeable.Internal as I 72 | import Data.Type.Equality 73 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Type/Reflection/Unsafe.hs: -------------------------------------------------------------------------------- 1 | ----------------------------------------------------------------------------- 2 | -- | 3 | -- Module : Type.Reflection.Unsafe 4 | -- Copyright : (c) The University of Glasgow, CWI 2001--2015 5 | -- License : BSD-style (see the file libraries/base/LICENSE) 6 | -- 7 | -- The representations of the types 'TyCon' and 'TypeRep', and the function 8 | -- 'mkTyCon' which is used by derived instances of 'Typeable' to construct 9 | -- 'TyCon's. 10 | -- 11 | -- Be warned, these functions can be used to construct ill-kinded 12 | -- type representations. 13 | -- 14 | ----------------------------------------------------------------------------- 15 | {-# LANGUAGE TypeInType, ScopedTypeVariables #-} 16 | 17 | module Type.Reflection.Unsafe ( 18 | -- * Type representations 19 | TypeRep, mkTrApp, mkTyCon, typeRepFingerprint, someTypeRepFingerprint 20 | -- * Kind representations 21 | , KindRep(..), TypeLitSort(..) 22 | -- * Type constructors 23 | , TyCon, mkTrCon, tyConKindRep, tyConKindArgs, tyConFingerprint 24 | ) where 25 | 26 | import Data.Typeable.Internal hiding (mkTrApp) 27 | import qualified Data.Typeable.Internal as TI 28 | 29 | -- | Construct a representation for a type application. 30 | mkTrApp :: forall k1 k2 (a :: k1 -> k2) (b :: k1). 31 | TypeRep (a :: k1 -> k2) 32 | -> TypeRep (b :: k1) 33 | -> TypeRep (a b) 34 | mkTrApp = TI.mkTrAppChecked 35 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/Unsafe/Coerce.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Unsafe #-} 2 | {-# LANGUAGE NoImplicitPrelude, MagicHash #-} 3 | 4 | ----------------------------------------------------------------------------- 5 | -- | 6 | -- Module : Unsafe.Coerce 7 | -- Copyright : Malcolm Wallace 2006 8 | -- License : BSD-style (see the LICENSE file in the distribution) 9 | -- 10 | -- Maintainer : libraries@haskell.org 11 | -- Stability : experimental 12 | -- Portability : portable 13 | -- 14 | -- The highly unsafe primitive 'unsafeCoerce' converts a value from any 15 | -- type to any other type. Needless to say, if you use this function, 16 | -- it is your responsibility to ensure that the old and new types have 17 | -- identical internal representations, in order to prevent runtime corruption. 18 | -- 19 | -- The types for which 'unsafeCoerce' is representation-safe may differ 20 | -- from compiler to compiler (and version to version). 21 | -- 22 | -- * Documentation for correct usage in GHC will be found under 23 | -- 'unsafeCoerce#' in GHC.Base (around which 'unsafeCoerce' is just a 24 | -- trivial wrapper). 25 | -- 26 | -- * In nhc98, the only representation-safe coercions are between Enum 27 | -- types with the same range (e.g. Int, Int32, Char, Word32), 28 | -- or between a newtype and the type that it wraps. 29 | -- 30 | ----------------------------------------------------------------------------- 31 | 32 | module Unsafe.Coerce (unsafeCoerce) where 33 | 34 | import GHC.Integer () -- for build ordering 35 | import GHC.Prim (unsafeCoerce#) 36 | 37 | local_id :: a -> a 38 | local_id x = x -- See Note [Mega-hack for coerce] 39 | 40 | {- Note [Mega-hack for coerce] 41 | 42 | If we just say 43 | unsafeCoerce x = unsafeCoerce# x 44 | then the simple-optimiser that the desugarer runs will eta-reduce to 45 | unsafeCoerce :: forall (a:*) (b:*). a -> b 46 | unsafeCoerce = unsafeCoerce# 47 | But we shouldn't be calling unsafeCoerce# in a higher 48 | order way; it has a compulsory unfolding 49 | unsafeCoerce# a b x = x |> UnsafeCo a b 50 | and we really rely on it being inlined pronto. But the simple-optimiser doesn't. 51 | The identity function local_id delays the eta reduction just long enough 52 | for unsafeCoerce# to get inlined. 53 | 54 | Sigh. This is horrible, but then so is unsafeCoerce. 55 | -} 56 | 57 | unsafeCoerce :: a -> b 58 | unsafeCoerce x = local_id (unsafeCoerce# x) 59 | -- See Note [Unsafe coerce magic] in basicTypes/MkId 60 | -- NB: Do not eta-reduce this definition (see above) 61 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/base.buildinfo: -------------------------------------------------------------------------------- 1 | extra-lib-dirs: 2 | extra-libraries: 3 | include-dirs: 4 | install-includes: HsBaseConfig.h EventConfig.h 5 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/base.buildinfo.in: -------------------------------------------------------------------------------- 1 | extra-lib-dirs: @ICONV_LIB_DIRS@ 2 | extra-libraries: @EXTRA_LIBS@ 3 | include-dirs: @ICONV_INCLUDE_DIRS@ 4 | install-includes: HsBaseConfig.h EventConfig.h 5 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/cbits/DarwinUtils.c: -------------------------------------------------------------------------------- 1 | #include "HsBase.h" 2 | 3 | #if defined(darwin_HOST_OS) || defined(ios_HOST_OS) 4 | #include 5 | 6 | static double scaling_factor = 0.0; 7 | 8 | void initialize_timer() 9 | { 10 | mach_timebase_info_data_t info; 11 | (void) mach_timebase_info(&info); 12 | scaling_factor = (double)info.numer / (double)info.denom; 13 | scaling_factor *= 1e-9; 14 | } 15 | 16 | void absolute_time(double *result) 17 | { 18 | uint64_t time = mach_absolute_time(); 19 | *result = (double)time * scaling_factor; 20 | } 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/cbits/PrelIOUtils.c: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) The University of Glasgow 2002 3 | * 4 | * static versions of the inline functions in HsBase.h 5 | */ 6 | 7 | #define INLINE 8 | 9 | #include "Rts.h" 10 | #include "HsBase.h" 11 | 12 | void errorBelch2(const char*s, char *t) 13 | { 14 | errorBelch(s,t); 15 | } 16 | 17 | void debugBelch2(const char*s, char *t) 18 | { 19 | debugBelch(s,t); 20 | } 21 | 22 | #if defined(HAVE_LIBCHARSET) 23 | # include 24 | #elif defined(HAVE_LANGINFO_H) 25 | # include 26 | #endif 27 | 28 | #if !defined(mingw32_HOST_OS) 29 | const char* localeEncoding(void) 30 | { 31 | #if defined(HAVE_LIBCHARSET) 32 | return locale_charset(); 33 | 34 | #elif defined(HAVE_LANGINFO_H) 35 | return nl_langinfo(CODESET); 36 | 37 | #else 38 | #warning Depending on the unportable behavior of GNU iconv due to absence of both libcharset and langinfo.h 39 | /* GNU iconv accepts "" to mean the current locale's 40 | * encoding. Warning: This isn't portable. 41 | */ 42 | return ""; 43 | #endif 44 | } 45 | #endif 46 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/cbits/SetEnv.c: -------------------------------------------------------------------------------- 1 | #include "HsBase.h" 2 | #if defined(HAVE_UNSETENV) 3 | int __hsbase_unsetenv(const char *name) { 4 | #if defined(UNSETENV_RETURNS_VOID) 5 | unsetenv(name); 6 | return 0; 7 | #else 8 | return unsetenv(name); 9 | #endif 10 | } 11 | #endif 12 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/cbits/consUtils.c: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) The University of Glasgow 2002 3 | * 4 | * Win32 Console API support 5 | */ 6 | #if defined(_WIN32) || defined(__CYGWIN__) 7 | /* to the end */ 8 | 9 | #include "consUtils.h" 10 | #include 11 | #include 12 | 13 | #if defined(__CYGWIN__) 14 | #define _get_osfhandle get_osfhandle 15 | #endif 16 | 17 | int is_console__(int fd) { 18 | DWORD st; 19 | HANDLE h; 20 | if (!_isatty(fd)) { 21 | /* TTY must be a character device */ 22 | return 0; 23 | } 24 | h = (HANDLE)_get_osfhandle(fd); 25 | if (h == INVALID_HANDLE_VALUE) { 26 | /* Broken handle can't be terminal */ 27 | return 0; 28 | } 29 | if (!GetConsoleMode(h, &st)) { 30 | /* GetConsoleMode appears to fail when it's not a TTY. In 31 | particular, it's what most of our terminal functions 32 | assume works, so if it doesn't work for all intents 33 | and purposes we're not dealing with a terminal. */ 34 | return 0; 35 | } 36 | return 1; 37 | } 38 | 39 | 40 | int 41 | set_console_buffering__(int fd, int cooked) 42 | { 43 | HANDLE h; 44 | DWORD st; 45 | /* According to GetConsoleMode() docs, it is not possible to 46 | leave ECHO_INPUT enabled without also having LINE_INPUT, 47 | so we have to turn both off here. */ 48 | DWORD flgs = ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT; 49 | 50 | if ( (h = (HANDLE)_get_osfhandle(fd)) != INVALID_HANDLE_VALUE ) { 51 | if ( GetConsoleMode(h,&st) && 52 | SetConsoleMode(h, cooked ? (st | ENABLE_LINE_INPUT) : st & ~flgs) ) { 53 | return 0; 54 | } 55 | } 56 | return -1; 57 | } 58 | 59 | int 60 | set_console_echo__(int fd, int on) 61 | { 62 | HANDLE h; 63 | DWORD st; 64 | DWORD flgs = ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT; 65 | 66 | if ( (h = (HANDLE)_get_osfhandle(fd)) != INVALID_HANDLE_VALUE ) { 67 | if ( GetConsoleMode(h,&st) && 68 | SetConsoleMode(h,( on ? (st | flgs) : (st & ~ENABLE_ECHO_INPUT))) ) { 69 | return 0; 70 | } 71 | } 72 | return -1; 73 | } 74 | 75 | int 76 | get_console_echo__(int fd) 77 | { 78 | HANDLE h; 79 | DWORD st; 80 | 81 | if ( (h = (HANDLE)_get_osfhandle(fd)) != INVALID_HANDLE_VALUE ) { 82 | if ( GetConsoleMode(h,&st) ) { 83 | return (st & ENABLE_ECHO_INPUT ? 1 : 0); 84 | } 85 | } 86 | return -1; 87 | } 88 | 89 | int 90 | flush_input_console__(int fd) 91 | { 92 | HANDLE h = (HANDLE)_get_osfhandle(fd); 93 | 94 | if ( h != INVALID_HANDLE_VALUE ) { 95 | /* If the 'fd' isn't connected to a console; treat the flush 96 | * operation as a NOP. 97 | */ 98 | DWORD unused; 99 | if ( !GetConsoleMode(h,&unused) && 100 | GetLastError() == ERROR_INVALID_HANDLE ) { 101 | return 0; 102 | } 103 | if ( FlushConsoleInputBuffer(h) ) { 104 | return 0; 105 | } 106 | } 107 | /* ToDo: translate GetLastError() into something errno-friendly */ 108 | return -1; 109 | } 110 | 111 | #endif /* defined(_WIN32) || ... */ 112 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/cbits/iconv.c: -------------------------------------------------------------------------------- 1 | #if !defined(_WIN32) 2 | 3 | #include 4 | #include 5 | 6 | iconv_t hs_iconv_open(const char* tocode, 7 | const char* fromcode) 8 | { 9 | return iconv_open(tocode, fromcode); 10 | } 11 | 12 | size_t hs_iconv(iconv_t cd, 13 | const char* * inbuf, size_t * inbytesleft, 14 | char* * outbuf, size_t * outbytesleft) 15 | { 16 | // (void*) cast avoids a warning. Some iconvs use (const 17 | // char**inbuf), other use (char **inbuf). 18 | return iconv(cd, (void*)inbuf, inbytesleft, outbuf, outbytesleft); 19 | } 20 | 21 | int hs_iconv_close(iconv_t cd) { 22 | return iconv_close(cd); 23 | } 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/cbits/sysconf.c: -------------------------------------------------------------------------------- 1 | #include "HsBaseConfig.h" 2 | 3 | /* For _SC_CLK_TCK */ 4 | #if HAVE_UNISTD_H 5 | #include 6 | #endif 7 | 8 | /* for CLK_TCK */ 9 | #if HAVE_TIME_H 10 | #include 11 | #endif 12 | 13 | long clk_tck(void) { 14 | #if defined(CLK_TCK) 15 | return (CLK_TCK); 16 | #else 17 | return sysconf(_SC_CLK_TCK); 18 | #endif 19 | } 20 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/include/CTypes.h: -------------------------------------------------------------------------------- 1 | {- -------------------------------------------------------------------------- 2 | // Dirty CPP hackery for CTypes/CTypesISO 3 | // 4 | // (c) The FFI task force, 2000 5 | // -------------------------------------------------------------------------- 6 | -} 7 | 8 | #pragma once 9 | 10 | {- 11 | // As long as there is no automatic derivation of classes for newtypes we resort 12 | // to extremely dirty cpp-hackery. :-P Some care has to be taken when the 13 | // macros below are modified, otherwise the layout rule will bite you. 14 | -} 15 | 16 | -- // GHC can derive any class for a newtype, so we make use of that here... 17 | 18 | #define ARITHMETIC_CLASSES Eq,Ord,Num,Enum,Storable,Real 19 | #define INTEGRAL_CLASSES Bounded,Integral,Bits,FiniteBits 20 | #define FLOATING_CLASSES Fractional,Floating,RealFrac,RealFloat 21 | #define OPAQUE_CLASSES Eq,Ord,Storable 22 | 23 | #define ARITHMETIC_TYPE(T,B) \ 24 | newtype T = T B deriving (ARITHMETIC_CLASSES) \ 25 | deriving newtype (Read, Show); 26 | 27 | #define INTEGRAL_TYPE(T,B) \ 28 | newtype T = T B deriving (ARITHMETIC_CLASSES, INTEGRAL_CLASSES) \ 29 | deriving newtype (Read, Show); 30 | 31 | #define INTEGRAL_TYPE_WITH_CTYPE(T,THE_CTYPE,B) \ 32 | newtype {-# CTYPE "THE_CTYPE" #-} T = T B \ 33 | deriving (ARITHMETIC_CLASSES, INTEGRAL_CLASSES) \ 34 | deriving newtype (Read, Show); 35 | 36 | #define FLOATING_TYPE(T,B) \ 37 | newtype T = T B deriving (ARITHMETIC_CLASSES, FLOATING_CLASSES) \ 38 | deriving newtype (Read, Show); 39 | 40 | #define FLOATING_TYPE_WITH_CTYPE(T,THE_CTYPE,B) \ 41 | newtype {-# CTYPE "THE_CTYPE" #-} T = T B \ 42 | deriving (ARITHMETIC_CLASSES, FLOATING_CLASSES) \ 43 | deriving newtype (Read, Show); 44 | 45 | #define OPAQUE_TYPE_WITH_CTYPE(T,THE_CTYPE,B) \ 46 | newtype {-# CTYPE "THE_CTYPE" #-} T = T (B) \ 47 | deriving (OPAQUE_CLASSES) \ 48 | deriving newtype Show; 49 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/include/EventConfig.h.in: -------------------------------------------------------------------------------- 1 | /* include/EventConfig.h.in. Generated from configure.ac by autoheader. */ 2 | 3 | /* Define if you have epoll support. */ 4 | #undef HAVE_EPOLL 5 | 6 | /* Define to 1 if you have the `epoll_create1' function. */ 7 | #undef HAVE_EPOLL_CREATE1 8 | 9 | /* Define to 1 if you have the `epoll_ctl' function. */ 10 | #undef HAVE_EPOLL_CTL 11 | 12 | /* Define to 1 if you have the `eventfd' function. */ 13 | #undef HAVE_EVENTFD 14 | 15 | /* Define to 1 if you have the header file. */ 16 | #undef HAVE_INTTYPES_H 17 | 18 | /* Define to 1 if you have the `kevent' function. */ 19 | #undef HAVE_KEVENT 20 | 21 | /* Define to 1 if you have the `kevent64' function. */ 22 | #undef HAVE_KEVENT64 23 | 24 | /* Define if you have kqueue support. */ 25 | #undef HAVE_KQUEUE 26 | 27 | /* Define to 1 if you have the header file. */ 28 | #undef HAVE_MEMORY_H 29 | 30 | /* Define if you have poll support. */ 31 | #undef HAVE_POLL 32 | 33 | /* Define to 1 if you have the header file. */ 34 | #undef HAVE_POLL_H 35 | 36 | /* Define to 1 if you have the header file. */ 37 | #undef HAVE_SIGNAL_H 38 | 39 | /* Define to 1 if you have the header file. */ 40 | #undef HAVE_STDINT_H 41 | 42 | /* Define to 1 if you have the header file. */ 43 | #undef HAVE_STDLIB_H 44 | 45 | /* Define to 1 if you have the header file. */ 46 | #undef HAVE_STRINGS_H 47 | 48 | /* Define to 1 if you have the header file. */ 49 | #undef HAVE_STRING_H 50 | 51 | /* Define to 1 if you have the header file. */ 52 | #undef HAVE_SYS_EPOLL_H 53 | 54 | /* Define to 1 if you have the header file. */ 55 | #undef HAVE_SYS_EVENTFD_H 56 | 57 | /* Define to 1 if you have the header file. */ 58 | #undef HAVE_SYS_EVENT_H 59 | 60 | /* Define to 1 if you have the header file. */ 61 | #undef HAVE_SYS_STAT_H 62 | 63 | /* Define to 1 if you have the header file. */ 64 | #undef HAVE_SYS_TYPES_H 65 | 66 | /* Define to 1 if you have the header file. */ 67 | #undef HAVE_UNISTD_H 68 | 69 | /* Define to the address where bug reports for this package should be sent. */ 70 | #undef PACKAGE_BUGREPORT 71 | 72 | /* Define to the full name of this package. */ 73 | #undef PACKAGE_NAME 74 | 75 | /* Define to the full name and version of this package. */ 76 | #undef PACKAGE_STRING 77 | 78 | /* Define to the one symbol short name of this package. */ 79 | #undef PACKAGE_TARNAME 80 | 81 | /* Define to the version of this package. */ 82 | #undef PACKAGE_VERSION 83 | 84 | /* Define to 1 if you have the ANSI C header files. */ 85 | #undef STDC_HEADERS 86 | 87 | /* The size of `kev.filter', as computed by sizeof. */ 88 | #undef SIZEOF_KEV_FILTER 89 | 90 | /* The size of `kev.flags', as computed by sizeof. */ 91 | #undef SIZEOF_KEV_FLAGS 92 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/include/WCsubst.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "HsFFI.h" 4 | #include 5 | 6 | HsInt u_iswupper(HsInt wc); 7 | HsInt u_iswdigit(HsInt wc); 8 | HsInt u_iswalpha(HsInt wc); 9 | HsInt u_iswcntrl(HsInt wc); 10 | HsInt u_iswspace(HsInt wc); 11 | HsInt u_iswprint(HsInt wc); 12 | HsInt u_iswlower(HsInt wc); 13 | 14 | HsInt u_iswalnum(HsInt wc); 15 | 16 | HsInt u_towlower(HsInt wc); 17 | HsInt u_towupper(HsInt wc); 18 | HsInt u_towtitle(HsInt wc); 19 | 20 | HsInt u_gencat(HsInt wc); 21 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/include/consUtils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) The University of Glasgow, 2000-2002 3 | * 4 | * Win32 Console API helpers. 5 | */ 6 | #pragma once 7 | 8 | extern int is_console__(int fd); 9 | extern int set_console_buffering__(int fd, int cooked); 10 | extern int set_console_echo__(int fd, int on); 11 | extern int get_console_echo__(int fd); 12 | extern int flush_input_console__ (int fd); 13 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/include/ieee-flpt.h: -------------------------------------------------------------------------------- 1 | /* this file is #included into both C (.c and .hc) and Haskell files */ 2 | 3 | /* IEEE format floating-point */ 4 | #define IEEE_FLOATING_POINT 1 5 | 6 | /* Radix of exponent representation */ 7 | #if !defined(FLT_RADIX) 8 | # define FLT_RADIX 2 9 | #endif 10 | 11 | /* Number of base-FLT_RADIX digits in the significand of a float */ 12 | #if !defined(FLT_MANT_DIG) 13 | # define FLT_MANT_DIG 24 14 | #endif 15 | /* Minimum int x such that FLT_RADIX**(x-1) is a normalised float */ 16 | #if !defined(FLT_MIN_EXP) 17 | # define FLT_MIN_EXP (-125) 18 | #endif 19 | /* Maximum int x such that FLT_RADIX**(x-1) is a representable float */ 20 | #if !defined(FLT_MAX_EXP) 21 | # define FLT_MAX_EXP 128 22 | #endif 23 | 24 | /* Number of base-FLT_RADIX digits in the significand of a double */ 25 | #if !defined(DBL_MANT_DIG) 26 | # define DBL_MANT_DIG 53 27 | #endif 28 | /* Minimum int x such that FLT_RADIX**(x-1) is a normalised double */ 29 | #if !defined(DBL_MIN_EXP) 30 | # define DBL_MIN_EXP (-1021) 31 | #endif 32 | /* Maximum int x such that FLT_RADIX**(x-1) is a representable double */ 33 | #if !defined(DBL_MAX_EXP) 34 | # define DBL_MAX_EXP 1024 35 | #endif 36 | -------------------------------------------------------------------------------- /prana-boot/packages/base-4.11.1.0/include/md5.h: -------------------------------------------------------------------------------- 1 | /* MD5 message digest */ 2 | #pragma once 3 | 4 | #include "HsFFI.h" 5 | 6 | typedef HsWord32 word32; 7 | typedef HsWord8 byte; 8 | 9 | struct MD5Context { 10 | word32 buf[4]; 11 | word32 bytes[2]; 12 | word32 in[16]; 13 | }; 14 | 15 | void __hsbase_MD5Init(struct MD5Context *context); 16 | void __hsbase_MD5Update(struct MD5Context *context, byte const *buf, int len); 17 | void __hsbase_MD5Final(byte digest[16], struct MD5Context *context); 18 | void __hsbase_MD5Transform(word32 buf[4], word32 const in[16]); 19 | -------------------------------------------------------------------------------- /prana-boot/packages/ghc-prim-0.5.2.0/GHC/Debug.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE Trustworthy #-} 2 | {-# LANGUAGE MagicHash, NoImplicitPrelude, UnboxedTuples, UnliftedFFITypes #-} 3 | 4 | module GHC.Debug ( debugLn, debugErrLn ) where 5 | 6 | import GHC.Prim 7 | import GHC.Types 8 | import GHC.Tuple () 9 | 10 | debugLn :: [Char] -> IO () 11 | debugLn xs = IO (\s0 -> 12 | case mkMBA s0 xs of 13 | (# s1, mba #) -> 14 | case c_debugLn mba of 15 | IO f -> f s1) 16 | 17 | debugErrLn :: [Char] -> IO () 18 | debugErrLn xs = IO (\s0 -> 19 | case mkMBA s0 xs of 20 | (# s1, mba #) -> 21 | case c_debugErrLn mba of 22 | IO f -> f s1) 23 | 24 | foreign import ccall unsafe "debugLn" 25 | c_debugLn :: MutableByteArray# RealWorld -> IO () 26 | 27 | foreign import ccall unsafe "debugErrLn" 28 | c_debugErrLn :: MutableByteArray# RealWorld -> IO () 29 | 30 | mkMBA :: State# RealWorld -> [Char] -> 31 | (# State# RealWorld, MutableByteArray# RealWorld #) 32 | mkMBA s0 xs = -- Start with 1 so that we have space to put in a \0 at 33 | -- the end 34 | case len 1# xs of 35 | l -> 36 | case newByteArray# l s0 of 37 | (# s1, mba #) -> 38 | case write mba 0# xs s1 of 39 | s2 -> (# s2, mba #) 40 | where len l [] = l 41 | len l (_ : xs') = len (l +# 1#) xs' 42 | 43 | write mba offset [] s = writeCharArray# mba offset '\0'# s 44 | write mba offset (C# x : xs') s 45 | = case writeCharArray# mba offset x s of 46 | s' -> 47 | write mba (offset +# 1#) xs' s' 48 | 49 | -------------------------------------------------------------------------------- /prana-boot/packages/ghc-prim-0.5.2.0/LICENSE: -------------------------------------------------------------------------------- 1 | This library (libraries/ghc-prim) is derived from code from several 2 | sources: 3 | 4 | * Code from the GHC project which is largely (c) The University of 5 | Glasgow, and distributable under a BSD-style license (see below), 6 | 7 | * Code from the Haskell 98 Report which is (c) Simon Peyton Jones 8 | and freely redistributable (but see the full license for 9 | restrictions). 10 | 11 | The full text of these licenses is reproduced below. All of the 12 | licenses are BSD-style or compatible. 13 | 14 | ----------------------------------------------------------------------------- 15 | 16 | The Glasgow Haskell Compiler License 17 | 18 | Copyright 2004, The University Court of the University of Glasgow. 19 | All rights reserved. 20 | 21 | Redistribution and use in source and binary forms, with or without 22 | modification, are permitted provided that the following conditions are met: 23 | 24 | - Redistributions of source code must retain the above copyright notice, 25 | this list of conditions and the following disclaimer. 26 | 27 | - Redistributions in binary form must reproduce the above copyright notice, 28 | this list of conditions and the following disclaimer in the documentation 29 | and/or other materials provided with the distribution. 30 | 31 | - Neither name of the University nor the names of its contributors may be 32 | used to endorse or promote products derived from this software without 33 | specific prior written permission. 34 | 35 | THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY COURT OF THE UNIVERSITY OF 36 | GLASGOW AND THE CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 37 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 38 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 39 | UNIVERSITY COURT OF THE UNIVERSITY OF GLASGOW OR THE CONTRIBUTORS BE LIABLE 40 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 41 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 42 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 43 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 44 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 45 | OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 46 | DAMAGE. 47 | 48 | ----------------------------------------------------------------------------- 49 | 50 | Code derived from the document "Report on the Programming Language 51 | Haskell 98", is distributed under the following license: 52 | 53 | Copyright (c) 2002 Simon Peyton Jones 54 | 55 | The authors intend this Report to belong to the entire Haskell 56 | community, and so we grant permission to copy and distribute it for 57 | any purpose, provided that it is reproduced in its entirety, 58 | including this Notice. Modified versions of this Report may also be 59 | copied and distributed for any purpose, provided that the modified 60 | version is clearly presented as such, and that it does not claim to 61 | be a definition of the Haskell 98 Language. 62 | 63 | -------------------------------------------------------------------------------- /prana-boot/packages/ghc-prim-0.5.2.0/cbits/bswap.c: -------------------------------------------------------------------------------- 1 | #include "Rts.h" 2 | 3 | extern StgWord16 hs_bswap16(StgWord16 x); 4 | StgWord16 5 | hs_bswap16(StgWord16 x) 6 | { 7 | return ((x >> 8) | (x << 8)); 8 | } 9 | 10 | extern StgWord32 hs_bswap32(StgWord32 x); 11 | StgWord32 12 | hs_bswap32(StgWord32 x) 13 | { 14 | return ((x >> 24) | ((x >> 8) & 0xff00) | 15 | (x << 24) | ((x & 0xff00) << 8)); 16 | } 17 | 18 | extern StgWord64 hs_bswap64(StgWord64 x); 19 | StgWord64 20 | hs_bswap64(StgWord64 x) 21 | { 22 | return ( (x >> 56) | (x << 56) 23 | | ((x >> 40) & 0xff00) | ((x & 0xff00) << 40) 24 | | ((x >> 24) & 0xff0000) | ((x & 0xff0000) << 24) 25 | | ((x >> 8) & 0xff000000) | ((x & 0xff000000) << 8) 26 | ); 27 | } 28 | -------------------------------------------------------------------------------- /prana-boot/packages/ghc-prim-0.5.2.0/cbits/clz.c: -------------------------------------------------------------------------------- 1 | #include "MachDeps.h" 2 | #include "Rts.h" 3 | #include 4 | 5 | // Fall-back implementations for count-leading-zeros primop 6 | // 7 | // __builtin_clz*() is supported by GCC and Clang 8 | 9 | #if SIZEOF_UNSIGNED_INT == 4 10 | StgWord 11 | hs_clz8(StgWord x) 12 | { 13 | return (uint8_t)x ? __builtin_clz((uint8_t)x)-24 : 8; 14 | } 15 | 16 | StgWord 17 | hs_clz16(StgWord x) 18 | { 19 | return (uint16_t)x ? __builtin_clz((uint16_t)x)-16 : 16; 20 | } 21 | 22 | StgWord 23 | hs_clz32(StgWord x) 24 | { 25 | return (uint32_t)x ? __builtin_clz((uint32_t)x) : 32; 26 | } 27 | #else 28 | # error no suitable __builtin_clz() found 29 | #endif 30 | 31 | StgWord 32 | hs_clz64(StgWord64 x) 33 | { 34 | #if SIZEOF_UNSIGNED_LONG == 8 35 | return x ? __builtin_clzl(x) : 64; 36 | #elif SIZEOF_UNSIGNED_LONG_LONG == 8 37 | return x ? __builtin_clzll(x) : 64; 38 | #else 39 | # error no suitable __builtin_clz() found 40 | #endif 41 | } 42 | -------------------------------------------------------------------------------- /prana-boot/packages/ghc-prim-0.5.2.0/cbits/ctz.c: -------------------------------------------------------------------------------- 1 | #include "MachDeps.h" 2 | #include "Rts.h" 3 | #include 4 | 5 | // Fall-back implementations for count-trailing-zeros primop 6 | // 7 | // __builtin_ctz*() is supported by GCC and Clang 8 | 9 | #if SIZEOF_UNSIGNED_INT == 4 10 | StgWord 11 | hs_ctz8(StgWord x) 12 | { 13 | return (uint8_t)x ? __builtin_ctz(x) : 8; 14 | } 15 | 16 | StgWord 17 | hs_ctz16(StgWord x) 18 | { 19 | return (uint16_t)x ? __builtin_ctz(x) : 16; 20 | } 21 | 22 | StgWord 23 | hs_ctz32(StgWord x) 24 | { 25 | return (uint32_t)x ? __builtin_ctz(x) : 32; 26 | } 27 | #else 28 | # error no suitable __builtin_ctz() found 29 | #endif 30 | 31 | StgWord 32 | hs_ctz64(StgWord64 x) 33 | { 34 | #if defined(__GNUC__) && (defined(i386_HOST_ARCH) || defined(powerpc_HOST_ARCH)) 35 | /* On Linux/i386, the 64bit `__builtin_ctzll()` instrinsic doesn't 36 | get inlined by GCC but rather a short `__ctzdi2` runtime function 37 | is inserted when needed into compiled object files. 38 | 39 | This workaround forces GCC on 32bit x86 to to express `hs_ctz64` in 40 | terms of the 32bit `__builtin_ctz()` (this is no loss, as there's no 41 | 64bit BSF instruction on i686 anyway) and thus avoid the problematic 42 | out-of-line runtime function. 43 | */ 44 | 45 | if (!x) return 64; 46 | 47 | return ((uint32_t)x ? __builtin_ctz((uint32_t)x) 48 | : (__builtin_ctz(x >> 32) + 32)); 49 | 50 | #elif SIZEOF_UNSIGNED_LONG == 8 51 | return x ? __builtin_ctzl(x) : 64; 52 | #elif SIZEOF_UNSIGNED_LONG_LONG == 8 53 | return x ? __builtin_ctzll(x) : 64; 54 | #else 55 | # error no suitable __builtin_ctz() found 56 | #endif 57 | } 58 | -------------------------------------------------------------------------------- /prana-boot/packages/ghc-prim-0.5.2.0/cbits/debug.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | void debugLn(char *s) { 5 | printf("%s\n", s); 6 | } 7 | 8 | void debugErrLn(char *s) { 9 | fprintf(stderr, "%s\n", s); 10 | } 11 | -------------------------------------------------------------------------------- /prana-boot/packages/ghc-prim-0.5.2.0/cbits/pdep.c: -------------------------------------------------------------------------------- 1 | #include "Rts.h" 2 | #include "MachDeps.h" 3 | 4 | extern StgWord64 hs_pdep64(StgWord64 src, StgWord64 mask); 5 | 6 | StgWord64 7 | hs_pdep64(StgWord64 src, StgWord64 mask) 8 | { 9 | uint64_t result = 0; 10 | 11 | while (1) { 12 | // Mask out all but the lowest bit 13 | const uint64_t lowest = (-mask & mask); 14 | 15 | if (lowest == 0) { 16 | break; 17 | } 18 | 19 | const uint64_t lsb = (uint64_t)((int64_t)(src << 63) >> 63); 20 | 21 | result |= lsb & lowest; 22 | mask &= ~lowest; 23 | src >>= 1; 24 | } 25 | 26 | return result; 27 | } 28 | 29 | extern StgWord hs_pdep32(StgWord src, StgWord mask); 30 | StgWord 31 | hs_pdep32(StgWord src, StgWord mask) 32 | { 33 | return hs_pdep64(src, mask); 34 | } 35 | 36 | extern StgWord hs_pdep16(StgWord src, StgWord mask); 37 | StgWord 38 | hs_pdep16(StgWord src, StgWord mask) 39 | { 40 | return hs_pdep64(src, mask); 41 | } 42 | 43 | extern StgWord hs_pdep8(StgWord src, StgWord mask); 44 | StgWord 45 | hs_pdep8(StgWord src, StgWord mask) 46 | { 47 | return hs_pdep64(src, mask); 48 | } 49 | -------------------------------------------------------------------------------- /prana-boot/packages/ghc-prim-0.5.2.0/cbits/pext.c: -------------------------------------------------------------------------------- 1 | #include "Rts.h" 2 | #include "MachDeps.h" 3 | 4 | extern StgWord64 hs_pext64(StgWord64 src, StgWord64 mask); 5 | 6 | StgWord64 7 | hs_pext64(StgWord64 src, StgWord64 mask) 8 | { 9 | uint64_t result = 0; 10 | int offset = 0; 11 | 12 | for (int bit = 0; bit != sizeof(uint64_t) * 8; ++bit) { 13 | const uint64_t src_bit = (src >> bit) & 1; 14 | const uint64_t mask_bit = (mask >> bit) & 1; 15 | 16 | if (mask_bit) { 17 | result |= (uint64_t)(src_bit) << offset; 18 | ++offset; 19 | } 20 | } 21 | 22 | return result; 23 | } 24 | 25 | extern StgWord hs_pext32(StgWord src, StgWord mask); 26 | StgWord 27 | hs_pext32(StgWord src, StgWord mask) 28 | { 29 | return hs_pext64(src, mask); 30 | } 31 | 32 | extern StgWord hs_pext16(StgWord src, StgWord mask); 33 | StgWord 34 | hs_pext16(StgWord src, StgWord mask) 35 | { 36 | return hs_pext64(src, mask); 37 | } 38 | 39 | extern StgWord hs_pext8(StgWord src, StgWord mask); 40 | StgWord 41 | hs_pext8(StgWord src, StgWord mask) 42 | { 43 | return hs_pext64(src, mask); 44 | } 45 | -------------------------------------------------------------------------------- /prana-boot/packages/ghc-prim-0.5.2.0/cbits/popcnt.c: -------------------------------------------------------------------------------- 1 | #include "Rts.h" 2 | #include "MachDeps.h" 3 | 4 | static const unsigned char popcount_tab[] = 5 | { 6 | 0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5, 7 | 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6, 8 | 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6, 9 | 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7, 10 | 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6, 11 | 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7, 12 | 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7, 13 | 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8, 14 | }; 15 | 16 | extern StgWord hs_popcnt8(StgWord x); 17 | StgWord 18 | hs_popcnt8(StgWord x) 19 | { 20 | return popcount_tab[(unsigned char)x]; 21 | } 22 | 23 | extern StgWord hs_popcnt16(StgWord x); 24 | StgWord 25 | hs_popcnt16(StgWord x) 26 | { 27 | return popcount_tab[(unsigned char)x] + 28 | popcount_tab[(unsigned char)(x >> 8)]; 29 | } 30 | 31 | extern StgWord hs_popcnt32(StgWord x); 32 | StgWord 33 | hs_popcnt32(StgWord x) 34 | { 35 | return popcount_tab[(unsigned char)x] + 36 | popcount_tab[(unsigned char)(x >> 8)] + 37 | popcount_tab[(unsigned char)(x >> 16)] + 38 | popcount_tab[(unsigned char)(x >> 24)]; 39 | } 40 | 41 | extern StgWord hs_popcnt64(StgWord64 x); 42 | StgWord 43 | hs_popcnt64(StgWord64 x) 44 | { 45 | return popcount_tab[(unsigned char)x] + 46 | popcount_tab[(unsigned char)(x >> 8)] + 47 | popcount_tab[(unsigned char)(x >> 16)] + 48 | popcount_tab[(unsigned char)(x >> 24)] + 49 | popcount_tab[(unsigned char)(x >> 32)] + 50 | popcount_tab[(unsigned char)(x >> 40)] + 51 | popcount_tab[(unsigned char)(x >> 48)] + 52 | popcount_tab[(unsigned char)(x >> 56)]; 53 | } 54 | 55 | #if WORD_SIZE_IN_BITS == 32 56 | 57 | extern StgWord hs_popcnt(StgWord x); 58 | StgWord 59 | hs_popcnt(StgWord x) 60 | { 61 | return popcount_tab[(unsigned char)x] + 62 | popcount_tab[(unsigned char)(x >> 8)] + 63 | popcount_tab[(unsigned char)(x >> 16)] + 64 | popcount_tab[(unsigned char)(x >> 24)]; 65 | } 66 | 67 | #elif WORD_SIZE_IN_BITS == 64 68 | 69 | extern StgWord hs_popcnt(StgWord x); 70 | StgWord 71 | hs_popcnt(StgWord x) 72 | { 73 | return popcount_tab[(unsigned char)x] + 74 | popcount_tab[(unsigned char)(x >> 8)] + 75 | popcount_tab[(unsigned char)(x >> 16)] + 76 | popcount_tab[(unsigned char)(x >> 24)] + 77 | popcount_tab[(unsigned char)(x >> 32)] + 78 | popcount_tab[(unsigned char)(x >> 40)] + 79 | popcount_tab[(unsigned char)(x >> 48)] + 80 | popcount_tab[(unsigned char)(x >> 56)]; 81 | } 82 | 83 | #else 84 | 85 | #error Unknown machine word size 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /prana-boot/packages/ghc-prim-0.5.2.0/cbits/word2float.c: -------------------------------------------------------------------------------- 1 | #include "Rts.h" 2 | 3 | extern StgFloat hs_word2float32(StgWord x); 4 | StgFloat 5 | hs_word2float32(StgWord x) 6 | { 7 | return x; 8 | } 9 | 10 | extern StgDouble hs_word2float64(StgWord x); 11 | StgDouble 12 | hs_word2float64(StgWord x) 13 | { 14 | return x; 15 | } 16 | -------------------------------------------------------------------------------- /prana-boot/packages/ghc-prim-0.5.2.0/ghc-prim.cabal: -------------------------------------------------------------------------------- 1 | cabal-version: 2.2 2 | name: ghc-prim 3 | version: 0.5.2.0 4 | 5 | license: BSD-3-Clause 6 | license-file: LICENSE 7 | category: GHC 8 | maintainer: libraries@haskell.org 9 | bug-reports: http://ghc.haskell.org/trac/ghc/newticket?component=libraries%20%28other%29&keywords=ghc-prim 10 | synopsis: GHC primitives 11 | build-type: Simple 12 | description: 13 | This package contains the primitive types and operations supplied by GHC. 14 | 15 | extra-source-files: changelog.md 16 | 17 | source-repository head 18 | type: git 19 | location: http://git.haskell.org/ghc.git 20 | subdir: libraries/ghc-prim 21 | 22 | Library 23 | default-language: Haskell2010 24 | other-extensions: 25 | BangPatterns 26 | CPP 27 | DeriveGeneric 28 | MagicHash 29 | MultiParamTypeClasses 30 | NoImplicitPrelude 31 | StandaloneDeriving 32 | Trustworthy 33 | TypeFamilies 34 | UnboxedTuples 35 | UnliftedFFITypes 36 | 37 | build-depends: rts == 1.0.* 38 | 39 | exposed-modules: 40 | GHC.CString 41 | GHC.Classes 42 | GHC.Debug 43 | GHC.IntWord64 44 | GHC.Magic 45 | GHC.PrimopWrappers 46 | GHC.Tuple 47 | GHC.Types 48 | -- GHC.Prim 49 | 50 | virtual-modules: 51 | GHC.Prim 52 | 53 | -- OS Specific 54 | if os(windows) 55 | -- Windows requires some extra libraries for linking because the RTS 56 | -- is no longer re-exporting them (see #11223) 57 | -- msvcrt: standard C library. The RTS will automatically include this, 58 | -- but is added for completeness. 59 | -- mingwex: provides C99 compatibility. libm is a stub on MingW. 60 | -- mingw32: Unfortunately required because of a resource leak between 61 | -- mingwex and mingw32. the __math_err symbol is defined in 62 | -- mingw32 which is required by mingwex. 63 | -- user32: provides access to apis to modify user components (UI etc) 64 | -- on Windows. Required because of mingw32. 65 | extra-libraries: user32, mingw32, mingwex 66 | 67 | c-sources: 68 | cbits/atomic.c 69 | cbits/bswap.c 70 | cbits/clz.c 71 | cbits/ctz.c 72 | cbits/debug.c 73 | cbits/longlong.c 74 | cbits/pdep.c 75 | cbits/pext.c 76 | cbits/popcnt.c 77 | cbits/word2float.c 78 | 79 | -- We need to set the unit ID to ghc-prim (without a version number) 80 | -- as it's magic. 81 | ghc-options: -this-unit-id ghc-prim 82 | -------------------------------------------------------------------------------- /prana-boot/packages/integer-gmp-1.0.2.0/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014, Herbert Valerio Riedel 2 | 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | * Redistributions in binary form must reproduce the above 12 | copyright notice, this list of conditions and the following 13 | disclaimer in the documentation and/or other materials provided 14 | with the distribution. 15 | 16 | * Neither the name of Herbert Valerio Riedel nor the names of other 17 | contributors may be used to endorse or promote products derived 18 | from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | -------------------------------------------------------------------------------- /prana-boot/packages/integer-gmp-1.0.2.0/Setup.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | import Distribution.Simple 4 | 5 | main :: IO () 6 | main = defaultMainWithHooks autoconfUserHooks 7 | -------------------------------------------------------------------------------- /prana-boot/packages/integer-gmp-1.0.2.0/aclocal.m4: -------------------------------------------------------------------------------- 1 | 2 | dnl-------------------------------------------------------------------- 3 | dnl * Check whether this machine has gmp/gmp3 installed 4 | dnl-------------------------------------------------------------------- 5 | 6 | AC_DEFUN([LOOK_FOR_GMP_LIB],[ 7 | if test "$HaveFrameworkGMP" = "NO" 8 | then 9 | AC_CHECK_LIB([gmp], [__gmpz_powm], 10 | [HaveLibGmp=YES; GMP_LIBS=gmp]) 11 | if test "$HaveLibGmp" = "NO" 12 | then 13 | AC_CHECK_LIB([gmp3], [__gmpz_powm], 14 | [HaveLibGmp=YES; GMP_LIBS=gmp3]) 15 | fi 16 | if test "$HaveLibGmp" = "YES" 17 | then 18 | AC_CHECK_LIB([$GMP_LIBS], [__gmpz_powm_sec], 19 | [HaveSecurePowm=1]) 20 | fi 21 | fi 22 | ]) 23 | 24 | dnl-------------------------------------------------------------------- 25 | dnl * Mac OS X only: check for GMP.framework 26 | dnl-------------------------------------------------------------------- 27 | 28 | AC_DEFUN([LOOK_FOR_GMP_FRAMEWORK],[ 29 | if test "$HaveLibGmp" = "NO" 30 | then 31 | case $target_os in 32 | darwin*) 33 | AC_MSG_CHECKING([for GMP.framework]) 34 | save_libs="$LIBS" 35 | LIBS="-framework GMP" 36 | AC_TRY_LINK_FUNC(__gmpz_powm_sec, 37 | [HaveFrameworkGMP=YES; GMP_FRAMEWORK=GMP]) 38 | LIBS="$save_libs" 39 | AC_MSG_RESULT([$HaveFrameworkGMP]) 40 | ;; 41 | esac 42 | fi 43 | ]) 44 | 45 | -------------------------------------------------------------------------------- /prana-boot/packages/integer-gmp-1.0.2.0/changelog.md: -------------------------------------------------------------------------------- 1 | # Changelog for [`integer-gmp` package](http://hackage.haskell.org/package/integer-gmp) 2 | 3 | ## 1.0.2.0 *April 2018* 4 | 5 | * Bundled with GHC 8.4.2 6 | 7 | * Define `powModSecInteger`, a "secure" version of `powModInteger` using the 8 | `mpz_powm_sec` function. 9 | 10 | ## 1.0.1.0 *July 2017* 11 | 12 | * Bundled with GHC 8.2.1 13 | 14 | * Optimize `minusInteger` 15 | 16 | * Fix the right-shift operation for negative big integers (fixes GHC #12136) 17 | 18 | * Make operations more strict 19 | 20 | ## 1.0.0.1 *Feb 2016* 21 | 22 | * Bundled with GHC 8.0.1 23 | 24 | * Optimise `bitBigNat`/`bigInteger` 25 | 26 | * Fix minor issue in `eqBigNatWord#` 27 | 28 | * Various minor optimisations 29 | 30 | ## 1.0.0.0 *Mar 2015* 31 | 32 | * Bundled with GHC 7.10.1 33 | 34 | * Complete rewrite of `integer-gmp`. For more details, see 35 | https://ghc.haskell.org/trac/ghc/wiki/Design/IntegerGmp2 36 | 37 | ## 0.5.1.0 *Feb 2014* 38 | 39 | * Bundled with GHC 7.8.1 40 | 41 | * Improved Haddock documentation 42 | 43 | * New [PrimBool](https://ghc.haskell.org/trac/ghc/wiki/PrimBool) 44 | versions of comparison predicates in `GHC.Integer`: 45 | 46 | eqInteger# :: Integer -> Integer -> Int# 47 | geInteger# :: Integer -> Integer -> Int# 48 | gtInteger# :: Integer -> Integer -> Int# 49 | leInteger# :: Integer -> Integer -> Int# 50 | ltInteger# :: Integer -> Integer -> Int# 51 | neqInteger# :: Integer -> Integer -> Int# 52 | 53 | * New `GHC.Integer.testBitInteger` primitive for use with `Data.Bits` 54 | 55 | * Reduce short-lived heap allocation and try to demote `J#` back 56 | to `S#` more aggressively. See also 57 | [#8647](https://ghc.haskell.org/trac/ghc/ticket/8647) 58 | for more details. 59 | 60 | * New GMP-specific binary (de)serialization primitives added to 61 | `GHC.Integer.GMP.Internals`: 62 | 63 | importIntegerFromByteArray 64 | importIntegerFromAddr 65 | exportIntegerToAddr 66 | exportIntegerToMutableByteArray 67 | sizeInBaseInteger 68 | 69 | * New GMP-implemented number-theoretic operations added to 70 | `GHC.Integer.GMP.Internals`: 71 | 72 | gcdExtInteger 73 | nextPrimeInteger 74 | testPrimeInteger 75 | powInteger 76 | powModInteger 77 | powModSecInteger 78 | recipModInteger 79 | -------------------------------------------------------------------------------- /prana-boot/packages/integer-gmp-1.0.2.0/gmp/config.mk.in: -------------------------------------------------------------------------------- 1 | ifeq "$(HaveLibGmp)" "" 2 | HaveLibGmp = @HaveLibGmp@ 3 | endif 4 | 5 | ifeq "$(HaveFrameworkGMP)" "" 6 | HaveFrameworkGMP = @HaveFrameworkGMP@ 7 | endif 8 | 9 | GMP_INCLUDE_DIRS = @GMP_INCLUDE_DIRS@ 10 | GMP_LIB_DIRS = @GMP_LIB_DIRS@ 11 | 12 | -------------------------------------------------------------------------------- /prana-boot/packages/integer-gmp-1.0.2.0/include/HsIntegerGmp.h.in: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* Whether GMP is embedded into integer-gmp */ 4 | #define GHC_GMP_INTREE @UseIntreeGmp@ 5 | 6 | /* The following values denote the GMP version used during GHC build-time */ 7 | #define GHC_GMP_VERSION_MJ @GhcGmpVerMj@ 8 | #define GHC_GMP_VERSION_MI @GhcGmpVerMi@ 9 | #define GHC_GMP_VERSION_PL @GhcGmpVerPl@ 10 | #define GHC_GMP_VERSION \ 11 | (@GhcGmpVerMj@ * 10000 + @GhcGmpVerMi@ * 100 + @GhcGmpVerPl@) 12 | 13 | /* Whether GMP supports mpz_powm_sec */ 14 | #define HAVE_SECURE_POWM @HaveSecurePowm@ 15 | -------------------------------------------------------------------------------- /prana-boot/packages/integer-gmp-1.0.2.0/integer-gmp.buildinfo.in: -------------------------------------------------------------------------------- 1 | include-dirs: @GMP_INCLUDE_DIRS@ 2 | extra-lib-dirs: @GMP_LIB_DIRS@ 3 | extra-libraries: @GMP_LIBS@ 4 | frameworks: @GMP_FRAMEWORK@ 5 | install-includes: HsIntegerGmp.h ghc-gmp.h 6 | -------------------------------------------------------------------------------- /prana-boot/packages/integer-gmp-1.0.2.0/integer-gmp.cabal: -------------------------------------------------------------------------------- 1 | cabal-version: >=1.10 2 | name: integer-gmp 3 | version: 1.0.2.0 4 | 5 | synopsis: Integer library based on GMP 6 | license: BSD3 7 | license-file: LICENSE 8 | author: Herbert Valerio Riedel 9 | maintainer: hvr@gnu.org 10 | category: Numeric, Algebra 11 | build-type: Configure 12 | description: 13 | This package provides the low-level implementation of the standard 14 | 'Integer' type based on the 15 | . 16 | . 17 | This package provides access to the internal representation of 18 | 'Integer' as well as primitive operations with no proper error 19 | handling, and should only be used directly with the utmost care. 20 | 21 | extra-source-files: 22 | aclocal.m4 23 | cbits/wrappers.c 24 | changelog.md 25 | config.guess 26 | config.sub 27 | configure 28 | configure.ac 29 | gmp/config.mk.in 30 | include/HsIntegerGmp.h.in 31 | install-sh 32 | integer-gmp.buildinfo.in 33 | 34 | extra-tmp-files: 35 | autom4te.cache 36 | config.log 37 | config.status 38 | gmp/config.mk 39 | integer-gmp.buildinfo 40 | include/HsIntegerGmp.h 41 | 42 | library 43 | default-language: Haskell2010 44 | other-extensions: 45 | BangPatterns 46 | CApiFFI 47 | CPP 48 | DeriveDataTypeable 49 | ExplicitForAll 50 | GHCForeignImportPrim 51 | MagicHash 52 | NegativeLiterals 53 | NoImplicitPrelude 54 | RebindableSyntax 55 | StandaloneDeriving 56 | UnboxedTuples 57 | UnliftedFFITypes 58 | build-depends: ghc-prim >= 0.5.2 && < 0.6 59 | hs-source-dirs: src/ 60 | ghc-options: -this-unit-id integer-gmp -Wall 61 | cc-options: -std=c99 -Wall 62 | 63 | include-dirs: include 64 | c-sources: 65 | cbits/wrappers.c 66 | 67 | exposed-modules: 68 | GHC.Integer 69 | GHC.Integer.Logarithms 70 | GHC.Integer.Logarithms.Internals 71 | 72 | GHC.Integer.GMP.Internals 73 | 74 | other-modules: 75 | GHC.Integer.Type 76 | -------------------------------------------------------------------------------- /prana-boot/packages/integer-gmp-1.0.2.0/src/GHC/Integer.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE CPP #-} 2 | {-# LANGUAGE MagicHash #-} 3 | {-# LANGUAGE NoImplicitPrelude #-} 4 | 5 | #include "MachDeps.h" 6 | 7 | -- | 8 | -- Module : GHC.Integer.Type 9 | -- Copyright : (c) Herbert Valerio Riedel 2014 10 | -- License : BSD3 11 | -- 12 | -- Maintainer : ghc-devs@haskell.org 13 | -- Stability : provisional 14 | -- Portability : non-portable (GHC Extensions) 15 | -- 16 | -- The 'Integer' type. 17 | -- 18 | -- This module exposes the /portable/ 'Integer' API. See 19 | -- "GHC.Integer.GMP.Internals" for the @integer-gmp@-specific internal 20 | -- representation of 'Integer' as well as optimized GMP-specific 21 | -- operations. 22 | 23 | module GHC.Integer ( 24 | Integer, 25 | 26 | -- * Construct 'Integer's 27 | mkInteger, smallInteger, wordToInteger, 28 | #if WORD_SIZE_IN_BITS < 64 29 | word64ToInteger, int64ToInteger, 30 | #endif 31 | -- * Conversion to other integral types 32 | integerToWord, integerToInt, 33 | #if WORD_SIZE_IN_BITS < 64 34 | integerToWord64, integerToInt64, 35 | #endif 36 | 37 | -- * Helpers for 'RealFloat' type-class operations 38 | encodeFloatInteger, floatFromInteger, 39 | encodeDoubleInteger, decodeDoubleInteger, doubleFromInteger, 40 | 41 | -- * Arithmetic operations 42 | plusInteger, minusInteger, timesInteger, negateInteger, 43 | absInteger, signumInteger, 44 | 45 | divModInteger, divInteger, modInteger, 46 | quotRemInteger, quotInteger, remInteger, 47 | 48 | -- * Comparison predicates 49 | eqInteger, neqInteger, leInteger, gtInteger, ltInteger, geInteger, 50 | compareInteger, 51 | 52 | -- ** 'Int#'-boolean valued versions of comparison predicates 53 | -- 54 | -- | These operations return @0#@ and @1#@ instead of 'False' and 55 | -- 'True' respectively. See 56 | -- 57 | -- for more details 58 | eqInteger#, neqInteger#, leInteger#, gtInteger#, ltInteger#, geInteger#, 59 | 60 | 61 | -- * Bit-operations 62 | andInteger, orInteger, xorInteger, 63 | 64 | complementInteger, 65 | shiftLInteger, shiftRInteger, testBitInteger, 66 | 67 | -- * Hashing 68 | hashInteger, 69 | ) where 70 | 71 | import GHC.Integer.Type 72 | 73 | default () 74 | -------------------------------------------------------------------------------- /prana-boot/packages/integer-gmp-1.0.2.0/src/GHC/Integer/Logarithms.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE NoImplicitPrelude #-} 2 | {-# LANGUAGE MagicHash #-} 3 | {-# LANGUAGE UnboxedTuples #-} 4 | {-# LANGUAGE UnliftedFFITypes #-} 5 | {-# LANGUAGE CPP #-} 6 | {-# LANGUAGE BangPatterns #-} 7 | 8 | module GHC.Integer.Logarithms 9 | ( wordLog2# 10 | , integerLog2# 11 | , integerLogBase# 12 | ) where 13 | 14 | #include "MachDeps.h" 15 | 16 | #if WORD_SIZE_IN_BITS == 32 17 | # define LD_WORD_SIZE_IN_BITS 5 18 | #elif WORD_SIZE_IN_BITS == 64 19 | # define LD_WORD_SIZE_IN_BITS 6 20 | #else 21 | # error unsupported WORD_SIZE_IN_BITS 22 | #endif 23 | 24 | import GHC.Integer.Type 25 | 26 | import GHC.Prim 27 | 28 | default () 29 | 30 | -- | Calculate the integer logarithm for an arbitrary base. 31 | -- 32 | -- The base must be greater than @1@, the second argument, the number 33 | -- whose logarithm is sought, shall be positive, otherwise the 34 | -- result is meaningless. 35 | -- 36 | -- The following property holds 37 | -- 38 | -- @base ^ 'integerLogBase#' base m <= m < base ^('integerLogBase#' base m + 1)@ 39 | -- 40 | -- for @base > 1@ and @m > 0@. 41 | -- 42 | -- Note: Internally uses 'integerLog2#' for base 2 43 | integerLogBase# :: Integer -> Integer -> Int# 44 | integerLogBase# (S# 2#) m = integerLog2# m 45 | integerLogBase# b m = e' 46 | where 47 | !(# _, e' #) = go b 48 | 49 | go pw | m `ltInteger` pw = (# m, 0# #) 50 | go pw = case go (sqrInteger pw) of 51 | (# q, e #) | q `ltInteger` pw -> (# q, 2# *# e #) 52 | (# q, e #) -> (# q `quotInteger` pw, 2# *# e +# 1# #) 53 | 54 | 55 | -- | Calculate the integer base 2 logarithm of an 'Integer'. The 56 | -- calculation is more efficient than for the general case, on 57 | -- platforms with 32- or 64-bit words much more efficient. 58 | -- 59 | -- The argument must be strictly positive, that condition is /not/ checked. 60 | integerLog2# :: Integer -> Int# 61 | integerLog2# (S# i#) = wordLog2# (int2Word# i#) 62 | integerLog2# (Jn# _) = -1# 63 | integerLog2# (Jp# bn) = go (s -# 1#) 64 | where 65 | s = sizeofBigNat# bn 66 | go i = case indexBigNat# bn i of 67 | 0## -> go (i -# 1#) 68 | w -> wordLog2# w +# (uncheckedIShiftL# i LD_WORD_SIZE_IN_BITS#) 69 | 70 | -- | Compute base-2 log of 'Word#' 71 | -- 72 | -- This is internally implemented as count-leading-zeros machine instruction. 73 | wordLog2# :: Word# -> Int# 74 | wordLog2# w# = (WORD_SIZE_IN_BITS# -# 1#) -# (word2Int# (clz# w#)) 75 | -------------------------------------------------------------------------------- /prana-boot/prana-boot.cabal: -------------------------------------------------------------------------------- 1 | Name: prana-boot 2 | Version: 0 3 | Copyright: XXX 4 | License: BSD3 5 | Category: Development 6 | build-type: Simple 7 | cabal-version: >=1.10 8 | 9 | executable prana-ghc 10 | default-language: 11 | Haskell2010 12 | main-is: 13 | Main.hs 14 | ghc-options: 15 | -Wall -O2 -threaded -rtsopts +RTS -N -RTS 16 | hs-source-dirs: 17 | app/ 18 | build-depends: 19 | base, process 20 | -------------------------------------------------------------------------------- /prana-ghc/.gitignore: -------------------------------------------------------------------------------- 1 | .stack-work/ 2 | *~ 3 | -------------------------------------------------------------------------------- /prana-ghc/README.md: -------------------------------------------------------------------------------- 1 | # prana-ghc 2 | 3 | This package provides two things: 4 | 5 | 1. A binary `prana-ghc` that acts the same as `ghc`, but also will 6 | generate and install prana packages. 7 | 2. A Haskell library `prana-ghc` that can be used to compile and load 8 | Haskell files as prana byte code, ready for execution by 9 | `prana-interpreter`. 10 | -------------------------------------------------------------------------------- /prana-ghc/cbits/HsVersions.h: -------------------------------------------------------------------------------- 1 | /* Hack needed because of http://hackage.haskell.org/trac/ghc/ticket/8040 */ 2 | 3 | #define ASSERT(e) if debugIsOn && not (e) then (assertPanic __FILE__ __LINE__) else 4 | 5 | #define GLOBAL_VAR(name,value,ty) \ 6 | {-# NOINLINE name #-}; \ 7 | name :: IORef (ty); \ 8 | name = Util.global (value); 9 | -------------------------------------------------------------------------------- /prana-ghc/cbits/PosixSource.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | * 3 | * (c) The GHC Team, 1998-2005 4 | * 5 | * Include this file into sources which should not need any non-Posix services. 6 | * That includes most RTS C sources. 7 | * ---------------------------------------------------------------------------*/ 8 | 9 | #ifndef POSIXSOURCE_H 10 | #define POSIXSOURCE_H 11 | 12 | #include 13 | 14 | #if defined(freebsd_HOST_OS) || defined(dragonfly_HOST_OS) 15 | #define _POSIX_C_SOURCE 200112L 16 | #define _XOPEN_SOURCE 600 17 | #else 18 | #define _POSIX_SOURCE 1 19 | #define _POSIX_C_SOURCE 199506L 20 | #define _XOPEN_SOURCE 500 21 | // FreeBSD takes a different approach to _ISOC99_SOURCE: on FreeBSD it 22 | // means "I want *just* C99 things", whereas on GNU libc and Solaris 23 | // it means "I also want C99 things". 24 | // 25 | // On both GNU libc and FreeBSD, _ISOC99_SOURCE is implied by 26 | // _XOPEN_SOURCE==600, but on Solaris it is an error to omit it. 27 | #define _ISOC99_SOURCE 28 | // Defining __USE_MINGW_ANSI_STDIO is the most portable way to tell 29 | // mingw that we want to use the standard %lld style format specifiers, 30 | // rather than the Windows %I64d style 31 | #define __USE_MINGW_ANSI_STDIO 1 32 | #endif 33 | 34 | #if defined(darwin_HOST_OS) 35 | /* If we don't define this the including sysctl breaks with things like 36 | /usr/include/bsm/audit.h:224:0: 37 | error: syntax error before 'u_char' 38 | */ 39 | #define _DARWIN_C_SOURCE 1 40 | #endif 41 | 42 | #endif /* POSIXSOURCE_H */ 43 | -------------------------------------------------------------------------------- /prana-ghc/cbits/hschooks.c: -------------------------------------------------------------------------------- 1 | /* 2 | These routines customise the error messages 3 | for various bits of the RTS. They are linked 4 | in instead of the defaults. 5 | */ 6 | 7 | #include "PosixSource.h" 8 | #include "Rts.h" 9 | 10 | #include "HsFFI.h" 11 | 12 | #include 13 | 14 | #ifdef HAVE_UNISTD_H 15 | #include 16 | #endif 17 | 18 | void 19 | initGCStatistics(void) 20 | { 21 | /* Workaround for #8754: if the GC stats aren't enabled because the 22 | compiler couldn't use -Bsymbolic to link the default hooks, then 23 | initialize them sensibly. See Note [-Bsymbolic and hooks] in 24 | Main.hs. */ 25 | if (RtsFlags.GcFlags.giveStats == NO_GC_STATS) { 26 | RtsFlags.GcFlags.giveStats = COLLECT_GC_STATS; 27 | } 28 | } 29 | 30 | void 31 | defaultsHook (void) 32 | { 33 | #if __GLASGOW_HASKELL__ >= 707 && __GLASGOW_HASKELL__ < 802 34 | // This helps particularly with large compiles, but didn't work 35 | // very well with earlier GHCs because it caused large amounts of 36 | // fragmentation. See rts/sm/BlockAlloc.c:allocLargeChunk(). 37 | RtsFlags.GcFlags.heapSizeSuggestionAuto = rtsTrue; 38 | #else 39 | RtsFlags.GcFlags.heapSizeSuggestion = 6*1024*1024 / BLOCK_SIZE; 40 | #endif 41 | 42 | RtsFlags.GcFlags.maxStkSize = 512*1024*1024 / sizeof(W_); 43 | 44 | initGCStatistics(); 45 | 46 | // See #3408: the default idle GC time of 0.3s is too short on 47 | // Windows where we receive console events once per second or so. 48 | #if __GLASGOW_HASKELL__ >= 703 49 | RtsFlags.GcFlags.idleGCDelayTime = SecondsToTime(5); 50 | #else 51 | RtsFlags.GcFlags.idleGCDelayTime = 5*1000; 52 | #endif 53 | } 54 | 55 | void 56 | StackOverflowHook (StgWord stack_size) /* in bytes */ 57 | { 58 | fprintf(stderr, "GHC stack-space overflow: current limit is %zu bytes.\nUse the `-K' option to increase it.\n", (size_t)stack_size); 59 | } 60 | -------------------------------------------------------------------------------- /prana-ghc/prana-ghc.cabal: -------------------------------------------------------------------------------- 1 | name: prana-ghc 2 | version: 8.4 3 | build-type: Simple 4 | cabal-version: >= 1.10 5 | 6 | library 7 | ghc-options: -O2 -Wall 8 | exposed-modules: 9 | Prana.Collect 10 | Prana.Ghc 11 | Prana.Index 12 | Prana.Reconstruct 13 | Prana.Rename 14 | Prana.FFI 15 | hs-source-dirs: 16 | src 17 | build-depends: 18 | base >=4.7 && <5, 19 | ghc, 20 | binary, 21 | prana-types, 22 | ghc-paths, 23 | bytestring, 24 | validation, 25 | containers, 26 | transformers, 27 | bifunctors, 28 | directory 29 | default-language: Haskell2010 30 | 31 | executable prana-ghc 32 | default-language: 33 | Haskell2010 34 | main-is: 35 | Main.hs 36 | ghc-options: 37 | -Wall -O2 -threaded -rtsopts +RTS -N -RTS 38 | include-dirs: 39 | cbits/ 40 | hs-source-dirs: 41 | app/ 42 | c-sources: 43 | cbits/hschooks.c 44 | cc-options: 45 | -fPIC 46 | build-depends: 47 | base < 5, 48 | array, 49 | bytestring, 50 | directory, 51 | filepath, 52 | ghc >= 7.8 && <= 8.6.3, 53 | ghc-paths, 54 | haskeline, 55 | process, 56 | transformers, 57 | containers, 58 | time, 59 | random, 60 | mtl, 61 | ghci, 62 | ghc-boot-th, 63 | prana-ghc 64 | 65 | if os(windows) 66 | build-depends: 67 | Win32 68 | else 69 | build-depends: 70 | unix 71 | ghc-options: 72 | -dynamic 73 | -------------------------------------------------------------------------------- /prana-ghc/regenerate.sh: -------------------------------------------------------------------------------- 1 | set -e 2 | set -x 3 | 4 | PREFIX=/home/chris/Work/chrisdone/prana/ghc-8.4/libraries/my-pkg-db 5 | 6 | stack build --test --no-run-tests 7 | 8 | rm -r ~/Work/chrisdone/prana/prana-dir/ 9 | mkdir -p ~/Work/chrisdone/prana/prana-dir/packages/ 10 | 11 | cd ~/Work/chrisdone/prana/ghc-8.4/libraries/ghc-prim/ 12 | 13 | stack exec --no-ghc-package-path -- ./Setup configure --package-db $PREFIX/package.conf.d --prefix $PREFIX --with-compiler $(stack exec which prana-ghc) 14 | 15 | PRANA_DIR=~/Work/chrisdone/prana/prana-dir/ PRANA_MODE=INSTALL time -p -- ./Setup build --ghc-options="-O0" 16 | 17 | 18 | # cd ../integer-gmp/ 19 | 20 | # PRANA_DIR=~/Work/chrisdone/prana/prana-dir/ PRANA_MODE=INSTALL time -p -- ./Setup build --ghc-options="-O0" 21 | 22 | # cd ../base-4.11.1.0/ 23 | 24 | # # Configuration was: 25 | # # ./Setup configure -finteger-gmp --package-db $PREFIX/package.conf.d --prefix $PREFIX --with-compiler $(stack exec which prana-ghc) 26 | 27 | # PRANA_DIR=~/Work/chrisdone/prana/prana-dir/ PRANA_MODE=INSTALL time -p -- ./Setup build --ghc-options="-O0" 28 | 29 | # cd ../array-0.5.2.0/ 30 | 31 | # # ./Setup configure --package-db $PREFIX/package.conf.d --prefix $PREFIX --with-compiler $(stack exec which prana-ghc) 32 | 33 | # PRANA_DIR=~/Work/chrisdone/prana/prana-dir/ PRANA_MODE=INSTALL time -p -- ./Setup build --ghc-options="-O0" 34 | 35 | # cd ../deepseq-1.4.3.0/ 36 | 37 | # PRANA_DIR=~/Work/chrisdone/prana/prana-dir/ PRANA_MODE=INSTALL time -p -- ./Setup build --ghc-options="-O0" 38 | 39 | # cd ../containers-0.5.11.0/ 40 | 41 | # PRANA_DIR=~/Work/chrisdone/prana/prana-dir/ PRANA_MODE=INSTALL time -p -- ./Setup build --ghc-options="-O0" 42 | 43 | # cd ../bytestring-0.10.8.2 44 | 45 | # PRANA_DIR=~/Work/chrisdone/prana/prana-dir/ PRANA_MODE=INSTALL time -p -- ./Setup build --ghc-options="-O0" 46 | 47 | # cd ../binary-0.8.5.1 48 | 49 | # PRANA_DIR=~/Work/chrisdone/prana/prana-dir/ PRANA_MODE=INSTALL time -p -- ./Setup build --ghc-options="-O0" 50 | -------------------------------------------------------------------------------- /prana-ghc/src/Prana/Collect.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE LambdaCase #-} 2 | 3 | -- | Collect information from a module. 4 | 5 | module Prana.Collect 6 | (collectGlobalBindings 7 | ,collectLocalBindings 8 | ,collectDataTypes) 9 | where 10 | 11 | import Control.Monad.Trans.State.Strict 12 | import Data.Bitraversable 13 | import Data.List 14 | import Data.Set (Set) 15 | import qualified Data.Set as Set 16 | import qualified DataCon 17 | import qualified Name 18 | import Prana.Rename 19 | import qualified StgSyn 20 | import qualified TyCon 21 | import qualified Var 22 | 23 | -- | Collect the set of globals produced by a set of bindings. 24 | collectGlobalBindings :: [StgSyn.GenStgTopBinding Name Name] -> Set Name 25 | collectGlobalBindings = Set.fromList . concatMap getNames 26 | where 27 | getNames = 28 | \case 29 | StgSyn.StgTopLifted (StgSyn.StgNonRec bndr _) -> [bndr] 30 | StgSyn.StgTopLifted (StgSyn.StgRec bndrs) -> map fst bndrs 31 | StgSyn.StgTopStringLit bndr _ -> [bndr] 32 | 33 | -- | Collect the set of locals produced by a set of bindings. 34 | collectLocalBindings :: [StgSyn.GenStgTopBinding Name Name] -> Set Name 35 | collectLocalBindings = 36 | flip execState mempty . 37 | traverse (bitraverse (modify . Set.insert) pure) . 38 | concatMap unwrapToplevel 39 | where 40 | unwrapToplevel = 41 | \case 42 | StgSyn.StgTopLifted (StgSyn.StgNonRec _ e) -> [e] 43 | StgSyn.StgTopLifted (StgSyn.StgRec bndrs) -> map snd bndrs 44 | StgSyn.StgTopStringLit _ _ -> [] 45 | 46 | -- | Collect the set of data types. 47 | collectDataTypes :: [TyCon.TyCon] -> [(Name.Name, [Var.Id])] 48 | collectDataTypes = 49 | nub . map (\tyCon -> (Name.getName tyCon, collectDataCons tyCon)) 50 | 51 | -- | Collect the set of data constructor ids. 52 | collectDataCons :: TyCon.TyCon -> [Var.Id] 53 | collectDataCons = 54 | nub . map DataCon.dataConWorkId . TyCon.tyConDataCons 55 | -------------------------------------------------------------------------------- /prana-ghc/src/Prana/Index.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE OverloadedStrings #-} 2 | {-# LANGUAGE DeriveGeneric #-} 3 | 4 | -- | Name indexes. 5 | 6 | module Prana.Index 7 | ( updateIndex 8 | , Index(..) 9 | , reverseIndex 10 | , ReverseIndex(..) 11 | ) where 12 | 13 | import Control.Monad.Trans.State.Strict 14 | import Data.List 15 | import qualified Data.Map.Strict as M 16 | import qualified Data.Set as Set 17 | import Data.Tuple 18 | import Prana.Collect 19 | import Prana.Rename 20 | import Prana.Types 21 | import qualified StgSyn 22 | 23 | updateIndex :: 24 | Monad m 25 | => [StgSyn.GenStgTopBinding Name Name] 26 | -> [(Name, [Name])] 27 | -> StateT Index m Index 28 | updateIndex bindings tycons = do 29 | modify 30 | (\idx -> 31 | idx 32 | { indexGlobals = 33 | let start = fromIntegral (M.size (indexGlobals idx)) 34 | in foldl' 35 | (\m (k, i) -> M.insert k (GlobalVarId i) m) 36 | (indexGlobals idx) 37 | (zip (Set.toList (collectGlobalBindings bindings)) [start ..]) 38 | , indexLocals = 39 | let start = fromIntegral (M.size (indexLocals idx)) 40 | in foldl' 41 | (\m (k, i) -> M.insert k (LocalVarId i) m) 42 | (indexLocals idx) 43 | (zip (Set.toList (collectLocalBindings bindings)) [start ..]) 44 | , indexDataCons = 45 | let start = fromIntegral (M.size (indexDataCons idx)) 46 | in foldl' 47 | (\m (typeIdx, (_typeName, constructorNames)) -> 48 | foldl' 49 | (\acc (consIndex, consName) -> 50 | M.insert 51 | consName 52 | (DataConId (TypeId typeIdx) (ConIndex consIndex)) 53 | acc) 54 | m 55 | (zip [0 ..] constructorNames)) 56 | (indexDataCons idx) 57 | (zip [start ..] tycons) 58 | , indexTypes = 59 | let start = fromIntegral (M.size (indexTypes idx)) 60 | in foldl' 61 | (\m ((typeName, _constructorNames), i) -> 62 | M.insert typeName (TypeId i) m) 63 | (indexTypes idx) 64 | (zip tycons [start ..]) 65 | }) 66 | get 67 | 68 | reverseIndex :: Index -> ReverseIndex 69 | reverseIndex index = 70 | ReverseIndex 71 | { reverseIndexTypes = M.fromList (map swap (M.toList (indexTypes index))) 72 | , reverseIndexDataCons = 73 | M.fromList (map swap (M.toList (indexDataCons index))) 74 | , reverseIndexLocals = M.fromList (map swap (M.toList (indexLocals index))) 75 | , reverseIndexGlobals = 76 | M.fromList (map swap (M.toList (indexGlobals index))) 77 | , reverseIndexIndex = index 78 | } 79 | -------------------------------------------------------------------------------- /prana-interpreter/README.md: -------------------------------------------------------------------------------- 1 | # prana-interpreter 2 | 3 | This package contains: 4 | 5 | 1. A library for interpreting the byte-code generated by `prana-ghc`. 6 | 2. A test suite for said interpreter. 7 | -------------------------------------------------------------------------------- /prana-interpreter/TODO: -------------------------------------------------------------------------------- 1 | I'm not sure whether this is necessary anymore. 2 | 3 | 4 | -- Needs more work on State# s actions. WE SHOULD ACTUALLY BE RETURNING 5 | -- AN UNBOXED TUPLE AT THE END OF EVERYTHING. 6 | 7 | -- But what do we use for `s` (RealWorld) which is magic? Oh, of course! 8 | -- Accept an argument, and box it. Done. 9 | 10 | -- Let's generate a real test suite case for readArray via 11 | -- Data.Primtive.Array and see how its result is pattern matched? 12 | 13 | -- Bad result of this is that: The below one is not properly lazy; we end 14 | -- up evaluating the box, whereas instead we ought really to be returning 15 | -- an unboxed tuple like above. 16 | 17 | -- ReadArrayOp 18 | -- -> case args_a2sBt of 19 | -- [wrapped_arg_0, wrapped_arg_1] 20 | -- -> do MutableArray arg_unwrapped_0 <- (evalMutableArrayArg 21 | -- evalSomeVarId_a2sBp) 22 | -- wrapped_arg_0 23 | -- I# arg_unwrapped_1 <- (evalIntArg evalSomeVarId_a2sBp) 24 | -- wrapped_arg_1 25 | -- get_result <- GHC.Types.IO 26 | -- (\ s 27 | -- -> case 28 | -- ((readArray# arg_unwrapped_0) arg_unwrapped_1) s 29 | -- of { 30 | -- (# s', arg_tmp_0 #) -> (# s', \ _ -> arg_tmp_0 #) }) 31 | -- let !result = get_result () 32 | -- evalBox_a2sBq result 33 | -- _ -> error "Invalid arguments to primop: "readArray#"" 34 | 35 | -- This one is properly lazy (doesn't force the element): 36 | 37 | -- IndexArrayOp 38 | -- -> case args_a2sBt of 39 | -- [wrapped_arg_0, wrapped_arg_1] 40 | -- -> do Array arg_unwrapped_0 <- (evalArrayArg evalSomeVarId_a2sBp) 41 | -- wrapped_arg_0 42 | -- I# arg_unwrapped_1 <- (evalIntArg evalSomeVarId_a2sBp) 43 | -- wrapped_arg_1 44 | -- let !result = (indexArray# arg_unwrapped_0) arg_unwrapped_1 45 | -- case result of { 46 | -- (# slot_0 #) 47 | -- -> do slot_boxed_0 <- pure slot_0 48 | -- pure ((ConWhnf (UnboxedTupleConId 1)) [slot_boxed_0]) } 49 | -- _ -> error "Invalid arguments to primop: "indexArray#"" 50 | -------------------------------------------------------------------------------- /prana-interpreter/prana-interpreter.cabal: -------------------------------------------------------------------------------- 1 | name: prana-interpreter 2 | version: 0 3 | build-type: Simple 4 | cabal-version: >= 1.10 5 | extra-source-files: test/assets/*.hs 6 | 7 | library 8 | exposed-modules: 9 | Prana.Interpreter 10 | Prana.Interpreter.Boxing 11 | Prana.Interpreter.PrimOps 12 | Prana.Interpreter.Binding 13 | Prana.Interpreter.Eval 14 | Prana.Interpreter.Types 15 | Prana.Interpreter.PrimOps.TH 16 | hs-source-dirs: 17 | src 18 | build-depends: 19 | base >=4.7 && <5, 20 | bytestring, 21 | binary, 22 | prana-types, 23 | prana-primops, 24 | mtl, 25 | containers, 26 | template-haskell, 27 | ghc-prim, 28 | primitive, 29 | libffi, 30 | unix 31 | default-language: Haskell2010 32 | 33 | test-suite prana-interpreter-test 34 | type: exitcode-stdio-1.0 35 | hs-source-dirs: test 36 | main-is: Main.hs 37 | build-depends: base 38 | , prana-types 39 | , ghc 40 | , hspec 41 | , ghc-paths, weigh, 42 | validation, prana-ghc, containers, mtl, 43 | bytestring, formatting, clock, conduit, prana-interpreter 44 | ghc-options: -Wall -rtsopts 45 | default-language: Haskell2010 46 | -------------------------------------------------------------------------------- /prana-interpreter/src/Prana/Interpreter.hs: -------------------------------------------------------------------------------- 1 | module Prana.Interpreter 2 | ( 3 | -- * Setting up the environment 4 | bindGlobal 5 | -- * Evaluation functions 6 | , evalExpr 7 | , evalCon 8 | , evalBox 9 | -- * Data types 10 | , Whnf(..) 11 | , Thunk(..) 12 | , Box(..) 13 | ) where 14 | 15 | import Prana.Interpreter.Binding 16 | import Prana.Interpreter.Eval 17 | import Prana.Interpreter.Types 18 | -------------------------------------------------------------------------------- /prana-interpreter/src/Prana/Interpreter/Binding.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE RecursiveDo #-} 2 | 3 | -- | Binding names in the environment. 4 | 5 | module Prana.Interpreter.Binding 6 | ( bindLocal 7 | , bindGlobal 8 | ) where 9 | 10 | import Control.Monad.IO.Class (liftIO) 11 | import Control.Monad.Reader 12 | import Data.Map.Strict (Map) 13 | import qualified Data.Map.Strict as M 14 | import Prana.Interpreter.Boxing 15 | import Prana.Interpreter.Types 16 | import Prana.Types 17 | 18 | bindLocal :: LocalBinding -> Map LocalVarId Box -> IO (Map LocalVarId Box) 19 | bindLocal localBinding locals = 20 | case localBinding of 21 | LocalNonRec var rhs -> do 22 | box <- boxRhs locals rhs 23 | let locals' = M.insert var box locals 24 | pure locals' 25 | LocalRec pairs -> mdo 26 | locals' <- 27 | foldM 28 | (\acc (var, rhs) -> do 29 | box <- boxRhs locals' rhs 30 | pure (M.insert var box acc)) 31 | locals 32 | pairs 33 | pure locals' 34 | 35 | bindGlobal :: 36 | MonadIO m 37 | => Map GlobalVarId Box 38 | -> GlobalBinding 39 | -> m (Map GlobalVarId Box) 40 | bindGlobal globals globalBinding = 41 | liftIO 42 | (case globalBinding of 43 | GlobalNonRec var rhs -> do 44 | box <- boxRhs mempty rhs 45 | let globals' = M.insert var box globals 46 | pure globals' 47 | GlobalRec pairs -> do 48 | globals' <- 49 | foldM 50 | (\acc (var, rhs) -> do 51 | box <- boxRhs mempty rhs 52 | pure (M.insert var box acc)) 53 | globals 54 | pairs 55 | pure globals' 56 | GlobalStringLit globalVarId byteString -> do 57 | box <- boxWhnf (LitWhnf (StringLit byteString)) 58 | pure (M.insert globalVarId box globals)) 59 | -------------------------------------------------------------------------------- /prana-interpreter/src/Prana/Interpreter/Boxing.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE LambdaCase #-} 2 | {-# LANGUAGE MagicHash #-} 3 | 4 | -- | 5 | 6 | module Prana.Interpreter.Boxing where 7 | 8 | import Data.IORef 9 | import Data.Map.Strict (Map) 10 | import Data.Primitive 11 | import Data.Primitive.SmallArray 12 | import GHC.Exts 13 | import Prana.Interpreter.Types 14 | import Prana.Types 15 | 16 | boxArg :: Map LocalVarId Box -> Arg -> IO Box 17 | boxArg locals = 18 | \case 19 | VarArg someVarId -> fmap Box (newIORef (VariableThunk locals someVarId)) 20 | LitArg lit -> fmap Box (newIORef (WhnfThunk (LitWhnf lit))) 21 | 22 | boxRhs :: Map LocalVarId Box -> Rhs -> IO Box 23 | boxRhs locals = 24 | \case 25 | RhsCon (Con dataConId args) -> do 26 | boxes <- traverse (boxArg locals) args 27 | fmap Box (newIORef (WhnfThunk (ConWhnf dataConId boxes))) 28 | RhsClosure closure -> 29 | if null (closureParams closure) 30 | then fmap Box (newIORef (ExpressionThunk locals (closureExpr closure))) 31 | else fmap 32 | Box 33 | (newIORef 34 | (WhnfThunk 35 | (FunWhnf 36 | locals 37 | (closureParams closure) 38 | (closureExpr closure)))) 39 | 40 | boxWhnf :: Whnf -> IO Box 41 | boxWhnf whnf = 42 | fmap Box (newIORef (WhnfThunk whnf)) 43 | 44 | boxInt :: Int# -> IO Box 45 | boxInt x# = boxWhnf (LitWhnf (IntLit (I# x#))) 46 | 47 | boxChar :: Char# -> IO Box 48 | boxChar x# = boxWhnf (LitWhnf (CharLit (C# x#))) 49 | 50 | boxWord :: Word# -> IO Box 51 | boxWord x# = boxWhnf (LitWhnf (WordLit (W# x#))) 52 | 53 | boxDouble :: Double# -> IO Box 54 | boxDouble x# = boxWhnf (LitWhnf (DoubleLit (D# x#))) 55 | 56 | boxFloat :: Float# -> IO Box 57 | boxFloat x# = boxWhnf (LitWhnf (FloatLit (F# x#))) 58 | 59 | boxAddr :: Addr# -> IO Box 60 | boxAddr x# = boxWhnf (AddrWhnf (Ptr x#)) 61 | 62 | boxArray :: Array# Box -> IO Box 63 | boxArray x# = boxWhnf (ArrayWhnf (Array x#)) 64 | 65 | boxMutableArray :: MutableArray# RealWorld Box -> IO Box 66 | boxMutableArray x# = boxWhnf (MutableArrayWhnf (MutableRealWorldArray (MutableArray x#))) 67 | 68 | boxSmallMutableArray :: SmallMutableArray# RealWorld Box -> IO Box 69 | boxSmallMutableArray x# = 70 | boxWhnf 71 | (SmallMutableArrayWhnf (SmallMutableRealWorldArray (SmallMutableArray x#))) 72 | 73 | boxMutableByteArray :: MutableByteArray# RealWorld -> IO Box 74 | boxMutableByteArray x# = 75 | boxWhnf 76 | (MutableByteArrayWhnf (MutableRealWorldByteArray (MutableByteArray x#))) 77 | 78 | boxState :: State# RealWorld -> IO Box 79 | boxState _ = boxWhnf StateWhnf 80 | -------------------------------------------------------------------------------- /prana-interpreter/src/Prana/Interpreter/Types.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE MagicHash #-} 2 | -- | Types used by the interpreter. 3 | 4 | module Prana.Interpreter.Types where 5 | 6 | import Data.IORef 7 | import Data.Map.Strict (Map) 8 | import Data.Primitive.Array 9 | import Data.Primitive.ByteArray 10 | import Data.Primitive.SmallArray 11 | import GHC.Exts 12 | import Prana.Types 13 | 14 | -- | A runtime value at WHNF. 15 | data Whnf 16 | = LitWhnf Lit 17 | | AddrWhnf (Ptr ()) 18 | | ConWhnf DataConId [Box] 19 | | FunWhnf (Map LocalVarId Box) [LocalVarId] Expr 20 | | StateWhnf 21 | | ArrayWhnf (Array Box) 22 | | MutableArrayWhnf (MutableRealWorldArray Box) 23 | | MutableByteArrayWhnf MutableRealWorldByteArray 24 | | SmallMutableArrayWhnf (SmallMutableRealWorldArray Box) 25 | deriving (Show, Eq) 26 | 27 | newtype MutableRealWorldArray a = 28 | MutableRealWorldArray (MutableArray RealWorld Box) 29 | deriving (Eq) 30 | instance Show (MutableRealWorldArray a) where 31 | show _ = "MutableRealWorldArray" 32 | 33 | newtype MutableRealWorldByteArray = 34 | MutableRealWorldByteArray (MutableByteArray RealWorld) 35 | instance Eq MutableRealWorldByteArray where 36 | MutableRealWorldByteArray x == MutableRealWorldByteArray y = 37 | sameMutableByteArray x y 38 | instance Show MutableRealWorldByteArray where 39 | show _ = "MutableRealWorldByteArray" 40 | 41 | newtype SmallMutableRealWorldArray a = 42 | SmallMutableRealWorldArray (SmallMutableArray RealWorld Box) 43 | deriving (Eq) 44 | instance Show (SmallMutableRealWorldArray a) where 45 | show _ = "SmallMutableRealWorldArray" 46 | 47 | -- | Provides laziness: A boxed value which is not necessarily 48 | -- evaluated, and when it is evaluated, the thunk inside it is 49 | -- updated. 50 | newtype Box = Box { boxIORef :: IORef Thunk } deriving (Eq) 51 | instance Show Box where show _ = "Box" 52 | 53 | -- | A thunk which has either been evaluated to WHNF, or references a 54 | -- variable or expression to force on demand. 55 | data Thunk 56 | = VariableThunk (Map LocalVarId Box) SomeVarId 57 | | ExpressionThunk (Map LocalVarId Box) Expr 58 | | WhnfThunk Whnf 59 | deriving (Show, Eq) 60 | -------------------------------------------------------------------------------- /prana-interpreter/test/assets/ArrayLoopTest.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE MagicHash, UnboxedTuples #-} 2 | 3 | -- | Tests that boxed things written to the array don't loop. 4 | 5 | module ArrayLoopTest where 6 | 7 | import GHC.Exts 8 | import GHC.Types (IO(..)) 9 | 10 | it :: IO (Char, Int, Char) 11 | it = 12 | IO 13 | (\s -> 14 | case newArray# 22# (let x = x 15 | in x :: Char) s of 16 | (# s', array #) -> 17 | case readArray# array 0# s' of 18 | (# s'', ch #) -> 19 | case unsafeFreezeArray# array s'' of 20 | (# s''', arr #) -> 21 | (# s''' 22 | , ( 'a' -- Replacing this with 'ch' causes a loop, which is proper. 23 | , I# (sizeofMutableArray# array) 24 | , case indexArray# arr 1# of 25 | (# x #) -> 'a')#)) 26 | -------------------------------------------------------------------------------- /prana-interpreter/test/assets/ArrayTest.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE MagicHash, UnboxedTuples #-} 2 | 3 | -- | Test some of the ops for Array# and MutableArray#. 4 | 5 | module ArrayTest where 6 | 7 | import GHC.Exts 8 | import GHC.Types (IO(..)) 9 | 10 | it :: IO (Char, Int, Char) 11 | it = 12 | IO 13 | (\s -> 14 | case newArray# 22# 'a' s of 15 | (# s', array #) -> 16 | case readArray# array 0# s' of 17 | (# s'', ch #) -> 18 | case unsafeFreezeArray# array s'' of 19 | (# s''', arr #) -> 20 | (# s''' 21 | , ( ch 22 | , I# (sizeofMutableArray# array) 23 | , case indexArray# arr 1# of 24 | (# x #) -> x)#)) 25 | -------------------------------------------------------------------------------- /prana-interpreter/test/assets/Atan2.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE NoImplicitPrelude #-} 2 | 3 | -- | Demonstrate various use of the FFI. 4 | 5 | module Atan2 where 6 | 7 | import Foreign.C 8 | 9 | foreign import ccall "math.h atan2" 10 | atan2 :: CDouble -> CDouble -> CDouble 11 | 12 | it :: CDouble 13 | it = atan2 (-10) (10) 14 | -------------------------------------------------------------------------------- /prana-interpreter/test/assets/CharTest.hs: -------------------------------------------------------------------------------- 1 | -- | 2 | 3 | module CharTest where 4 | 5 | it :: String 6 | it = show 123 7 | -------------------------------------------------------------------------------- /prana-interpreter/test/assets/DoubleTest.hs: -------------------------------------------------------------------------------- 1 | -- | 2 | 3 | module DoubleTest where 4 | 5 | it :: Double 6 | it = log 10 7 | -------------------------------------------------------------------------------- /prana-interpreter/test/assets/FibCodata.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE BangPatterns #-} 2 | 3 | module FibCodata (it) where 4 | 5 | it :: Int 6 | it = fibs FibCodata.!! 49 7 | 8 | 9 | fibs :: [Int] 10 | fibs = 1 : 1 : zipWith (+) fibs (tail fibs) 11 | 12 | -- | We implement our own Integer-based !! to force use of 13 | -- MultiValAlts -- using unboxed tuples for a loop. The regular 14 | -- Prelude.!! works fine, but tests less of the interpreter than this 15 | -- implementation. 16 | (!!) :: [p] -> Integer -> p 17 | xs !! n 18 | | otherwise = 19 | foldr 20 | (\x r k -> 21 | case k of 22 | 0 -> x 23 | _ -> r (k - 1)) 24 | (error "too large") 25 | xs 26 | n 27 | -------------------------------------------------------------------------------- /prana-interpreter/test/assets/FibIterative.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE BangPatterns #-} 2 | 3 | module FibIterative (it) where 4 | 5 | it :: Int 6 | it = fib 50 7 | 8 | fib :: Int -> Int 9 | fib n = go 0 1 0 10 | where 11 | go !acc0 !acc1 !i 12 | | i == n = acc0 13 | | otherwise = go acc1 (acc0 + acc1) (i + 1) 14 | -------------------------------------------------------------------------------- /prana-interpreter/test/assets/Foreign.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE NoImplicitPrelude #-} 2 | 3 | -- | Demonstrate various use of the FFI. 4 | 5 | module Foreign where 6 | 7 | import Foreign.C 8 | 9 | foreign import ccall "math.h sin" 10 | sin :: CDouble -> CDouble 11 | 12 | it :: CDouble 13 | it = sin 1 14 | -------------------------------------------------------------------------------- /prana-primops/prana-primops.cabal: -------------------------------------------------------------------------------- 1 | Name: prana-primops 2 | Version: 0 3 | Copyright: XXX 4 | License: BSD3 5 | -- XXX License-File: LICENSE 6 | Author: XXX 7 | Maintainer: XXX 8 | Synopsis: Generates various files implementing GHC's primitive operations. 9 | Description: 10 | This utility reads a textual description of GHC's primitive operations 11 | (@primops.txt.pp@) and produces a number of outputs. These include, 12 | . 13 | * the @GHC.Prim@ module included in the @ghc-prim@ package. 14 | * the @GHC.PrimopWrappers@ module included in the @ghc-prim@ package. 15 | * an LaTeX document describing the primitive operations. 16 | Category: Development 17 | build-type: Simple 18 | cabal-version: >=1.10 19 | 20 | library 21 | Default-Language: Haskell2010 22 | hs-source-dirs: src 23 | exposed-modules: 24 | Prana.PrimOp 25 | Prana.PrimOp.Type 26 | Other-Modules: Lexer 27 | Parser 28 | ParserM 29 | Syntax 30 | Build-Depends: base >= 4 && < 5, 31 | array, 32 | deepseq, 33 | filepath, 34 | template-haskell, 35 | directory, 36 | binary 37 | 38 | Executable prana-genprimopcode 39 | Default-Language: Haskell2010 40 | hs-source-dirs: src, app 41 | Main-Is: Main.hs 42 | Other-Modules: Lexer 43 | Parser 44 | ParserM 45 | Syntax 46 | Build-Depends: base >= 4 && < 5, 47 | array 48 | -------------------------------------------------------------------------------- /prana-primops/src/Prana/PrimOp.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TemplateHaskellQuotes #-} 2 | {-# LANGUAGE NamedFieldPuns #-} 3 | 4 | -- | Reading the primops. 5 | 6 | module Prana.PrimOp 7 | ( derivePrimOpType 8 | , parsePrimops 9 | , findProjectFile 10 | , Entry(..) 11 | , Ty(..) 12 | , TyCon(..) 13 | , TyVar 14 | ) where 15 | 16 | import Data.Maybe 17 | import GHC.Generics 18 | import Language.Haskell.TH 19 | import Parser 20 | import Syntax 21 | import System.Directory 22 | import System.FilePath 23 | 24 | -------------------------------------------------------------------------------- 25 | -- Derive the PrimOp type 26 | 27 | derivePrimOpType :: Q [Dec] 28 | derivePrimOpType = do 29 | entries <- runIO parsePrimops 30 | conses <- fmap catMaybes (mapM mkCons entries) 31 | pure [DataD ctx (mkName "PrimOp") tyVars mkind conses derivings] 32 | where 33 | ctx = [] 34 | tyVars = [] 35 | mkind = Nothing 36 | mkCons entry = 37 | case entry of 38 | PrimOpSpec {cons = constructorName} -> 39 | pure (Just (NormalC (mkName constructorName) slots)) 40 | _ -> pure Nothing 41 | slots = [] 42 | derivings = 43 | [ DerivClause 44 | Nothing 45 | [ ConT ''Show 46 | , ConT ''Generic 47 | , ConT ''Eq 48 | , ConT ''Ord 49 | , ConT ''Read 50 | , ConT ''Enum 51 | , ConT ''Bounded 52 | ] 53 | ] 54 | 55 | -------------------------------------------------------------------------------- 56 | -- Parsing the primops file 57 | 58 | parsePrimops :: IO [Entry] 59 | parsePrimops = do 60 | fp <- findProjectFile "prana-primops/primops.txt" 61 | bytes <- readFile fp 62 | case parse bytes of 63 | Left err -> error err 64 | Right (Info _ entries) -> pure entries 65 | 66 | -------------------------------------------------------------------------------- 67 | -- TH helpers 68 | 69 | findProjectFile :: FilePath -> IO FilePath 70 | findProjectFile relativeFile = 71 | do mstack <- findStack 72 | case mstack of 73 | Nothing -> error "Could not find stack.yaml." 74 | Just stackDir -> pure (stackDir <> "/" <> relativeFile) 75 | 76 | findStack :: IO (Maybe FilePath) 77 | findStack = do 78 | pwd <- getCurrentDirectory 79 | go pwd 80 | where 81 | go pwd = do 82 | exists <- doesFileExist (pwd <> "/stack.yaml") 83 | if exists 84 | then pure (Just pwd) 85 | else let parent = takeDirectory pwd 86 | in if parent /= pwd 87 | then go parent 88 | else pure Nothing 89 | -------------------------------------------------------------------------------- /prana-primops/src/Prana/PrimOp/Type.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TemplateHaskell #-} 2 | {-# LANGUAGE DeriveGeneric #-} 3 | 4 | -- | Derive the primop type. 5 | 6 | module Prana.PrimOp.Type where 7 | 8 | import Data.Binary 9 | import Prana.PrimOp 10 | 11 | $derivePrimOpType 12 | 13 | instance Binary PrimOp 14 | -------------------------------------------------------------------------------- /prana-types/README.md: -------------------------------------------------------------------------------- 1 | # prana-types 2 | 3 | This package provides all the types neccessary for compiling Haskell 4 | code to prana byte code and for loading it ready for the interpreter. 5 | 6 | Broadly speaking, it contains: 7 | 8 | 1. An STG AST set of data types, which correspond almost 1:1 with 9 | GHC's, but with minor modifications to make it more strict, and to 10 | not depend on the GHC API directly. 11 | 2. The name index types, which serve to map integers used in the AST 12 | to their original names, and a reverse index to go in the other 13 | direction. 14 | -------------------------------------------------------------------------------- /prana-types/prana-types.cabal: -------------------------------------------------------------------------------- 1 | name: prana-types 2 | version: 0 3 | build-type: Simple 4 | cabal-version: >= 1.10 5 | 6 | library 7 | exposed-modules: 8 | Prana.Types 9 | Prana.Pretty 10 | hs-source-dirs: 11 | src 12 | build-depends: 13 | base >=4.7 && <5, 14 | bytestring, 15 | binary, 16 | containers, 17 | prana-primops 18 | default-language: Haskell2010 19 | -------------------------------------------------------------------------------- /stack.yaml: -------------------------------------------------------------------------------- 1 | resolver: lts-12.12 2 | compiler: ghc-8.4.3 3 | packages: 4 | - prana-types 5 | - prana-ghc 6 | - prana-interpreter 7 | - prana-primops 8 | extra-deps: 9 | - weigh-0.0.14 10 | -------------------------------------------------------------------------------- /stack.yaml.lock: -------------------------------------------------------------------------------- 1 | # This file was autogenerated by Stack. 2 | # You should not edit this file by hand. 3 | # For more information, please see the documentation at: 4 | # https://docs.haskellstack.org/en/stable/lock_files 5 | 6 | packages: 7 | - completed: 8 | hackage: weigh-0.0.14@sha256:655ff8086b9704828102872a48cfd968b355352d4ee1a01b42a2e033eb8639e1,1119 9 | pantry-tree: 10 | size: 418 11 | sha256: c1c460012612fe8a5772e6a1de2706af844fd2e07eb206888f18feb30fab3bf3 12 | original: 13 | hackage: weigh-0.0.14 14 | snapshots: 15 | - completed: 16 | size: 504336 17 | url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/12/12.yaml 18 | sha256: 11db5c37144d13fe6b56cd511050b4e6ffe988f6edb8e439c2432fc9fcdf50c3 19 | original: lts-12.12 20 | --------------------------------------------------------------------------------