[Haskell-beginners] guards
Daniel Schoepe
daniel at schoepe.org
Fri Nov 11 01:21:58 CET 2011
On Thu, 10 Nov 2011 15:55:48 -0700, kolli kolli <nammukolli04 at gmail.com> wrote:
> I have to feame the code saying in IF t1 t2 t3
>
> If t1 has type x and if type of t2 == type of t3 then return type of t2 or
> t3
As Chaddaï said, the result of a call to typing has type Maybe Type
while TypeBool has type Type, so you would have to compare the result
with Just TypeBool, and not just TypeBool.
The same applies to "where x = typing capGamma t3". Here x already has
type Maybe Type, so passing it to Just would give you a value of type
Maybe (Maybe Type). This can be resolved by returning x directly in this
case:
... | typing capGama t1 == TypeBool && typing capGama t2 == x = x
A minor stylistic comment: It's common to write `Just TypeBool' instead
of `Just(TypeBool)', since a constructor is really just a (special kind
of) function.
Cheers,
Daniel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/beginners/attachments/20111111/d813f025/attachment.pgp>
More information about the Beginners
mailing list