Send Beginners mailing list submissions to
        beginners@haskell.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        beginners-requ...@haskell.org

You can reach the person managing the list at
        beginners-ow...@haskell.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1.  Simple data type for dates? (Galaxy Being)
   2. Re:  Simple data type for dates? (Matthew Low)


----------------------------------------------------------------------

Message: 1
Date: Tue, 29 Jun 2021 23:57:41 -0500
From: Galaxy Being <borg...@gmail.com>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Subject: [Haskell-beginners] Simple data type for dates?
Message-ID:
        <cafahfsupuzxidjrqz7ajdt-eokjptjfkloqyx9falc7ja6o...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

I've looked at Data.Time, but I'm not seeing examples. I'd like to figure
out how to simply have use of similar to this:

type MyMonth = String
type MyDay = String
type MyYear = String
data MyDate = MyDate MyMonth MyDay MyYear deriving Show

storeDate :: MyDate
storeDate = "June" "29" "2021"

which will be in a bigger data structure I'm building. I can't believe this
isn't reinventing some long-established wheel. Is there such a type ready
to use?

⨽
Lawrence Bottorff
Grand Marais, MN, USA
borg...@gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20210629/50ecd071/attachment-0001.html>

------------------------------

Message: 2
Date: Tue, 29 Jun 2021 23:31:47 -0600
From: Matthew Low <m...@ualberta.ca>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Subject: Re: [Haskell-beginners] Simple data type for dates?
Message-ID:
        <CAC=gtkzaabfyenh561ozwni8t7ftrrrsoaz5xcv-iqvtdlz...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

The `time` package equivalent of `MyDate` would be `Day`:

storeDate :: Day
storeDate = fromGregorian 2021 6 29

> storeDate
2021-06-29
> toGregorian storeDate
(2021,6,29)
> dayOfWeek storeDate
Tuesday

However, I don't see any easy conversion between the numeric month and its
English name.


On Tue, Jun 29, 2021 at 10:58 PM Galaxy Being <borg...@gmail.com> wrote:

> I've looked at Data.Time, but I'm not seeing examples. I'd like to figure
> out how to simply have use of similar to this:
>
> type MyMonth = String
> type MyDay = String
> type MyYear = String
> data MyDate = MyDate MyMonth MyDay MyYear deriving Show
>
> storeDate :: MyDate
> storeDate = "June" "29" "2021"
>
> which will be in a bigger data structure I'm building. I can't believe
> this isn't reinventing some long-established wheel. Is there such a type
> ready to use?
>
> ⨽
> Lawrence Bottorff
> Grand Marais, MN, USA
> borg...@gmail.com
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20210629/c48e21b3/attachment-0001.html>

------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 155, Issue 11
******************************************

Reply via email to