Comments (7)
Works for me using Derive 2.5.25 and the test case below. Can you check with that test case and Derive version, and we can see where things differ.
{-# LANGUAGE TemplateHaskell, DeriveDataTypeable, DeriveGeneric, StandaloneDeriving #-}
module Example where
import Data.Text
import Data.Data
import GHC.Generics
import Data.Time.Clock
import Data.Derive.Arbitrary
import Test.QuickCheck
import Data.DeriveTH
import System.IO.Unsafe
data NoteListItem = NoteListItem {
noteListItemId :: !Text
, noteListItemHash :: !Text
, noteListItemTitle :: !Text
, noteListItemLength :: !Int
, noteListItemCreatedAt :: !UTCTime
, noteListItemUpdatedAt :: !UTCTime
} deriving (Show, Eq, Data, Typeable, Generic, Ord)
instance Arbitrary Text where
arbitrary = return mempty
instance Arbitrary UTCTime where
arbitrary = return $ unsafePerformIO getCurrentTime
$(derive makeArbitrary ''NoteListItem)
main = print =<< generate (arbitrary :: Gen NoteListItem)
from derive.
The test case you posted above works fine - no issues.
I've created a minimal repo that reproduces the failing behavior for me here: https://github.com/jonschoning/derive-issue-17
*note - not a serious issue for me, but just curious if I'm using the library correctly or am misunderstanding something more basic about how ghc works.
from derive.
another side note - what I don't quite understand is where it is getting SourceLazy
from in
(Bang NoSourceUnpackedness SourceLazy,ConT Data.Text.Internal.Text)
I would think it should interpret all the fields as SourceStrict
due to the bangs.
>>> import Derive17
>>> :kind! Rep NoteListItem
Rep NoteListItem :: * -> *
= D1
('MetaData
"NoteListItem"
"Derive17"
"derive17-0.0.1-G2Y3UnpjaWJD80ZsMDbSig"
'False)
(C1
('MetaCons "NoteListItem" 'PrefixI 'True)
((S1
('MetaSel
('Just "noteListItemId")
'NoSourceUnpackedness
'SourceStrict
'DecidedStrict)
(Rec0 TE.Text)
:*: (S1
('MetaSel
('Just "noteListItemHash")
'NoSourceUnpackedness
'SourceStrict
'DecidedStrict)
(Rec0 TE.Text)
:*: S1
('MetaSel
('Just "noteListItemTitle")
'NoSourceUnpackedness
'SourceStrict
'DecidedStrict)
(Rec0 TE.Text)))
:*: (S1
('MetaSel
('Just "noteListItemLength")
'NoSourceUnpackedness
'SourceStrict
'DecidedUnpack)
(Rec0 Int)
:*: (S1
('MetaSel
('Just "noteListItemCreatedAt")
'NoSourceUnpackedness
'SourceStrict
'DecidedStrict)
(Rec0 UTCTime)
:*: S1
('MetaSel
('Just "noteListItemUpdatedAt")
'NoSourceUnpackedness
'SourceStrict
'DecidedStrict)
(Rec0 UTCTime)))))
from derive.
Thanks for the awesome test case - I've got a fix, just doing a buildbot test and then I'll release it.
I suspect the constructors are either strict, lazy or default. Within a module they are default, but once they leave a module they get given explicit values.
from derive.
oh ok.. thank you! I will read up on this behavior
from derive.
That behaviour is a complete guess - but it seems to fit with what we're seeing. I expect the two different modules is important.
from derive.
Fixed in 2.5.26. Thanks for the awesome test case!
from derive.
Related Issues (20)
- Add Aeson ToJSON/FromJSON
- Enum instances derived with TH crash with "Missing field in record construction
- Unnecessary context when deriving Monoid
- breakage with template-haskell-2.11 (in ghc-8) HOT 15
- to decrease build time, sources should be in separate src/ folder HOT 2
- Could not convert Dec to Decl HOT 2
- Convert to haskell-src-exts-1.18 HOT 20
- Errors while using C and GHC preprocessors HOT 1
- TH derivation doesn't work when the type name is qualified HOT 1
- Fails to build under newest derive HOT 3
- Build failure with GHC 8.2 HOT 3
- Example in Data.Derive.UniplateDirect fails HOT 8
- Parse Fails For pattern aliases (MINOR: see issue comments) HOT 3
- Could not convert Type to Kind () ConT GHC.Types.Nat HOT 1
- Could not convert Dec to Decl () HOT 2
- Hackage distribution lacks TestInstances HOT 1
- Could not convert Type to Type () HOT 1
- Upgrade to haskell-src-exts-1.20 HOT 1
- support haskell-src-exts-1.21+? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from derive.