File tree Expand file tree Collapse file tree 2 files changed +18
-5
lines changed
Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -305,7 +305,9 @@ toConstructor
305305toConstructor GenerateOptions {.. } haskellTypes outerTypeName (constructorName, maybeAlternativeType) = do
306306 let name = Syntax. mkName (Text. unpack $ constructorModifier constructorName)
307307
308- let bang = Bang NoSourceUnpackedness NoSourceStrictness
308+ let strictness = if makeStrict then SourceStrict else NoSourceStrictness
309+
310+ let bang = Bang NoSourceUnpackedness strictness
309311
310312 case maybeAlternativeType of
311313 Just dhallType
@@ -400,6 +402,8 @@ data GenerateOptions = GenerateOptions
400402 -- ^ Generate a `FromDhall` instance for the Haskell type
401403 , generateToDhallInstance :: Bool
402404 -- ^ Generate a `ToDhall` instance for the Haskell type
405+ , makeStrict :: Bool
406+ -- ^ Make all fields strict.
403407 }
404408
405409-- | A default set of options used by `makeHaskellTypes`. That means:
@@ -412,6 +416,7 @@ defaultGenerateOptions = GenerateOptions
412416 , fieldModifier = id
413417 , generateFromDhallInstance = True
414418 , generateToDhallInstance = True
419+ , makeStrict = False
415420 }
416421
417422-- | This function generates `Dhall.InterpretOptions` that can be used for the
Original file line number Diff line number Diff line change 77
88module Dhall.Test.TH where
99
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 )
1414
1515import qualified Data.Text
1616import qualified Dhall
@@ -153,3 +153,11 @@ Dhall.TH.makeHaskellTypesWith (Dhall.TH.defaultGenerateOptions
153153deriving instance Dhall. Generic NoInstancesT
154154instance Dhall. FromDhall NoInstancesT
155155instance 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