Hi All,
Referring to the following, which is taken from the Control.Newtype documentation page:
op :: Newtype n o => (o -> n) -> n -> oSource
This function serves two purposes:
- Giving you the unpack of a newtype without you needing to remember the name.
- Showing that the first parameter is completely ignored on the value level, meaning the only reason you pass in the constructor is to provide type information. Typeclasses sure are neat.
As point #2, above, emphasizes, the only purpose for the first argument to the function (i.e. - the constructor "(o -> n)") is to specify the type of 'n'. However, being a newtype, 'n' can have only one constructor. So, why is it necessary to pass in the constructor to this function, when we're already passing in 'n'?
Thanks,
-db