Naming conventions for newtype deconstructors (destructors?)
Posted
by
Petr Pudlák
on Programmers
See other posts from Programmers
or by Petr Pudlák
Published on 2012-10-12T11:51:27Z
Indexed on
2012/10/12
15:48 UTC
Read the original article
Hit count: 245
coding-standards
|haskell
Looking into Haskell's standard library we can see:
newtype StateT s m a = StateT { runStateT :: s -> m (a, s) }
newtype WrappedMonad m a = WrapMonad { unwrapMonad :: m a }
newtype Sum a = Sum { getSum :: a }
Apparently, there (at least) 3 different prefixes used to unwrap a value inside a newtype
: un-, run- and get-. (Moreover run- and get- capitalizes the next letter while un- doesn't.) This seems confusing.
- Are there any reasons for that, or is that just a historical thing?
- If I design my own
newtype
, what prefix should I use and why?
© Programmers or respective owner