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. Re: Structural restrictions in type constructor (emacstheviking)
2. Re: Structural restrictions in type constructor (Matt Williams)
3. Function problem (Bruno Sotelo Klinec)
4. Re: Function problem (David McBride)
5. Re: Structural restrictions in type constructor (Rein Henrichs)
6. Re: Structural restrictions in type constructor (Petr V?penka)
----------------------------------------------------------------------
Message: 1
Date: Mon, 22 Jun 2015 14:51:19 +0100
From: emacstheviking <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Structural restrictions in type
constructor
Message-ID:
<CAEiEuULkeWVHxWRcauD7fG=sgeswt_4rhng9xk1bvigodtq...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
It *could* be done and might already have been done... I seem to recall a
few months back somebody asked for a similar feature using one of the
vector libraries, to limit one of the input vectors to a fixed length?
You'd have to dig through the list archives though...
On 22 June 2015 at 12:36, Imants Cekusins <[email protected]> wrote:
> > But this is checking the values in the implementation, not a type level
> build time guarantee, isn't it?
>
> yep, correct. Could be caught by unit tests though :-P
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150622/ac4c1960/attachment-0001.html>
------------------------------
Message: 2
Date: Mon, 22 Jun 2015 15:00:25 +0100
From: Matt Williams <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Structural restrictions in type
constructor
Message-ID:
<CAFTVGQaJXrOzyet8=at4l82x4vk1ph_xqwxpdyp91q7zqry...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
OK, I think this is clearly well beyond my level!
Will insert some manual checking.
Thanks,
Matt
On 22 June 2015 at 14:51, emacstheviking <[email protected]> wrote:
> It *could* be done and might already have been done... I seem to recall a
> few months back somebody asked for a similar feature using one of the
> vector libraries, to limit one of the input vectors to a fixed length?
>
> You'd have to dig through the list archives though...
>
> On 22 June 2015 at 12:36, Imants Cekusins <[email protected]> wrote:
>
>> > But this is checking the values in the implementation, not a type level
>> build time guarantee, isn't it?
>>
>> yep, correct. Could be caught by unit tests though :-P
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150622/9abf3213/attachment-0001.html>
------------------------------
Message: 3
Date: Mon, 22 Jun 2015 13:08:09 -0300
From: Bruno Sotelo Klinec <[email protected]>
To: "[email protected]" <[email protected]>
Subject: [Haskell-beginners] Function problem
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
Hi there! I was hoping you could help me a bit here with making a function. I
am asked to write functions to make a mini robot game, which uses these data
and types:
data Program = Move Direction Program
|Radar (Robot -> Point) Program
|Shoot Point Program
|Surrender
data Direction = N|S|E|O
type Point = (Int,Int)
data Robot = R1|R2
And then I have to write functions like this:
prog1::Program
prog1 = Move E $ Radar R1 (2,4) $ Radar R2 (5,6) $ Shoot (5,7) prog1
My problem is the function adjust::Direction->Program->Program that takes one
direction and a program and moves every shot in that program one unit in the
given direction. I can't figure out how to do this, I would really appreciate
you could help me, thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150622/eb5e9ce4/attachment-0001.html>
------------------------------
Message: 4
Date: Mon, 22 Jun 2015 12:35:05 -0400
From: David McBride <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Function problem
Message-ID:
<CAN+Tr431MO0rBDKUFME7nL3faZMUhZPVBA4GJ+qVmy11s=t...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
If you pass a program into this instruction, if it sees a shoot, it will
modify it slightly, if it is some other instruction, it will simply leave
the instruction unchanged, and then call itself on the rest of the
program. Use pattern matching to do this (untested code):
adjust :: Direction -> Program -> Direction
adjust dir (Shoot point next) = Shoot (adjustPoint dir point) $ adjust dir
next
where
adjustPoint :: Dir -> Point -> Point
adjustPoint N (x,y) = (x, y+1)
adjustPoint ... = ...
adjust dir (Move d next) = Move d $ adjust dir next
adjust ... = ...
adjust _ (Surrender) = Surrender
On Mon, Jun 22, 2015 at 12:08 PM, Bruno Sotelo Klinec <
[email protected]> wrote:
> Hi there! I was hoping you could help me a bit here with making a
> function. I am asked to write functions to make a mini robot game, which
> uses these data and types:
>
> data Program = Move Direction Program
> |Radar (Robot -> Point) Program
> |Shoot Point Program
> |Surrender
> data Direction = N|S|E|O
> type Point = (Int,Int)
> data Robot = R1|R2
>
> And then I have to write functions like this:
> prog1::Program
> prog1 = Move E $ Radar R1 (2,4) $ Radar R2 (5,6) $ Shoot (5,7) prog1
>
> My problem is the function adjust::Direction->Program->Program that takes
> one direction and a program and moves every shot in that program one unit
> in the given direction. I can't figure out how to do this, I would really
> appreciate you could help me, thanks!
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150622/c83d4acd/attachment-0001.html>
------------------------------
Message: 5
Date: Mon, 22 Jun 2015 19:09:36 +0000
From: Rein Henrichs <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Structural restrictions in type
constructor
Message-ID:
<cajp6g8wjyaky2tep9au+fjzf0rg0rzcoloas6poigxyj783...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
You can't do this at the type level in Haskell.
On Mon, Jun 22, 2015 at 7:00 AM Matt Williams <[email protected]>
wrote:
> OK, I think this is clearly well beyond my level!
>
> Will insert some manual checking.
>
> Thanks,
> Matt
>
> On 22 June 2015 at 14:51, emacstheviking <[email protected]> wrote:
>
>> It *could* be done and might already have been done... I seem to recall a
>> few months back somebody asked for a similar feature using one of the
>> vector libraries, to limit one of the input vectors to a fixed length?
>>
>> You'd have to dig through the list archives though...
>>
>> On 22 June 2015 at 12:36, Imants Cekusins <[email protected]> wrote:
>>
>>> > But this is checking the values in the implementation, not a type level
>>> build time guarantee, isn't it?
>>>
>>> yep, correct. Could be caught by unit tests though :-P
>>> _______________________________________________
>>> Beginners mailing list
>>> [email protected]
>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>>
>>
>>
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>
>>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150622/313a8943/attachment-0001.html>
------------------------------
Message: 6
Date: Mon, 22 Jun 2015 21:18:02 +0200
From: Petr V?penka <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Structural restrictions in type
constructor
Message-ID:
<candmeue72+w0a+cbqr-nre94x-oa9kytw6grmi+-ccwr1yz...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Maybe not exactly what you need but this was for me a kind of eye-opener
with regard to type system:
https://github.com/leonidas/codeblog/blob/master/2013/2013-02-19-typesafe-tictactoe.md
On Mon, Jun 22, 2015 at 9:09 PM, Rein Henrichs <[email protected]>
wrote:
> You can't do this at the type level in Haskell.
>
> On Mon, Jun 22, 2015 at 7:00 AM Matt Williams <
> [email protected]> wrote:
>
>> OK, I think this is clearly well beyond my level!
>>
>> Will insert some manual checking.
>>
>> Thanks,
>> Matt
>>
>> On 22 June 2015 at 14:51, emacstheviking <[email protected]> wrote:
>>
>>> It *could* be done and might already have been done... I seem to recall
>>> a few months back somebody asked for a similar feature using one of the
>>> vector libraries, to limit one of the input vectors to a fixed length?
>>>
>>> You'd have to dig through the list archives though...
>>>
>>> On 22 June 2015 at 12:36, Imants Cekusins <[email protected]> wrote:
>>>
>>>> > But this is checking the values in the implementation, not a type
>>>> level
>>>> build time guarantee, isn't it?
>>>>
>>>> yep, correct. Could be caught by unit tests though :-P
>>>> _______________________________________________
>>>> Beginners mailing list
>>>> [email protected]
>>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>>>
>>>
>>>
>>> _______________________________________________
>>> Beginners mailing list
>>> [email protected]
>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>>
>>>
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150622/a2d23226/attachment.html>
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 84, Issue 37
*****************************************