File tree 2 files changed +18
-5
lines changed
2 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -305,7 +305,9 @@ toConstructor
305
305
toConstructor GenerateOptions {.. } haskellTypes outerTypeName (constructorName, maybeAlternativeType) = do
306
306
let name = Syntax. mkName (Text. unpack $ constructorModifier constructorName)
307
307
308
- let bang = Bang NoSourceUnpackedness NoSourceStrictness
308
+ let strictness = if makeStrict then SourceStrict else NoSourceStrictness
309
+
310
+ let bang = Bang NoSourceUnpackedness strictness
309
311
310
312
case maybeAlternativeType of
311
313
Just dhallType
@@ -400,6 +402,8 @@ data GenerateOptions = GenerateOptions
400
402
-- ^ Generate a `FromDhall` instance for the Haskell type
401
403
, generateToDhallInstance :: Bool
402
404
-- ^ Generate a `ToDhall` instance for the Haskell type
405
+ , makeStrict :: Bool
406
+ -- ^ Make all fields strict.
403
407
}
404
408
405
409
-- | A default set of options used by `makeHaskellTypes`. That means:
@@ -412,6 +416,7 @@ defaultGenerateOptions = GenerateOptions
412
416
, fieldModifier = id
413
417
, generateFromDhallInstance = True
414
418
, generateToDhallInstance = True
419
+ , makeStrict = False
415
420
}
416
421
417
422
-- | This function generates `Dhall.InterpretOptions` that can be used for the
Original file line number Diff line number Diff line change 7
7
8
8
module Dhall.Test.TH where
9
9
10
- import Control.Exception (throwIO )
11
- import Data.Either.Validation (Validation (.. ))
12
- import Dhall.TH (HaskellType (.. ))
13
- import Test.Tasty (TestTree )
10
+ import Control.Exception (throwIO )
11
+ import Data.Either.Validation (Validation (.. ))
12
+ import Dhall.TH (HaskellType (.. ))
13
+ import Test.Tasty (TestTree )
14
14
15
15
import qualified Data.Text
16
16
import qualified Dhall
@@ -153,3 +153,11 @@ Dhall.TH.makeHaskellTypesWith (Dhall.TH.defaultGenerateOptions
153
153
deriving instance Dhall. Generic NoInstancesT
154
154
instance Dhall. FromDhall NoInstancesT
155
155
instance Dhall. ToDhall NoInstancesT
156
+
157
+ Dhall.TH. makeHaskellTypesWith (Dhall.TH. defaultGenerateOptions
158
+ { Dhall.TH. constructorModifier = (" Strict" <> )
159
+ , Dhall.TH. fieldModifier = (" strict" <> ) . Data.Text. toTitle
160
+ , Dhall.TH. makeStrict = True
161
+ })
162
+ [ MultipleConstructors " StrictFields" " ./tests/th/example.dhall"
163
+ ]
You can’t perform that action at this time.
0 commit comments