I recently began working on a new venture, QR Card Us to help support my education and fund another venture–it just launched tonight. This isn’t so much a sales pitch about that though as it is an announcement of an open-sourced Haskell module I wrote in the process (though, you’re certainly welcome to go check it out, tell your friends, and order some!).
As I was reading up on vCards, I found it most helpful to read RFC 2426. I wanted to easily play around with vCards in my favorite language, but didn’t care for the existing vCard module, so I decided to write my own instead, thus letting me announce hs-vcard. I think it’s fairly straight forward and well-documented, so I’ll end with an example input and the output.
This is the vCard for Frank Dawson, one of the RFC 2426 authors, constructed in Haskell:
1import Text.VCard 2 3vc = VCard "Frank Dawson" 4 (IndividualNames ["Dawson"] ["Frank"] [] [] []) 5 [ Organization ["Lotus Development Corporation"] 6 , Address [AddrWork, AddrPostal, AddrParcel] "" "" 7 "6544 Battleford Drive" 8 "Raleigh" "NC" "27613-3502" "U.S.A" 9 , Telephone [TelVoice, TelMessage, TelWork] "+1-919-676-9515" 10 , Telephone [TelFax, TelWork] "+1-919-676-9564" 11 , Email [EmailInternet, EmailPreferred] "Frank_Dawson@Lotus.com" 12 , Email [EmailInternet] "fdawson@earthlink.net" 13 , URL "http://home.earthlink.net/~fdawson" 14 ]
and printed out as:
BEGIN:vCard
VERSION:3.0
FN:Frank Dawson
N:Dawson;Frank;;;
ORG:Lotus Development Corporation
ADR;TYPE=WORK,POSTAL,PARCEL:;;6544 Battleford Drive;Raleigh;NC;27613-3502;U.S.A
TEL;TYPE=VOICE,MSG,WORK:+1-919-676-9515
TEL;TYPE=FAX,WORK:+1-919-676-9564
EMAIL;TYPE=INTERNET,PREF:Frank_Dawson@Lotus.com
EMAIL;TYPE=INTERNET:fdawson@earthlink.net
URL:http://home.earthlink.net/~fdawson
END:vCard
Please let me know if you find any problems, and even better: fix them and submit patches to the GitHub repository. I also chose to not implement reading them in, primarily because I had absolutely no use for that, but people are again welcome to contribute and do so.
I hope you find it useful! Please feel free to comment with any questions or feedback you might have on how I could do things better.
I like learning new things. Previously: Kenchi founder, eng & ops teams at Stripe from 2012-2019. Say hi! 🏳️🌈