Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Matrix and types (mike h)
2. Re: Matrix and types (Francesco Ariis)
----------------------------------------------------------------------
Message: 1
Date: Thu, 14 Mar 2019 11:10:06 +0000
From: mike h <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: [Haskell-beginners] Matrix and types
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"
Hi,
As an exercise I want to write a Matrix library.
Multiplication of two matrices is only defined when the the number of columns
in the first matrix
equals the number of rows in the second matrix. i.e. c1 == r2
So when writing the multiplication function I can check that c1 == r2 and do
something.
However what I really want to do, if possible, is to have the compiler catch
the error.
I’d appreciate any advice on how to approach this. I don’t want a full
description of exactly what to do as that way I won’t have struggled or argued
with the compiler - which for me is the best way to learn Haskell :)
Thanks
Mike
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20190314/05213318/attachment-0001.html>
------------------------------
Message: 2
Date: Thu, 14 Mar 2019 12:37:20 +0100
From: Francesco Ariis <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] Matrix and types
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
Hello Mike,
On Thu, Mar 14, 2019 at 11:10:06AM +0000, mike h wrote:
> Multiplication of two matrices is only defined when the the number of columns
> in the first matrix
> equals the number of rows in the second matrix. i.e. c1 == r2
>
> So when writing the multiplication function I can check that c1 == r2 and do
> something.
> However what I really want to do, if possible, is to have the compiler catch
> the error.
Type-level literals [1] or any kind of similar trickery should help you
with having matrices checked at compile-time.
[1]
https://downloads.haskell.org/~ghc/7.10.1/docs/html/users_guide/type-level-literals.html
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 129, Issue 3
*****************************************