[Haskell-beginners] Date type needs helper function?

Galaxy Being borgauf at gmail.com
Thu Jul 1 16:41:21 UTC 2021


I am using the built-in data type Day (Data.Time) in two ways

data PDate = PDate Day

or

type PDate Day

doesn't seem to matter. But then this doesn't work

testrec1 = PDate 2021 7 1

I always must use the "helper function" fromGregorian

testrec0 = PDate (fromGregorian 2021 7 1)
...
PDate 2021-07-01

Looking at Real World Haskell examples

data BookInfo = Book Int String [String]  deriving (Show)
...
myInfo = Book 9780135072455 "Algebra of Programming" ["Richard Bird", "Oege
de Moor"]

I know there's a great Haskell lesson to learn here, so why can Book take
everything naked but my Day version not?


⨽
Lawrence Bottorff
Grand Marais, MN, USA
borgauf at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20210701/3b27e204/attachment.html>


More information about the Beginners mailing list