[Haskell-cafe] Template-haskell loading packages
Christopher Done
chrisdone at googlemail.com
Thu Jun 28 10:18:15 CEST 2012
'Ello,
I'm using TH in a big project and whenever TH starts-up in the GHC
(6.4.2) compilation process it loads a number of packages:
[119 o 119] Compiling Main ( src/Main.hs,
dist/build/eudl/eudl-tmp/Main.o )
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package array-0.4.0.0 ... linking ... done.
Loading package strict-0.3.2 ... linking ... done.
Loading package split-0.1.4.3 ... linking ... done.
Loading package safe-0.3.3 ... linking ... done.
Loading package bytestring-0.9.2.1 ... linking ... done.
Loading package deepseq-1.3.0.0 ... linking ... done.
Loading package containers-0.4.2.1 ... linking ... done.
Loading package binary-0.5.1.0 ... linking ... done.
Loading package cereal-0.3.5.2 ... linking ... done.
Loading package entropy-0.2.1 ... linking ... done.
Loading package largeword-1.0.1 ... linking ... done.
Loading package tagged-0.4.2.1 ... linking ... done.
Loading package crypto-api-0.10.2 ... linking ... done.
Loading package pureMD5-2.1.0.3 ... linking ... done.
Loading package dlist-0.5 ... linking ... done.
Loading package old-locale-1.0.0.4 ... linking ... done.
Loading package data-default-0.4.0 ... linking ... done.
Loading package pretty-1.1.1.0 ... linking ... done.
Loading package template-haskell ... linking ... done.
Loading package utf8-string-0.3.7 ... linking ... done.
Loading package printf-mauke-3000.0.5.0.1 ... linking ... done.
Loading package haskell-lexer-1.0 ... linking ... done.
Loading package pretty-show-1.2 ... linking ... done.
Loading package parallel-3.2.0.3 ... linking ... done.
Loading package transformers-0.2.2.0 ... linking ... done.
Loading package mtl-2.0.1.0 ... linking ... done.
Loading package text-0.11.2.1 ... linking ... done.
Loading package parsec-3.1.3 ... linking ... done.
Loading package unix-2.5.1.1 ... linking ... done.
Loading package network-2.3.0.14 ... linking ... done.
Loading package old-time-1.1.0.0 ... linking ... done.
Loading package HTTP-4000.2.3 ... linking ... done.
Loading package base64-bytestring-0.1.1.1 ... linking ... done.
Loading package blaze-builder-0.3.1.0 ... linking ... done.
Loading package blaze-html-0.4.3.4 ... linking ... done.
Loading package filepath-1.3.0.0 ... linking ... done.
Loading package directory-1.1.0.2 ... linking ... done.
Loading package syb-0.3.6.1 ... linking ... done.
Loading package hs-bibutils-4.12 ... linking ... done.
Loading package json-0.5 ... linking ... done.
Loading package pandoc-types-1.9.1 ... linking ... done.
Loading package time-1.4 ... linking ... done.
Loading package xml-1.3.12 ... linking ... done.
Loading package citeproc-hs-0.3.4 ... linking ... done.
Loading package extensible-exceptions-0.1.1.4 ... linking ... done.
Loading package regex-base-0.93.2 ... linking ... done.
Loading package regex-pcre-builtin-0.94.2.1.7.7 ... linking ... done.
Loading package highlighting-kate-0.5.1 ... linking ... done.
Loading package process-1.1.0.1 ... linking ... done.
Loading package random-1.0.1.1 ... linking ... done.
Loading package tagsoup-0.12.6 ... linking ... done.
Loading package temporary-1.1.2.3 ... linking ... done.
Loading package texmath-0.6.0.6 ... linking ... done.
Loading package digest-0.0.1.1 ... linking ... done.
Loading package zlib-0.5.3.3 ... linking ... done.
Loading package zip-archive-0.1.1.8 ... linking ... done.
Loading package pandoc-1.9.4.1 ... linking ... done.
Loading package convertible-1.0.11.1 ... linking ... done.
Loading package HDBC-2.3.1.1 ... linking ... done.
Loading package HDBC-postgresql-2.3.2.1 ... linking ... done.
Loading package haskelldb-2.1.3 ... linking ... done.
Loading package haskelldb-hdbc-2.1.0 ... linking ... done.
Loading package haskelldb-hdbc-postgresql-2.1.0 ... linking ... done.
Loading package QuickCheck-2.4.2 ... linking ... done.
Loading package has-0.5.0.1 ... linking ... done.
Loading package feed-0.3.8 ... linking ... done.
Loading package MonadCatchIO-mtl-0.3.0.4 ... linking ... done.
Loading package xhtml-3000.2.1 ... linking ... done.
Loading package cgi-3001.1.8.2 ... linking ... done.
Loading package fastcgi-3001.0.2.3 ... linking ... done.
Loading package ranges-0.2.4 ... linking ... done.
Loading package email-validate-0.2.8 ... linking ... done.
Loading package digestive-functors-0.2.0.0 ... linking ... done.
Loading package digestive-functors-blaze-0.2.1.0 ... linking ... done.
Loading package curl-1.3.7 ... linking ... done.
Loading package csv-0.1.2 ... linking ... done.
Loading package MonadRandom-0.1.6 ... linking ... done.
Loading package HUnit-1.2.4.3 ... linking ... done.
Loading package hslogger-1.1.5 ... linking ... done.
Loading package regex-posix-0.95.2 ... linking ... done.
Loading package regex-compat-0.95.1 ... linking ... done.
Loading package MissingH-1.1.1.0 ... linking ... done.
Loading package ConfigFile-1.1.1 ... linking ... done.
The TH is declared in a separate module, e.g.
{-# LANGUAGE TemplateHaskell, QuasiQuotes #-}
module Test where
import Language.Haskell.TH
alias :: String -> Name -> Q [Dec]
alias name typ = do
d <- newtypeD ctx conName [] con instances
return [d]
where instances = [''Show,''Num,''Eq,''Ord,''Enum,''Real,''Integral]
ctx = return []
conName = mkName name
con = recC conName [field]
field = return (mkName ("un"++name), NotStrict, ConT typ)
aliases :: Name -> [String] -> Q [Dec]
aliases typ names = fmap concat $ mapM (flip alias typ) names
if I put
import Test
aliases ''Int ["UserId","EventId"]
in the Main module of my project and build the project, I get the
above things being loaded. I'm not sure why the modules need to be
dynamically linked considering they're not actually being used in the
TH. And the module is clearly staged separate to the context in which
it's used. I get that I can reify names to things, like “alias "Foo"
''SomePackage'sType” but those types exist at compile time, surely it
can't require the actual packages? Can anyone explain?
Ciao!
More information about the Haskell-Cafe
mailing list