impossible happens with ghc 6.5 building gtk2hs on win32
Trying to build gtk2hs-0.9.10 on win32 using ghc 6.5 (the ghc that ships with visual haskell).
output of ghc -v5:
Glasgow Haskell Compiler, Version 6.5, for Haskell 98, compiled by GHC version 6.4
Using package config file: c:\Program Files\Visual Haskell\package.conf
name: rts
version: 1.0
license: AllRightsReserved
copyright:
maintainer:
stability:
homepage:
package-url:
description:
category:
author:
exposed: True
exposed-modules:
hidden-modules:
import-dirs:
library-dirs: "c:/Program Files/Visual Haskell"
"c:/Program Files/Visual Haskell/gcc-lib"
hs-libraries: HSrts
extra-libraries: m gmp wsock32
include-dirs: "c:/Program Files/Visual Haskell/include"
"c:/Program Files/Visual Haskell/include/mingw"
includes: Stg.h
depends:
hugs-options:
cc-options:
ld-options: -u _GHCziBase_Izh_static_info -u
_GHCziBase_Czh_static_info -u _GHCziFloat_Fzh_static_info -u
_GHCziFloat_Dzh_static_info -u _GHCziPtr_Ptr_static_info -u
_GHCziWord_Wzh_static_info -u _GHCziInt_I8zh_static_info -u
_GHCziInt_I16zh_static_info -u _GHCziInt_I32zh_static_info -u
_GHCziInt_I64zh_static_info -u _GHCziWord_W8zh_static_info -u
_GHCziWord_W16zh_static_info -u _GHCziWord_W32zh_static_info -u
_GHCziWord_W64zh_static_info -u _GHCziStable_StablePtr_static_info
-u _GHCziBase_Izh_con_info -u _GHCziBase_Czh_con_info -u
_GHCziFloat_Fzh_con_info -u _GHCziFloat_Dzh_con_info -u
_GHCziPtr_Ptr_con_info -u _GHCziPtr_FunPtr_con_info -u
_GHCziStable_StablePtr_con_info -u _GHCziBase_False_closure -u
_GHCziBase_True_closure -u _GHCziPack_unpackCString_closure -u
_GHCziIOBase_stackOverflow_closure -u
_GHCziIOBase_heapOverflow_closure -u
_GHCziIOBase_NonTermination_closure -u
_GHCziIOBase_BlockedOnDeadMVar_closure -u
_GHCziIOBase_BlockedIndefinitely_closure -u
_GHCziIOBase_Deadlock_closure -u
_GHCziWeak_runFinalizzerBatch_closure
framework-dirs:
frameworks:
haddock-interfaces:
haddock-html:
name: haskell98
version: 1.0
license: AllRightsReserved
copyright:
maintainer:
stability:
homepage:
package-url:
description:
category:
author:
exposed: True
exposed-modules: Array Bits CError CForeign CPUTime CString CTypes
Char Complex Directory ForeignPtr IO Int Ix List Locale
MarshalAlloc MarshalArray MarshalError MarshalUtils Maybe Monad Ptr
Random Ratio StablePtr Storable System Time Word
hidden-modules:
import-dirs: "c:/Program Files/Visual Haskell/imports"
library-dirs: "c:/Program Files/Visual Haskell"
hs-libraries: HShaskell98
extra-libraries:
include-dirs:
includes:
depends: base-1.0
hugs-options:
cc-options:
ld-options:
framework-dirs:
frameworks:
haddock-interfaces: $topdir/html/libraries/haskell98/haskell98.haddock
haddock-html: $topdir/html/libraries/haskell98
name: template-haskell
version: 1.0
license: AllRightsReserved
copyright:
maintainer:
stability:
homepage:
package-url:
description:
category:
author:
exposed: True
exposed-modules: Language.Haskell.TH.PprLib Language.Haskell.TH.Lib
Language.Haskell.TH.Ppr Language.Haskell.TH.Syntax
Language.Haskell.TH
hidden-modules:
import-dirs: "c:/Program Files/Visual Haskell/imports"
library-dirs: "c:/Program Files/Visual Haskell"
hs-libraries: HStemplate-haskell
extra-libraries:
include-dirs:
includes:
depends: base-1.0 haskell98-1.0
hugs-options:
cc-options:
ld-options:
framework-dirs:
frameworks:
haddock-interfaces: $topdir/html/libraries/template-haskell/template-haskell.haddock
haddock-html: $topdir/html/libraries/template-haskell
name: Cabal
version: 1.0
license: AllRightsReserved
copyright:
maintainer:
stability:
homepage:
package-url:
description:
category:
author:
exposed: True
exposed-modules: Distribution.Compat.ReadP Distribution.Compiler
Distribution.Extension Distribution.GetOpt
Distribution.InstalledPackageInfo Distribution.License
Distribution.Make Distribution.Package
Distribution.PackageDescription Distribution.ParseUtils
Distribution.PreProcess Distribution.Setup Distribution.Simple
Distribution.Version Distribution.PreProcess.Unlit
Distribution.Simple.Build Distribution.Simple.Configure
Distribution.Simple.GHCPackageConfig Distribution.Simple.Install
Distribution.Simple.LocalBuildInfo Distribution.Simple.Register
Distribution.Simple.SrcDist Distribution.Simple.Utils
Language.Haskell.Extension
hidden-modules: Distribution.Compat.Exception
Distribution.Compat.RawSystem Distribution.Compat.FilePath
Distribution.Compat.Directory
import-dirs: "c:/Program Files/Visual Haskell/imports"
library-dirs: "c:/Program Files/Visual Haskell"
hs-libraries: HSCabal
extra-libraries: shfolder
include-dirs:
includes:
depends: base-1.0
hugs-options:
cc-options:
ld-options:
framework-dirs:
frameworks:
haddock-interfaces: $topdir/html/libraries/Cabal/Cabal.haddock
haddock-html: $topdir/html/libraries/Cabal
name: parsec
version: 2.0
license: AllRightsReserved
copyright:
maintainer:
stability:
homepage:
package-url:
description:
category:
author:
exposed: True
exposed-modules: Text.ParserCombinators.Parsec.Error
Text.ParserCombinators.Parsec.Char
Text.ParserCombinators.Parsec.Combinator
Text.ParserCombinators.Parsec.Expr
Text.ParserCombinators.Parsec.Language
Text.ParserCombinators.Parsec.Perm
Text.ParserCombinators.Parsec.Pos
Text.ParserCombinators.Parsec.Prim
Text.ParserCombinators.Parsec.Token Text.ParserCombinators.Parsec
hidden-modules:
import-dirs: "c:/Program Files/Visual Haskell/imports"
library-dirs: "c:/Program Files/Visual Haskell"
hs-libraries: HSparsec
extra-libraries:
include-dirs:
includes:
depends: base-1.0
hugs-options:
cc-options:
ld-options:
framework-dirs:
frameworks:
haddock-interfaces: $topdir/html/libraries/parsec/parsec.haddock
haddock-html: $topdir/html/libraries/parsec
name: haskell-src
version: 1.0
license: AllRightsReserved
copyright:
maintainer:
stability:
homepage:
package-url:
description:
category:
author:
exposed: True
exposed-modules: Language.Haskell.Lexer Language.Haskell.Parser
Language.Haskell.ParseMonad Language.Haskell.ParseUtils
Language.Haskell.Pretty Language.Haskell.Syntax
hidden-modules:
import-dirs: "c:/Program Files/Visual Haskell/imports"
library-dirs: "c:/Program Files/Visual Haskell"
hs-libraries: HShaskell-src
extra-libraries:
include-dirs:
includes:
depends: base-1.0 haskell98-1.0
hugs-options:
cc-options:
ld-options:
framework-dirs:
frameworks:
haddock-interfaces: $topdir/html/libraries/haskell-src/haskell-src.haddock
haddock-html: $topdir/html/libraries/haskell-src
name: network
version: 1.0
license: AllRightsReserved
copyright:
maintainer:
stability:
homepage:
package-url:
description:
category:
author:
exposed: True
exposed-modules: Network.BSD Network.CGI Network.Socket Network.URI
Network
hidden-modules:
import-dirs: "c:/Program Files/Visual Haskell/imports"
library-dirs: "c:/Program Files/Visual Haskell"
hs-libraries: HSnetwork
extra-libraries:
include-dirs: "c:/Program Files/Visual Haskell/include"
includes: HsNet.h
depends: base-1.0 parsec-2.0
hugs-options:
cc-options:
ld-options:
framework-dirs:
frameworks:
haddock-interfaces: $topdir/html/libraries/network/network.haddock
haddock-html: $topdir/html/libraries/network
name: QuickCheck
version: 1.0
license: AllRightsReserved
copyright:
maintainer:
stability:
homepage:
package-url:
description:
category:
author:
exposed: True
exposed-modules: Debug.QuickCheck.Batch Debug.QuickCheck.Poly
Debug.QuickCheck.Utils Debug.QuickCheck Test.QuickCheck.Batch
Test.QuickCheck.Poly Test.QuickCheck.Utils Test.QuickCheck
hidden-modules:
import-dirs: "c:/Program Files/Visual Haskell/imports"
library-dirs: "c:/Program Files/Visual Haskell"
hs-libraries: HSQuickCheck
extra-libraries:
include-dirs:
includes:
depends: base-1.0
hugs-options:
cc-options:
ld-options:
framework-dirs:
frameworks:
haddock-interfaces: $topdir/html/libraries/QuickCheck/QuickCheck.haddock
haddock-html: $topdir/html/libraries/QuickCheck
name: HUnit
version: 1.1
license: AllRightsReserved
copyright:
maintainer:
stability:
homepage:
package-url:
description:
category:
author:
exposed: True
exposed-modules: Test.HUnit.Base Test.HUnit.Lang
Test.HUnit.Terminal Test.HUnit.Text Test.HUnit
hidden-modules:
import-dirs: "c:/Program Files/Visual Haskell/imports"
library-dirs: "c:/Program Files/Visual Haskell"
hs-libraries: HSHUnit
extra-libraries:
include-dirs:
includes:
depends: base-1.0
hugs-options:
cc-options:
ld-options:
framework-dirs:
frameworks:
haddock-interfaces: $topdir/html/libraries/HUnit/HUnit.haddock
haddock-html: $topdir/html/libraries/HUnit
name: mtl
version: 1.0
license: AllRightsReserved
copyright:
maintainer:
stability:
homepage:
package-url:
description:
category:
author:
exposed: True
exposed-modules: Control.Monad.Error Control.Monad.Cont
Control.Monad.Identity Control.Monad.List Control.Monad.RWS
Control.Monad.Reader Control.Monad.State Control.Monad.Trans
Control.Monad.Writer
hidden-modules:
import-dirs: "c:/Program Files/Visual Haskell/imports"
library-dirs: "c:/Program Files/Visual Haskell"
hs-libraries: HSmtl
extra-libraries:
include-dirs:
includes:
depends: base-1.0
hugs-options:
cc-options:
ld-options:
framework-dirs:
frameworks:
haddock-interfaces: $topdir/html/libraries/mtl/mtl.haddock
haddock-html: $topdir/html/libraries/mtl
name: fgl
version: 5.2
license: AllRightsReserved
copyright:
maintainer:
stability:
homepage:
package-url:
description:
category:
author:
exposed: True
exposed-modules: Data.Graph.Inductive.Internal.FiniteMap
Data.Graph.Inductive.Internal.Heap
Data.Graph.Inductive.Internal.Queue
Data.Graph.Inductive.Internal.RootPath
Data.Graph.Inductive.Internal.Thread Data.Graph.Inductive.Basic
Data.Graph.Inductive.Example Data.Graph.Inductive.Graph
Data.Graph.Inductive.Graphviz Data.Graph.Inductive.Monad
Data.Graph.Inductive.NodeMap Data.Graph.Inductive.Query
Data.Graph.Inductive.Tree Data.Graph.Inductive.Monad.IOArray
Data.Graph.Inductive.Query.ArtPoint Data.Graph.Inductive.Query.BCC
Data.Graph.Inductive.Query.BFS Data.Graph.Inductive.Query.DFS
Data.Graph.Inductive.Query.Dominators
Data.Graph.Inductive.Query.GVD Data.Graph.Inductive.Query.Indep
Data.Graph.Inductive.Query.MST Data.Graph.Inductive.Query.MaxFlow
Data.Graph.Inductive.Query.MaxFlow2
Data.Graph.Inductive.Query.Monad Data.Graph.Inductive.Query.SP
Data.Graph.Inductive.Query.TransClos Data.Graph.Inductive
hidden-modules:
import-dirs: "c:/Program Files/Visual Haskell/imports"
library-dirs: "c:/Program Files/Visual Haskell"
hs-libraries: HSfgl
extra-libraries:
include-dirs:
includes:
depends: base-1.0 mtl-1.0
hugs-options:
cc-options:
ld-options:
framework-dirs:
frameworks:
haddock-interfaces: $topdir/html/libraries/fgl/fgl.haddock
haddock-html: $topdir/html/libraries/fgl
name: Win32
version: 1.0
license: AllRightsReserved
copyright:
maintainer:
stability:
homepage:
package-url:
description:
category:
author:
exposed: True
exposed-modules: Graphics.Win32.GDI.Bitmap Graphics.Win32.GDI.Brush
Graphics.Win32.GDI.Clip Graphics.Win32.GDI.Font
Graphics.Win32.GDI.Graphics2D Graphics.Win32.GDI.HDC
Graphics.Win32.GDI.Palette Graphics.Win32.GDI.Path
Graphics.Win32.GDI.Pen Graphics.Win32.GDI.Region
Graphics.Win32.GDI.Types Graphics.Win32.Control
Graphics.Win32.Dialogue Graphics.Win32.GDI Graphics.Win32.Icon
Graphics.Win32.Key Graphics.Win32.Menu Graphics.Win32.Message
Graphics.Win32.Misc Graphics.Win32.Resource Graphics.Win32.Window
Graphics.Win32 System.Win32.DLL System.Win32.File System.Win32.Info
System.Win32.Mem System.Win32.NLS System.Win32.Process
System.Win32.Registry System.Win32.Types System.Win32
hidden-modules:
import-dirs: "c:/Program Files/Visual Haskell/imports"
library-dirs: "c:/Program Files/Visual Haskell"
hs-libraries: HSWin32
extra-libraries: HSWin32_cbits user32 gdi32 winmm kernel32 advapi32
include-dirs: "c:/Program Files/Visual Haskell/include"
includes: HsWin32.h HsGDI.h WndProc.h
depends: base-1.0
hugs-options:
cc-options: -DUNICODE
ld-options:
framework-dirs:
frameworks:
haddock-interfaces: $topdir/html/libraries/Win32/Win32.haddock
haddock-html: $topdir/html/libraries/Win32
name: HGL
version: 3.1
license: AllRightsReserved
copyright:
maintainer:
stability:
homepage:
package-url:
description:
category:
author:
exposed: True
exposed-modules: Graphics.HGL.Core Graphics.HGL.Draw
Graphics.HGL.Units Graphics.HGL.Key Graphics.HGL.Run
Graphics.HGL.Draw.Brush Graphics.HGL.Draw.Font
Graphics.HGL.Draw.Monad Graphics.HGL.Draw.Pen
Graphics.HGL.Draw.Picture Graphics.HGL.Draw.Region
Graphics.HGL.Draw.Text Graphics.HGL.Utils Graphics.HGL.Window
Graphics.HGL Graphics.SOE
hidden-modules: Graphics.HGL.Internals.Event
Graphics.HGL.Internals.Events Graphics.HGL.Internals.Draw
Graphics.HGL.Internals.Types Graphics.HGL.Internals.Flag
Graphics.HGL.Internals.Utilities Graphics.HGL.Win32.Bitmap
Graphics.HGL.Win32.Draw Graphics.HGL.Win32.Types
Graphics.HGL.Win32.WND
import-dirs: "c:/Program Files/Visual Haskell/imports"
library-dirs: "c:/Program Files/Visual Haskell"
hs-libraries: HSHGL
extra-libraries:
include-dirs:
includes:
depends: base-1.0 Win32-1.0
hugs-options:
cc-options:
ld-options:
framework-dirs:
frameworks:
haddock-interfaces: $topdir/html/libraries/HGL/HGL.haddock
haddock-html: $topdir/html/libraries/HGL
name: OpenGL
version: 2.0
license: AllRightsReserved
copyright:
maintainer:
stability:
homepage:
package-url:
description:
category:
author:
exposed: True
exposed-modules: Graphics.Rendering.OpenGL.GL.Antialiasing
Graphics.Rendering.OpenGL.GL.BasicTypes
Graphics.Rendering.OpenGL.GL.BeginEnd
Graphics.Rendering.OpenGL.GL.Bitmaps
Graphics.Rendering.OpenGL.GL.BufferObjects
Graphics.Rendering.OpenGL.GL.Clipping
Graphics.Rendering.OpenGL.GL.Colors
Graphics.Rendering.OpenGL.GL.ColorSum
Graphics.Rendering.OpenGL.GL.CoordTrans
Graphics.Rendering.OpenGL.GL.DisplayLists
Graphics.Rendering.OpenGL.GL.Evaluators
Graphics.Rendering.OpenGL.GL.Feedback
Graphics.Rendering.OpenGL.GL.FlushFinish
Graphics.Rendering.OpenGL.GL.Fog
Graphics.Rendering.OpenGL.GL.Framebuffer
Graphics.Rendering.OpenGL.GL.Hints Graphics.Rendering.OpenGL.GL
Graphics.Rendering.OpenGL.GL.LineSegments
Graphics.Rendering.OpenGL.GL.PerFragment
Graphics.Rendering.OpenGL.GL.PixelRectangles.ColorTable
Graphics.Rendering.OpenGL.GL.PixelRectangles.Convolution
Graphics.Rendering.OpenGL.GL.PixelRectangles.Histogram
Graphics.Rendering.OpenGL.GL.PixelRectangles
Graphics.Rendering.OpenGL.GL.PixelRectangles.Minmax
Graphics.Rendering.OpenGL.GL.PixelRectangles.PixelMap
Graphics.Rendering.OpenGL.GL.PixelRectangles.PixelStorage
Graphics.Rendering.OpenGL.GL.PixelRectangles.PixelTransfer
Graphics.Rendering.OpenGL.GL.PixelRectangles.Rasterization
Graphics.Rendering.OpenGL.GL.Points
Graphics.Rendering.OpenGL.GL.Polygons
Graphics.Rendering.OpenGL.GL.RasterPos
Graphics.Rendering.OpenGL.GL.ReadCopyPixels
Graphics.Rendering.OpenGL.GL.Rectangles
Graphics.Rendering.OpenGL.GL.SavingState
Graphics.Rendering.OpenGL.GL.Selection
Graphics.Rendering.OpenGL.GL.StateVar
Graphics.Rendering.OpenGL.GL.StringQueries
Graphics.Rendering.OpenGL.GL.Texturing.Application
Graphics.Rendering.OpenGL.GL.Texturing.Environments
Graphics.Rendering.OpenGL.GL.Texturing
Graphics.Rendering.OpenGL.GL.Texturing.Objects
Graphics.Rendering.OpenGL.GL.Texturing.Parameters
Graphics.Rendering.OpenGL.GL.Texturing.Queries
Graphics.Rendering.OpenGL.GL.Texturing.Specification
Graphics.Rendering.OpenGL.GLU.Errors Graphics.Rendering.OpenGL.GLU
Graphics.Rendering.OpenGL.GLU.Initialization
Graphics.Rendering.OpenGL.GLU.Matrix
Graphics.Rendering.OpenGL.GLU.Mipmapping
Graphics.Rendering.OpenGL.GLU.NURBS
Graphics.Rendering.OpenGL.GLU.Quadrics
Graphics.Rendering.OpenGL.GLU.Tessellation
Graphics.Rendering.OpenGL.GL.VertexArrays
Graphics.Rendering.OpenGL.GL.VertexSpec Graphics.Rendering.OpenGL
hidden-modules: Graphics.Rendering.OpenGL.GL.BlendingFactor
Graphics.Rendering.OpenGL.GL.BufferMode
Graphics.Rendering.OpenGL.GL.Capability
Graphics.Rendering.OpenGL.GL.ComparisonFunction
Graphics.Rendering.OpenGL.GL.DataType
Graphics.Rendering.OpenGL.GL.EdgeFlag
Graphics.Rendering.OpenGL.GL.Exception
Graphics.Rendering.OpenGL.GL.Extensions
Graphics.Rendering.OpenGL.GL.Face
Graphics.Rendering.OpenGL.GL.GLboolean
Graphics.Rendering.OpenGL.GL.IOState
Graphics.Rendering.OpenGL.GL.PeekPoke
Graphics.Rendering.OpenGL.GL.PixelData
Graphics.Rendering.OpenGL.GL.PixelFormat
Graphics.Rendering.OpenGL.GL.PixelRectangles.Reset
Graphics.Rendering.OpenGL.GL.PixelRectangles.Sink
Graphics.Rendering.OpenGL.GL.PointParameter
Graphics.Rendering.OpenGL.GL.PolygonMode
Graphics.Rendering.OpenGL.GL.PrimitiveMode
Graphics.Rendering.OpenGL.GL.QueryUtils
Graphics.Rendering.OpenGL.GL.RenderMode
Graphics.Rendering.OpenGL.GL.Texturing.PixelInternalFormat
Graphics.Rendering.OpenGL.GL.Texturing.TexParameter
Graphics.Rendering.OpenGL.GL.Texturing.TextureTarget
Graphics.Rendering.OpenGL.GL.Texturing.TextureUnit
Graphics.Rendering.OpenGL.GLU.ErrorsInternal
import-dirs: "c:/Program Files/Visual Haskell/imports"
library-dirs: "c:/Program Files/Visual Haskell"
hs-libraries: HSOpenGL
extra-libraries: HSOpenGL_cbits
include-dirs: "c:/Program Files/Visual Haskell/include"
includes: HsOpenGL.h
depends: base-1.0
hugs-options:
cc-options:
ld-options: -lglu32 -lopengl32
framework-dirs:
frameworks:
haddock-interfaces: $topdir/html/libraries/OpenGL/OpenGL.haddock
haddock-html: $topdir/html/libraries/OpenGL
name: stm
version: 1.0
license: AllRightsReserved
copyright:
maintainer:
stability:
homepage:
package-url:
description:
category:
author:
exposed: True
exposed-modules: Control.Concurrent.STM Control.Concurrent.STM.TVar
Control.Concurrent.STM.TChan Control.Concurrent.STM.TMVar
hidden-modules:
import-dirs: "c:/Program Files/Visual Haskell/imports"
library-dirs: "c:/Program Files/Visual Haskell"
hs-libraries: HSstm
extra-libraries:
include-dirs:
includes:
depends: base-1.0
hugs-options:
cc-options:
ld-options:
framework-dirs:
frameworks:
haddock-interfaces: $topdir/html/libraries/stm/stm.haddock
haddock-html: $topdir/html/libraries/stm
name: base
version: 1.0
license: AllRightsReserved
copyright:
maintainer:
stability:
homepage:
package-url:
description:
category:
author:
exposed: True
exposed-modules: Control.Arrow Control.Concurrent
Control.Concurrent.Chan Control.Concurrent.MVar
Control.Concurrent.QSem Control.Concurrent.QSemN
Control.Concurrent.SampleVar Control.Exception Control.Monad
Control.Monad.Fix Control.Monad.ST Control.Monad.ST.Lazy
Control.Monad.ST.Strict Control.Parallel
Control.Parallel.Strategies Data.Array Data.Array.Base
Data.Array.Diff Data.Array.IArray Data.Array.IO
Data.Array.IO.Internals Data.Array.MArray Data.Array.ST
Data.Array.Storable Data.Array.Unboxed Data.Bits Data.Bool
Data.Char Data.Complex Data.Dynamic Data.Either Data.Eq
Data.FiniteMap Data.FunctorM Data.Generics Data.Generics.Aliases
Data.Generics.Basics Data.Generics.Instances Data.Generics.Schemes
Data.Generics.Text Data.Generics.Twins Data.Graph Data.HashTable
Data.IORef Data.Int Data.IntMap Data.IntSet Data.Ix Data.List
Data.Maybe Data.Map Data.Monoid Data.Ord Data.PackedString
Data.Queue Data.Ratio Data.STRef Data.STRef.Lazy Data.STRef.Strict
Data.Sequence Data.Set Data.Tree Data.Tuple Data.Typeable
Data.Unique Data.Version Data.Word Debug.Trace Foreign Foreign.C
Foreign.C.Error Foreign.C.String Foreign.C.Types Foreign.Concurrent
Foreign.ForeignPtr Foreign.Marshal Foreign.Marshal.Alloc
Foreign.Marshal.Array Foreign.Marshal.Error Foreign.Marshal.Pool
Foreign.Marshal.Utils Foreign.Ptr Foreign.StablePtr
Foreign.Storable GHC.ConsoleHandler GHC.Dotnet GHC.Exts
GHC.ForeignPtr GHC.Handle GHC.IO GHC.Int GHC.PArr
GHC.PrimopWrappers GHC.Unicode GHC.Word Numeric Prelude System.Cmd
System.Console.GetOpt System.CPUTime System.Directory
System.Directory.Internals System.Environment System.Exit System.IO
System.IO.Error System.IO.Unsafe System.Info System.Locale
System.Mem System.Mem.StableName System.Mem.Weak
System.Posix.Internals System.Posix.Signals System.Posix.Types
System.Process System.Process.Internals System.Random System.Time
Text.Html Text.Html.BlockTable Text.ParserCombinators.ReadP
Text.ParserCombinators.ReadPrec Text.PrettyPrint
Text.PrettyPrint.HughesPJ Text.Printf Text.Read Text.Read.Lex
Text.Regex Text.Regex.Posix Text.Show Text.Show.Functions GHC.Arr
GHC.Base GHC.Conc GHC.Enum GHC.Err GHC.Exception GHC.Float
GHC.IOBase GHC.List GHC.Num GHC.Pack GHC.Prim GHC.Ptr GHC.Read
GHC.Real GHC.ST GHC.STRef GHC.Show GHC.Stable GHC.Storable
GHC.TopHandler GHC.Weak
hidden-modules:
import-dirs: "c:/Program Files/Visual Haskell/imports"
library-dirs: "c:/Program Files/Visual Haskell"
hs-libraries: HSbase1 HSbase2 HSbase3
extra-libraries: HSbase_cbits wsock32 msvcrt kernel32 user32
shell32
include-dirs: "c:/Program Files/Visual Haskell/include"
includes: HsBase.h
depends: rts-1.0
hugs-options:
cc-options:
ld-options:
framework-dirs:
frameworks:
haddock-interfaces: $topdir/html/libraries/base/base.haddock
haddock-html: $topdir/html/libraries/base
name: ghc
version: 6.5
license: AllRightsReserved
copyright:
maintainer:
stability:
homepage:
package-url:
description:
category:
author:
exposed: False
exposed-modules: AsmCodeGen Bag BasicTypes BinIface Binary BitSet
Bitmap BuildTyCl ByteCodeAsm ByteCodeFFI ByteCodeGen ByteCodeInstr
ByteCodeItbls ByteCodeLink CLabel CSE CgBindery CgCallConv CgCase
CgClosure CgCon CgExpr CgForeignCall CgHeapery CgInfoTbls
CgLetNoEscape CgMonad CgParallel CgPrimOp CgProf CgStackery
CgTailCall CgTicky CgUtils Check Class ClosureInfo CmdLineParser
Cmm CmmLex CmmLint CmmParse CmmUtils CodeGen CodeOutput Constants
Convert CoreFVs CoreLint CorePrep CoreSubst CoreSyn CoreTidy
CoreToStg CoreUnfold CoreUtils CostCentre CprAnalyse Ctype DataCon
Demand Desugar Digraph DmdAnal DriverMkDepend DriverPhases
DriverPipeline DsArrows DsBinds DsCCall DsExpr DsForeign DsGRHSs
DsListComp DsMeta DsMonad DsUtils DynFlags ErrUtils ExternalCore
FastMutInt FastString FastTypes FieldLabel Finder FiniteMap
FlattenInfo FlattenMonad Flattening FloatIn FloatOut ForeignCall
FunDeps GHC Generics GetImports HsBinds HsDecls HsExpr HsImpExp
HsLit HsPat HsSyn HsTypes HsUtils HscMain HscStats HscTypes IOEnv
Id IdInfo IfaceEnv IfaceSyn IfaceType IlxGen Inst InstEnv
InteractiveUI Java JavaGen Kind Lexer LexCore LiberateCase Linker
ListSetOps Literal LoadIface MachCodeGen MachInstrs MachOp MachRegs
Match MatchCon MatchLit Maybes MkExternalCore MkId MkIface Module
NCGMonad NDPCoreUtils Name NameEnv NameSet NewDemand ObjLink
OccName OccurAnal OrdList Outputable PArrAnal PackageConfig
Packages Panic Parser ParserCoreUtils ParsePkgConf
PositionIndependentCode PprC PprCmm PprCore PprExternalCore PprMach
PprTyThing PrelInfo PrelNames PrelRules Pretty PrettyTest PrimOp
PrimPacked PrintJava RdrHsSyn RdrName RegAllocInfo RegisterAlloc
RnBinds RnEnv RnExpr RnHsSyn RnNames RnSource RnTypes Rules SAT
SATMonad SCCfinal SMRep SRT SaAbsInt SaLib SetLevels SimplCore
SimplEnv SimplMonad SimplStg SimplUtils Simplify SpecConstr
Specialise SrcLoc StaticFlags StgLint StgStats StgSyn StrictAnal
StringBuffer SysTools TcArrows TcBinds TcClassDcl TcDefaults
TcDeriv TcEnv TcExpr TcForeign TcGenDeriv TcHsSyn TcHsType TcIface
TcInstDcls TcMType TcMatches TcPat TcRnDriver TcRnMonad TcRnTypes
TcRules TcSimplify TcSplice TcTyClsDecls TcTyDecls TcType TcUnify
TidyPgm TyCon Type TypeRep TysPrim TysWiredIn UnicodeUtil Unify
UniqFM UniqSet UniqSupply Unique Util Var VarEnv VarSet WorkWrap
WwLib
hidden-modules:
import-dirs: "c:/Program Files/Visual Haskell/hslibs-imports/ghc"
library-dirs: "c:/Program Files/Visual Haskell"
hs-libraries: HSghc
extra-libraries:
include-dirs:
includes:
depends: template-haskell-1.0 Cabal-1.0 base-1.0 haskell98-1.0
hugs-options:
cc-options:
ld-options:
framework-dirs:
frameworks:
haddock-interfaces: $topdir/html/libraries/ghc/ghc.haddock
haddock-html: $topdir/html/libraries/ghc
name: com
version: 1.0
license: AllRightsReserved
copyright:
maintainer:
stability:
homepage:
package-url:
description:
category:
author:
exposed: False
exposed-modules: Com ComPrim ComDll ComServ ComException Automation
Threads HDirect WideString StdDispatch Pointer AutoPrim PointerPrim
hidden-modules:
import-dirs: C:/ghc/ghc-6.5/hslibs-imports/com
library-dirs: C:/ghc/ghc-6.5
hs-libraries: HScom
extra-libraries: kernel32 user32 ole32 oleaut32 advapi32
include-dirs:
includes:
depends: base-1.0 haskell98-1.0
hugs-options:
cc-options:
ld-options:
framework-dirs:
frameworks:
haddock-interfaces:
haddock-html:
name: hdirect
version: 0.21
license: AllRightsReserved
copyright:
maintainer:
stability:
homepage:
package-url:
description:
category:
author:
exposed: False
exposed-modules:
hidden-modules:
import-dirs:
library-dirs:
hs-libraries:
extra-libraries:
include-dirs:
includes:
depends:
hugs-options:
cc-options:
ld-options:
framework-dirs:
frameworks:
haddock-interfaces:
haddock-html:
name: com
version: 0.21
license: AllRightsReserved
copyright:
maintainer:
stability:
homepage:
package-url:
description:
category:
author:
exposed: False
exposed-modules:
hidden-modules:
import-dirs:
library-dirs:
hs-libraries:
extra-libraries:
include-dirs:
includes:
depends:
hugs-options:
cc-options:
ld-options:
framework-dirs:
frameworks:
haddock-interfaces:
haddock-html:
name: comlib
version: 0.1
license: AllRightsReserved
copyright:
maintainer:
stability:
homepage:
package-url:
description:
category:
author:
exposed: False
exposed-modules: Automation Com ComDll ComException ComPrim ComServ
HDirect Pointer Threads TypeLib WideString StdDispatch
hidden-modules: AutoPrim ClassFactory Connection ConnectionPoint
EnumInterface ExeServer PointerPrim SafeArray StdTypes
import-dirs: "C:\\Program Files\\Haskell\\comlib-0.1\\ghc-6.5"
library-dirs: "C:\\Program Files\\Haskell\\comlib-0.1\\ghc-6.5"
hs-libraries: HScomlib-0.1
extra-libraries: kernel32 user32 ole32 oleaut32 advapi32
include-dirs:
includes:
depends: base-1.0 haskell98-1.0
hugs-options:
cc-options:
ld-options:
framework-dirs:
frameworks:
haddock-interfaces:
haddock-html:
name: comlib
version: 0.2
license: AllRightsReserved
copyright:
maintainer:
stability:
homepage:
package-url:
description:
category:
author:
exposed: True
exposed-modules: Automation Com ComDll ComException ComPrim ComServ
HDirect Pointer Threads TypeLib WideString StdDispatch
hidden-modules: AutoPrim ClassFactory Connection ConnectionPoint
EnumInterface ExeServer PointerPrim SafeArray StdTypes
import-dirs: "C:\\Program Files\\Haskell\\comlib-0.2\\ghc-6.5"
library-dirs: "C:\\Program Files\\Haskell\\comlib-0.2\\ghc-6.5"
hs-libraries: HScomlib-0.2
extra-libraries: kernel32 user32 ole32 oleaut32 advapi32
include-dirs:
includes:
depends: base-1.0 haskell98-1.0
hugs-options:
cc-options:
ld-options:
framework-dirs:
frameworks:
haddock-interfaces:
haddock-html:
name: HaXml
version: 1.13
license: AllRightsReserved
copyright:
maintainer:
stability:
homepage:
package-url:
description:
category:
author:
exposed: True
exposed-modules: Text.ParserCombinators.HuttonMeijerWallace
Text.XML.HaXml Text.XML.HaXml.Combinators
Text.XML.HaXml.DtdToHaskell.Convert
Text.XML.HaXml.DtdToHaskell.Instance
Text.XML.HaXml.DtdToHaskell.TypeDef Text.XML.HaXml.Escape
Text.XML.HaXml.Haskell2Xml Text.XML.HaXml.Html.Generate
Text.XML.HaXml.Html.Parse Text.XML.HaXml.Html.Pretty
Text.XML.HaXml.Lex Text.XML.HaXml.OneOfN Text.XML.HaXml.Parse
Text.XML.HaXml.Pretty Text.XML.HaXml.Types Text.XML.HaXml.Validate
Text.XML.HaXml.Verbatim Text.XML.HaXml.Wrappers
Text.XML.HaXml.Xml2Haskell Text.XML.HaXml.Xtract.Combinators
Text.XML.HaXml.Xtract.Lex Text.XML.HaXml.Xtract.Parse
hidden-modules:
import-dirs: "C:/Program Files/visual haskell//imports"
library-dirs: "C:/Program Files/visual haskell/"
hs-libraries: HSHaXml
extra-libraries:
include-dirs:
includes:
depends: base-1.0 haskell98-1.0
hugs-options:
cc-options:
ld-options:
framework-dirs:
frameworks:
haddock-interfaces:
haddock-html:
name: wxcore
version: 0.9.4
license: AllRightsReserved
copyright:
maintainer:
stability:
homepage:
package-url:
description:
category:
author:
exposed: True
exposed-modules: Graphics.UI.WXCore Graphics.UI.WXCore.WxcClasses
Graphics.UI.WXCore.WxcClassInfo Graphics.UI.WXCore.WxcDefs
Graphics.UI.WXCore.IntMap Graphics.UI.WXCore.Types
Graphics.UI.WXCore.Defines Graphics.UI.WXCore.Draw
Graphics.UI.WXCore.Events Graphics.UI.WXCore.Frame
Graphics.UI.WXCore.Layout Graphics.UI.WXCore.Process
Graphics.UI.WXCore.Print Graphics.UI.WXCore.Dialogs
Graphics.UI.WXCore.Image Graphics.UI.WXCore.Controls
Graphics.UI.WXCore.Db Graphics.UI.WXCore.OpenGL
Graphics.UI.WXCore.WxcObject Graphics.UI.WXCore.WxcClassTypes
Graphics.UI.WXCore.WxcTypes Graphics.UI.WXCore.WxcClassesAL
Graphics.UI.WXCore.WxcClassesMZ
hidden-modules:
import-dirs: C:/Progra~1/Visual~1/imports
library-dirs: C:/Progra~1/Visual~1
hs-libraries: wxcore wxcore0 wxcore1 wxcore2
extra-libraries: wxc-msw2.4.2-0.9.4
include-dirs:
includes:
depends: base-1.0 haskell98-1.0
hugs-options:
cc-options:
ld-options:
framework-dirs:
frameworks:
haddock-interfaces:
haddock-html:
name: wx
version: 0.9.4
license: AllRightsReserved
copyright:
maintainer:
stability:
homepage:
package-url:
description:
category:
author:
exposed: True
exposed-modules: Graphics.UI.WX Graphics.UI.WX.Types
Graphics.UI.WX.Attributes Graphics.UI.WX.Layout
Graphics.UI.WX.Classes Graphics.UI.WX.Variable
Graphics.UI.WX.Events Graphics.UI.WX.Window Graphics.UI.WX.Frame
Graphics.UI.WX.Media Graphics.UI.WX.Menu Graphics.UI.WX.Timer
Graphics.UI.WX.Draw Graphics.UI.WX.Controls Graphics.UI.WX.Dialogs
hidden-modules:
import-dirs: C:/Progra~1/Visual~1/imports
library-dirs: C:/Progra~1/Visual~1
hs-libraries: wx
extra-libraries:
include-dirs:
includes:
depends: wxcore-0.9.4
hugs-options:
cc-options:
ld-options:
framework-dirs:
frameworks:
haddock-interfaces:
haddock-html:
Hsc static flags: -static
*** Deleting temp files:
Deleting:
<no location info>:
ghc.exe: no input files
Usage: For basic information, try the `--help' option.
The exact error is:
/c/Progra~1/Visual~1/bin/ghc +RTS -M120m -RTS -c tools/c2hs/gen/GBMonad.hs -o tools/c2hs/gen/GBMonad.o -O -DWIN32 -itools/c2hs/base/admin:tools/c2hs/base/errors:tools/c2hs/base/general:tools/c2hs/base/graphs:tools/c2hs/base/state:tools/c2hs/base/syms:tools/c2hs/base/syntax:tools/c2hs/base/sysdep:tools/c2hs/c:tools/c2hs/chs:tools/c2hs/gen:tools/c2hs/state:tools/c2hs/toplevel
tools/c2hs/gen/GBMonad.hs:83:0:
Warning: Module `Data.FiniteMap' is deprecated:
Please use Data.Map instead.
tools/c2hs/gen/GBMonad.hs:83:23:
Warning: Deprecated use of type constructor or class `FiniteMap'
(imported from Data.FiniteMap):
Please use Data.Map instead.
tools/c2hs/gen/GBMonad.hs:83:34:
Warning: Deprecated use of `emptyFM'
(imported from Data.FiniteMap):
Please use Data.Map instead.
tools/c2hs/gen/GBMonad.hs:83:43:
Warning: Deprecated use of `addToFM'
(imported from Data.FiniteMap):
Please use Data.Map instead.
tools/c2hs/gen/GBMonad.hs:83:52:
Warning: Deprecated use of `lookupFM'
(imported from Data.FiniteMap):
Please use Data.Map instead.
tools/c2hs/gen/GBMonad.hs:83:62:
Warning: Deprecated use of `plusFM'
(imported from Data.FiniteMap):
Please use Data.Map instead.
tools/c2hs/gen/GBMonad.hs:84:9:
Warning: Deprecated use of `fmToList'
(imported from Data.FiniteMap):
Please use Data.Map instead.
tools/c2hs/gen/GBMonad.hs:84:19:
Warning: Deprecated use of `listToFM'
(imported from Data.FiniteMap):
Please use Data.Map instead.
<no location info>:
ghc.exe: panic! (the `impossible' happened, GHC version 6.5):
<<loop>>
Please report it as a compiler bug to glasgow-haskell-bugs@haskell.org,
or http://sourceforge.net/projects/ghc/.
The contents of GBMonad.hs:
-- C->Haskell Compiler: monad for the binding generator
--
-- Author : Manuel M T Chakravarty
-- Derived: 18 February 2 (extracted from GenBind.hs)
--
-- Version $Revision: 1.1 $ from $Date: 2004/11/21 21:05:41 $
--
-- Copyright (c) [2002..2003] Manuel M T Chakravarty
--
-- This file is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This file is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
--- DESCRIPTION ---------------------------------------------------------------
--
-- This modules defines the monad and related utility routines for the code
-- that implements the expansion of the binding hooks.
--
--- DOCU ----------------------------------------------------------------------
--
-- language: Haskell 98
--
-- Translation table handling for enumerators:
-- -------------------------------------------
--
-- First a translation table lookup on the original identifier of the
-- enumerator is done. If that doesn't match and the prefix can be removed
-- from the identifier, a second lookup on the identifier without the prefix
-- is performed. If this also doesn't match, the identifier without prefix
-- (possible after underscoreToCase translation is returned). If there is a
-- match, the translation (without any further stripping of prefix) is
-- returned.
--
-- Pointer map
-- -----------
--
-- Pointer hooks allow the use to customise the Haskell types to which C
-- pointer types are mapped. The globally maintained map essentially maps C
-- pointer types to Haskell pointer types. The representation of the Haskell
-- types is defined by the `type' or `newtype' declaration emitted by the
-- corresponding pointer hook. However, the map stores a flag that tells
-- whether the C type is itself the pointer type in question or whether it is
-- pointers to this C type that should be mapped as specified. The pointer
-- map is dumped into and read from `.chi' files.
--
-- Haskell object map
-- ------------------
--
-- Some features require information about Haskell objects defined by c2hs.
-- Therefore, the Haskell object map maintains the necessary information
-- about these Haskell objects. The Haskell object map is dumped into and
-- read from `.chi' files.
--
--- TODO ----------------------------------------------------------------------
--
-- * Look up in translation tables is naive - this probably doesn't affect
-- costs much, but at some point a little profiling might be beneficial.
--
module GBMonad (
TransFun, transTabToTransFun,
HsObject(..), GB, HsPtrRep, initialGBState, setContext, getLibrary,
getPrefix, delayCode, getDelayedCode, ptrMapsTo, queryPtr, objIs,
queryObj, queryClass, queryPointer, mergeMaps, dumpMaps
) where
-- standard libraries
import Char (toUpper, toLower, isSpace)
import List (find)
import Maybe (fromMaybe)
-- Compiler Toolkit
import Common (Position, Pos(posOf), nopos, builtinPos)
import Errors (interr)
import Idents (Ident, identToLexeme, onlyPosIdent)
import Data.FiniteMap (FiniteMap, emptyFM, addToFM, lookupFM, plusFM,
fmToList, listToFM)
-- C -> Haskell
import C (CT, readCT, transCT, raiseErrorCTExc)
-- friends
import CHS (CHSModule(..), CHSFrag(..), CHSHook(..), CHSTrans(..),
CHSAccess(..), CHSAPath(..), CHSPtrType(..))
-- translation tables
-- ------------------
-- takes an identifier to a lexeme including a potential mapping by a
-- translation table
--
type TransFun = Ident -> String
-- translation function for the `underscoreToCase' flag
--
underscoreToCase :: TransFun
underscoreToCase ide = let lexeme = identToLexeme ide
ps = filter (not . null) . parts $ lexeme
in
concat . map adjustCase $ ps
where
parts s = let (l, s') = break (== '_') s
in
l : case s' of
[] -> []
(_:s'') -> parts s''
adjustCase (c:cs) = toUpper c : map toLower cs
-- takes an identifier association table to a translation function
--
-- * if first argument is `True', identifiers that are not found in the
-- translation table are subjected to `underscoreToCase'
--
-- * the details of handling the prefix are given in the DOCU section at the
-- beginning of this file
--
transTabToTransFun :: String -> CHSTrans -> TransFun
transTabToTransFun prefix (CHSTrans _2Case table) =
\ide -> let
lexeme = identToLexeme ide
dft = if _2Case -- default uses maybe the...
then underscoreToCase ide -- ..._2case transformed...
else lexeme -- ...lexeme
in
case lookup ide table of -- lookup original ident
Just ide' -> identToLexeme ide' -- original ident matches
Nothing ->
case eat prefix lexeme of
Nothing -> dft -- no match & no prefix
Just eatenLexeme ->
let
eatenIde = onlyPosIdent (posOf ide) eatenLexeme
eatenDft = if _2Case
then underscoreToCase eatenIde
else eatenLexeme
in
case lookup eatenIde table of -- lookup without prefix
Nothing -> eatenDft -- orig ide without prefix
Just ide' -> identToLexeme ide' -- without prefix matched
where
-- try to eat prefix and return `Just partialLexeme' if successful
--
eat [] ('_':cs) = eat [] cs
eat [] cs = Just cs
eat (p:prefix) (c:cs) | toUpper p == toUpper c = eat prefix cs
| otherwise = Nothing
eat _ _ = Nothing
-- the local monad
-- ---------------
-- map that for maps C pointer types to Haskell types for pointer that have
-- been registered using a pointer hook
--
-- * the `Bool' indicates whether for a C type "ctype", we map "ctype" itself
-- or "*ctype"
--
-- * the co-domain details how this pointer is represented in Haskell.
-- See HsPtrRep.
--
type PointerMap = FiniteMap (Bool, Ident) HsPtrRep
-- Define how pointers are represented in Haskell.
--
-- * The first element is true if the pointer points to a function.
-- The second is the Haskell pointer type (plain
-- Ptr, ForeignPtr or StablePtr). The third field is (Just wrap) if the
-- pointer is wrapped in a newtype. Where "wrap"
-- contains the name of the Haskell data type that was defined for this
-- pointer. The forth element contains the type argument of the
-- Ptr, ForeignPtr or StablePtr and is the same as "wrap"
-- unless the user overrode it with the -> notation.
type HsPtrRep = (Bool, CHSPtrType, Maybe String, String)
-- map that maintains key information about some of the Haskell objects
-- generated by c2hs
--
-- NB: using records here avoids to run into a bug with deriving `Read' in GHC
-- 5.04.1
--
data HsObject = Pointer {
ptrTypeHO :: CHSPtrType, -- kind of pointer
isNewtypeHO :: Bool -- newtype?
}
| Class {
superclassHO :: (Maybe Ident),-- superclass
ptrHO :: Ident -- pointer
}
deriving (Show, Read)
type HsObjectMap = FiniteMap Ident HsObject
{- FIXME: What a mess...
instance Show HsObject where
show (Pointer ptrType isNewtype) =
"Pointer " ++ show ptrType ++ show isNewtype
show (Class osuper pointer ) =
"Class " ++ show ptrType ++ show isNewtype
-}
-- super kludgy (depends on Show instance of Ident)
instance Read Ident where
readsPrec _ ('`':lexeme) = let (ideChars, rest) = span (/= '\'') lexeme
in
if null ideChars
then []
else [(onlyPosIdent nopos ideChars, tail rest)]
readsPrec p (c:cs)
| isSpace c = readsPrec p cs
readsPrec _ _ = []
-- the local state consists of
--
-- (1) the dynamic library specified by the context hook,
-- (2) the prefix specified by the context hook,
-- (3) the set of delayed code fragaments, ie, pieces of Haskell code that,
-- finally, have to be appended at the CHS module together with the hook
-- that created them (the latter allows avoid duplication of foreign
-- export declarations), and
-- (4) a map associating C pointer types with their Haskell representation
--
-- access to the attributes of the C structure tree is via the `CT' monad of
-- which we use an instance here
--
data GBState = GBState {
lib :: String, -- dynamic library
prefix :: String, -- prefix
frags :: [(CHSHook, CHSFrag)], -- delayed code (with hooks)
ptrmap :: PointerMap, -- pointer representation
objmap :: HsObjectMap -- generated Haskell objects
}
type GB a = CT GBState a
initialGBState :: GBState
initialGBState = GBState {
lib = "",
prefix = "",
frags = [],
ptrmap = emptyFM,
objmap = emptyFM
}
-- set the dynamic library and library prefix
--
setContext :: (Maybe String) -> (Maybe String) -> GB ()
setContext lib prefix =
transCT $ \state -> (state {lib = fromMaybe "" lib,
prefix = fromMaybe "" prefix},
())
-- get the dynamic library
--
getLibrary :: GB String
getLibrary = readCT lib
-- get the prefix string
--
getPrefix :: GB String
getPrefix = readCT prefix
-- add code to the delayed fragments (the code is made to start at a new line)
--
-- * currently only code belonging to call hooks can be delayed
--
-- * if code for the same call hook (ie, same C function) is delayed
-- repeatedly only the first entry is stored; it is checked that the hooks
-- specify the same flags (ie, produce the same delayed code)
--
delayCode :: CHSHook -> String -> GB ()
delayCode hook str =
do
frags <- readCT frags
frags' <- delay hook frags
transCT (\state -> (state {frags = frags'}, ()))
where
newEntry = (hook, (CHSVerb ("\n" ++ str) (posOf hook)))
--
delay hook@(CHSCall isFun isUns ide oalias _) frags =
case find (\(hook', _) -> hook' == hook) frags of
Just (CHSCall isFun' isUns' ide' _ _, _)
| isFun == isFun'
&& isUns == isUns'
&& ide == ide' -> return frags
| otherwise -> err (posOf ide) (posOf ide')
Nothing -> return $ frags ++ [newEntry]
delay _ _ =
interr "GBMonad.delayCode: Illegal delay!"
--
err = incompatibleCallHooksErr
-- get the complete list of delayed fragments
--
getDelayedCode :: GB [CHSFrag]
getDelayedCode = readCT (map snd . frags)
-- add an entry to the pointer map
--
ptrMapsTo :: (Bool, Ident) -> HsPtrRep -> GB ()
(isStar, cName) `ptrMapsTo` hsRepr =
transCT (\state -> (state {
ptrmap = addToFM (ptrmap state) (isStar, cName) hsRepr
}, ()))
-- query the pointer map
--
queryPtr :: (Bool, Ident) -> GB (Maybe HsPtrRep)
queryPtr pcName = do
fm <- readCT ptrmap
return $ lookupFM fm pcName
-- add an entry to the Haskell object map
--
objIs :: Ident -> HsObject -> GB ()
hsName `objIs` obj =
transCT (\state -> (state {
objmap = addToFM (objmap state) hsName obj
}, ()))
-- query the Haskell object map
--
queryObj :: Ident -> GB (Maybe HsObject)
queryObj hsName = do
fm <- readCT objmap
return $ lookupFM fm hsName
-- query the Haskell object map for a class
--
-- * raise an error if the class cannot be found
--
queryClass :: Ident -> GB HsObject
queryClass hsName = do
let pos = posOf hsName
oobj <- queryObj hsName
case oobj of
Just obj@(Class _ _) -> return obj
Just _ -> classExpectedErr hsName
Nothing -> hsObjExpectedErr hsName
-- query the Haskell object map for a pointer
--
-- * raise an error if the pointer cannot be found
--
queryPointer :: Ident -> GB HsObject
queryPointer hsName = do
let pos = posOf hsName
oobj <- queryObj hsName
case oobj of
Just obj@(Pointer _ _) -> return obj
Just _ -> pointerExpectedErr hsName
Nothing -> hsObjExpectedErr hsName
-- merge the pointer and Haskell object maps
--
-- * currently, the read map overrides any entires for shared keys in the map
-- that is already in the monad; this is so that, if multiple import hooks
-- add entries for shared keys, the textually latest prevails; any local
-- entries are entered after all import hooks anyway
--
-- FIXME: This currently has several shortcomings:
-- * It just dies in case of a corrupted .chi file
-- * We should at least have the option to raise a warning if two
-- entries collide in the `objmap'. But it would be better to
-- implement qualified names.
-- * Do we want position information associated with the read idents?
--
mergeMaps :: String -> GB ()
mergeMaps str =
transCT (\state -> (state {
ptrmap = plusFM readPtrMap (ptrmap state),
objmap = plusFM readObjMap (objmap state)
}, ()))
where
(ptrAssoc, objAssoc) = read str
readPtrMap = listToFM [((isStar, onlyPosIdent nopos ide), repr)
| ((isStar, ide), repr) <- ptrAssoc]
readObjMap = listToFM [(onlyPosIdent nopos ide, obj)
| (ide, obj) <- objAssoc]
-- convert the whole pointer and Haskell object maps into printable form
--
dumpMaps :: GB String
dumpMaps = do
ptrFM <- readCT ptrmap
objFM <- readCT objmap
let dumpable = ([((isStar, identToLexeme ide), repr)
| ((isStar, ide), repr) <- fmToList ptrFM],
[(identToLexeme ide, obj)
| (ide, obj) <- fmToList objFM])
return $ show dumpable
-- error messages
-- --------------
incompatibleCallHooksErr :: Position -> Position -> GB a
incompatibleCallHooksErr here there =
raiseErrorCTExc here
["Incompatible call hooks!",
"There is a another call hook for the same C function at " ++ show there,
"The flags and C function name of the two hooks should be identical,",
"but they are not."]
classExpectedErr :: Ident -> GB a
classExpectedErr ide =
raiseErrorCTExc (posOf ide)
["Expected a class name!",
"Expected `" ++ identToLexeme ide ++ "' to refer to a class introduced",
"by a class hook."]
pointerExpectedErr :: Ident -> GB a
pointerExpectedErr ide =
raiseErrorCTExc (posOf ide)
["Expected a pointer name!",
"Expected `" ++ identToLexeme ide ++ "' to be a type name introduced by",
"a pointer hook."]
hsObjExpectedErr :: Ident -> GB a
hsObjExpectedErr ide =
raiseErrorCTExc (posOf ide)
["Unknown name!",
"`" ++ identToLexeme ide ++ "' is unknown; it has *not* been defined by",
"a previous hook."]