Skip to main content

Questions tagged [template-haskell]

Template Haskell is a GHC extension to Haskell that adds compile-time meta-programming facilities. This allows users to write programs that generate or modify their program at compile time: a form of compile-time macros.

template-haskell
2 votes
2 answers
56 views

Is there a way to get `cabal` to detect changes to non-Haskell source files?

I'm using template haskell to include content from non-Haskell files in some of my code, and this content is then parsed and used. The problem that I have with using cabal as a build tool for this is ...
GTF's user avatar
  • 8,265
2 votes
1 answer
43 views

How to get terms names of GADT in Template Haskell?

If I have GADT like: data Pkt (m::Msg) (d::Dir) where GetResourcesPkt :: Pkt 'ResourcesM 'Ask MyResourcesPkt ...
RandomB's user avatar
  • 3,645
1 vote
1 answer
64 views

TemplateHaskell's addDependentFile doesn't work when the file doesn't exist

I want my TemplateHaskell expression recompiled when the dependent file changes and in case it doesn't exist, use a fallback file. But once the dependent file is created I want to also recompile. The ...
xbalaj's user avatar
  • 1,047
1 vote
1 answer
65 views

Printing an expression using Dump library fails

I would like to print the property being tested alongside the argument that caused failure. So, I am trying to solve the second part of the problem by using Debug.Dump from the dump package. This is a ...
F. Zer's user avatar
  • 1,223
1 vote
0 answers
122 views

How can I pinpoint the specific location where property tests fail when using QuickCheck more efficiently?

Current solution: I am currently using counterexample function from Test.Quickcheck: counterexample :: Testable prop => String -> prop -> Property to add informative messages in order to ...
F. Zer's user avatar
  • 1,223
2 votes
0 answers
47 views

Can I attach Haddock comments to declarations in a `[d|���|]` declaration quote?

If I have a declaration quote passed to a Template Haskell function, something like someTHFunction [d| -- | Some documentation data SomeType = SomeConstructor | SomeOtherConstructor |] ...
Antal Spector-Zabusky's user avatar
3 votes
0 answers
44 views

How to refer to a module (and construct the names of its contents) in template haskell

I have a splice I'm writing in TH which needs to take a list of module names and create new names based on a convention I have for these modules. At the moment I am doing this by passing in Strings of ...
GTF's user avatar
  • 8,265
2 votes
2 answers
75 views

How do I capture the named value created by this TH code

Here's my Template Haskell code objectGIDDeclaration :: String -> Integer -> Q [Dec] objectGIDDeclaration dnameSTR gid = pure fDec where dname = dnameSTR <> "GID" fDec = [...
Michael Litchard's user avatar
0 votes
1 answer
93 views

Implement a ReaderT monad Type for mocking network api calls

data TestEnv = TestEnv { rateLimiter' :: !TokenBucket , apiManager :: !Manager , apiKey :: !BS.ByteString } type BunnyReaderT m = ReaderT TestEnv m class MonadIO m => HasBunny m where ...
Vikram malik's user avatar
2 votes
1 answer
166 views

How do I get all instances of HasField type class?

Asking ghci about instances of a record type R does not return the instances of HasField. data R = MkR {f1 :: Int, f2 :: Int} instance HasField "f3" R Int where getField (MkR a b) = a + b ...
lsmor's user avatar
  • 5,043
0 votes
1 answer
125 views

Obfuscating values of compile-time parameters in Haskell

In my Haskell application I implemented the following mechanism for passing sensitive information to the binary (without resorting to CLI parameters): I use a TemplateHaskell mechanism for reading ...
Wojciech Gac's user avatar
  • 1,546
0 votes
1 answer
56 views

No Store instance for Aeson object

The code below generates orphan instances for store. It works fine for aeson 1.4.7.1 but generates error in aeson 2.0.3.0. {-# LANGUAGE DeriveDataTypeable,DeriveGeneric,TemplateHaskell,...
Sal's user avatar
  • 4,332
3 votes
1 answer
88 views

How to force Stack to re-compile when a text file read using template haskell changes?

I'm currently writing a configuration for xmonad. I wanted to make a variable color theme config, so I made each color theme a type, eg data Dracula = Dracula, and a Color type class class ColorTheme ...
Kareem Taha's user avatar
0 votes
1 answer
49 views

No instance for (Data.Vector.Generic.Base.Vector ...) when using Hasql.TH

I have a query I'm running in Hasql using Hasql.TH, and I'm encountering an error I've never seen before (see below). I'm seen this SO question/answer which references the version of vector, but (a) I'...
GTF's user avatar
  • 8,265
0 votes
1 answer
257 views

(Template?) Haskell get name of function at run or compile time

I have a list of imported functions as a top level binding. I want to get the name of each function in the list without hardcoding them. Because the list is known at compile time using Template ...
Fabus1184's user avatar
  • 149

15 30 50 per page
1
2 3 4 5
26