[Haskell-beginners] data type
Alexander Chen
alexander at chenjia.nl
Fri May 29 09:55:31 UTC 2020
import Data.Time
data DatabaseItem = DbString String
| DbNumber Integer
| DbDate UTCTime
deriving (Eq, Ord, Show)
theDatabase :: [DatabaseItem]
theDatabase =
[ DbDate (UTCTime
(fromGregorian 1911 5 1)
(secondsToDiffTime 34250))
, DbNumber 9001
, DbString "Hello, world!"
, DbDate (UTCTime
(fromGregorian 1921 5 1)
(secondsToDiffTime 34123))
]
My question:
I want to get the UTCTime.
So, thisFunction :: [DatabaseItem] -> [UTCTime]
I don't need the answer but more the intuition (a link to a youtube etc. is also possible) how to handle these types of situations. Because i keep trying to think in terms of key:values (Python,Julia) which doesn't seem the right paradigm to approach this.
thanks in advance!
best,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20200529/0c160d43/attachment.html>
More information about the Beginners
mailing list