[Haskell-cafe] Question about Newtype "op()" function arguments.
David Banas
capn.freako at gmail.com
Wed Jun 12 15:44:08 CEST 2013
Ah, so is the idea, then, to use *op()* when `n` wasn't actually
constructed formally, but rather "assembled" by the user, so as to match
the type of the accessor function normally supplied as the argument to the
constructor?
On 6/7/2013 4:51 PM, Tom Ellis wrote:
> On Fri, Jun 07, 2013 at 04:05:09PM -0400, Joe Q wrote:
>> The phantom parameter solves the same problem as scoped type variables.
>> Granted, if you find yourself in that kind of polymorphic soup you have
>> deeper problems...
> I don't understand this. Scoped type variables are used when you want to
> use a type variable from the top level within the body of a function. If
> you use "op" and specify a particular constructor then you don't have a
> variable but a concrete instance of a type. But maybe I'm missing some
more
> powerful way this can be used ...
>
> Tom
You can use scoped type variables to correct an ambiguous type error.
You can think of op as a variation on asTypeOf, as documented here on
http://www.haskell.org/haskellwiki/Scoped_type_variables#Avoiding_Scoped_Type_Variables
.
If I tried to come up with an example that's specific to op, it would
only be horribly contrived.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130612/63aad965/attachment.htm>
More information about the Haskell-Cafe
mailing list