[Haskell-beginners] Expose every Function of a wrapped type

Leonhard Applis Leonhard.Applis at protonmail.com
Fri Nov 15 11:36:03 UTC 2019


Hi, 

I currently have a newtype definition of a typed Data.Map. 

newtype G = G Data.Map String Values 

I have done this because for my specific use-case, I can define G as a monoid and get some nice benefits. 

However, I find myself often just re-declaring functions of Data.Map and wrap/unwrap them in my Constructor G, such as 

singleton :: String -> Value -> G
singleton s v = G $ (Data.Map.singleton s v) 

I think I do not need to limit the scope of G's functionality, I basically want everything from Data.Map + Bonus , like my Monoid. 
Also I want G to be a specific Data.Map, there is never any other case where it's not a Map String Values. 

However, if I have 

type G2 = Data.Map String Values 

I cannot instance Monoid. 

So, I am very sure that I'm not the first person ever doing this. Is there a language extension providing what I want? Or is what i want "bad"?
Am I just missing a higher-order base function which does what I want?

best regards & thanks
Leonhard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20191115/904e640f/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: publickey - Leonhard.Applis at protonmail.com - 0x807FDDF3.asc
Type: application/pgp-keys
Size: 1843 bytes
Desc: not available
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20191115/904e640f/attachment.key>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 477 bytes
Desc: OpenPGP digital signature
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20191115/904e640f/attachment.sig>


More information about the Beginners mailing list