[Haskell-cafe] comprehension problem
ptrash
ptrash at web.de
Sun Jun 7 13:39:15 EDT 2009
Cool, thanks a lot.
Ross Mellgren wrote:
>
> P Float is the constructor to create a value of this type, similar to
> data declarations.
>
> That is, 0.5 :: Float, P 0.5 :: Probability
>
> The {} notation after D creates a record accessor, also similar to
> data declarations. It's equivalent to making an unD that unwraps the
> value yourself:
>
> newtype Dist a = D { unD :: [(a, Probability)] }
>
> is the same as
>
> newtype Dist a = D [(a, Probability)]
>
> unD :: Dist a -> [(a, Probability)]
> unD (D x) = x
>
> a in Dist a is a type variable, for example you could have Dist Float
> (containing [(Float, Probability)]), or Dist String (containing
> [(String, Probability)])
>
> -Ross
>
> On Jun 3, 2009, at 4:01 PM, ptrash wrote:
>
>>
>> Hi,
>>
>> what does this to code rows mean:
>>
>> newtype Probability = P Float
>> newtype Dist a = D {unD :: [(a, Probability)]}
>>
>> newtype definies a new type called Probability. But what does P
>> Float mean?
>>
>> And what is the a in Dist a?
>> What does D {...} mean?
>>
>> Thanks for your help.
>> --
>> View this message in context:
>> http://www.nabble.com/comprehension-problem-tp23858359p23858359.html
>> Sent from the Haskell - Haskell-Cafe mailing list archive at
>> Nabble.com.
>>
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
--
View this message in context: http://www.nabble.com/comprehension-problem-tp23858359p23913380.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
More information about the Haskell-Cafe
mailing list