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:  Dipping Toes Into Haskell (Timothy Washington)
   2. Re:  Dipping Toes Into Haskell (Timothy Washington)
   3.  Problems installing lambdabot (Joel Neely)


----------------------------------------------------------------------

Message: 1
Date: Thu, 12 Mar 2015 20:14:30 -0400
From: Timothy Washington <[email protected]>
To: [email protected],  The Haskell-Beginners Mailing
        List - Discussion of primarily beginner-level topics related to
        Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Dipping Toes Into Haskell
Message-ID:
        <CAADtM-a=5pv8pu_yb8mcepscfdu_kjcmw9dvgiuvams1ayv...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Good explanation. Thank-you.


Tim Washington
Interruptsoftware.com <http://interruptsoftware.com>


On Thu, Mar 12, 2015 at 7:50 PM, Sumit Sahrawat, Maths & Computing, IIT
(BHU) <[email protected]> wrote:

> data Piece = X | O
>
> means that X and O are constants, having data type 'Piece'.
> In other words, you directly use X and O instead of Piece X and Piece O.
>
> Piece is a type, and X and O are constructors (or simply the two possible
> values).
>
> A good similar example is the Bool type,
>
>     data Bool = False | True
>     -- Two possible values, i.e. False and True
>
> For more info, take a look here:
> http://en.wikibooks.org/wiki/Haskell/Type_declarations
>
> Also, to make life easier, you might want to use:
>
>     data Piece = X | O
>       deriving Show -- Make this type showable
>
> With this, you will be able to use 'print' with elements of this datatype.
>
> For a tutorial on setting up emacs, take a look here:
> https://github.com/serras/emacs-haskell-tutorial/blob/master/tutorial.md
>
> For updating nested lists, you have to create a function that takes two
> numbers (the positions) and iterates over the whole structure, just
> updating the required position.
> While this may seem like an overkill, it gets optimized by ghc.
>
> I don't have any experience with lenses, but they should be usable here.
> Understanding them will require a good understanding of the type system.
>
> On 13 March 2015 at 04:32, Timothy Washington <[email protected]> wrote:
>
>> To get started, I'm trying to implement a simple *tictactoe* game. And I
>> would like to be able to represent a Piece on the board, as either the
>> string "X" or "O". This is what I have so far.
>>
>> module Main where
>>
>> data Piece = X | O
>> type Row = [Piece]
>> type Board = [Row]
>>
>> -- put an X or O in a position
>> move :: Board -> Piece -> Board
>> move board piece = board
>>
>> -- check win vertically
>> -- check win horizontally
>> -- check win diagonally
>>
>> main :: IO ()
>> main = putStrLn "Hello World"
>>
>>
>>
>> *A)* Now, I'd like to be able to *load code interactively*, preferably
>> within emacs. However I don't have access to my types with *ghci* or *ghc-mod
>> (Interactive-Haskell)*. In either case, this call fails with the below
>> error.
>>
>>
>> let p = Piece X
>> <interactive>:20:9-13: Not in scope: data constructor `Piece'
>>
>>
>> *B)* And how do I make a *custom datatype* that's one of two strings
>> (enumeration of either "X" or "O"). Cabal builds and runs the abouve code,
>> so I know it can compile. But I'm confused as to where X or O is defined,
>> and how I would supply it as an input.
>>
>> *C)* Finally, how do we update nested lists in Haskell. I want the move
>> function to take a Board, Piece, and Position, and return a Board. I see
>> some results from Hoogle <https://www.haskell.org/hoogle/?hoogle=update>.
>> Is this where Lenses <https://www.haskell.org/hoogle/?hoogle=lens> or
>> Zippers <https://www.haskell.org/hoogle/?hoogle=zipper> come into play?
>>
>>
>> Thanks
>>
>> Tim Washington
>> Interruptsoftware.com <http://interruptsoftware.com>
>>
>>
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>
>>
>
>
> --
> Regards
>
> Sumit Sahrawat
>
> _______________________________________________
> 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/20150312/1c10b5b0/attachment-0001.html>

------------------------------

Message: 2
Date: Thu, 12 Mar 2015 20:15:14 -0400
From: Timothy Washington <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Dipping Toes Into Haskell
Message-ID:
        <caadtm-azd8bkf-26dh3repow+rujh1awwupay2kceq6whui...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Thank-you :) And thanks for the Data.List docs. That's a good place to
start.


Tim Washington
Interruptsoftware.com <http://interruptsoftware.com>


On Thu, Mar 12, 2015 at 7:53 PM, Kim-Ee Yeoh <[email protected]> wrote:

> Hi Tim,
>
> Congrats on your choice of tic-tac-toe. I also believe it's a good toy to
> get your feet wet with haskell.
>
> 1. Your concerns about writing a "custom datatype" are best addressed by
> reading up on it. If you search for "haskell data type declarations",
> you'll find good material explaining the difference between "data",
> "newtype", and "type" declarations. You'll also understand the meaning of
> the error message and what "data constructor" refers to.
>
> 2. Functions defined on lists are here:
>
> https://hackage.haskell.org/package/base/docs/Data-List.html
>
> The update function you're looking for is (!!).
>
>
>
>
> -- Kim-Ee
>
> On Fri, Mar 13, 2015 at 6:02 AM, Timothy Washington <[email protected]>
> wrote:
>
>> To get started, I'm trying to implement a simple *tictactoe* game. And I
>> would like to be able to represent a Piece on the board, as either the
>> string "X" or "O". This is what I have so far.
>>
>> module Main where
>>
>> data Piece = X | O
>> type Row = [Piece]
>> type Board = [Row]
>>
>> -- put an X or O in a position
>> move :: Board -> Piece -> Board
>> move board piece = board
>>
>> -- check win vertically
>> -- check win horizontally
>> -- check win diagonally
>>
>> main :: IO ()
>> main = putStrLn "Hello World"
>>
>>
>>
>> *A)* Now, I'd like to be able to *load code interactively*, preferably
>> within emacs. However I don't have access to my types with *ghci* or *ghc-mod
>> (Interactive-Haskell)*. In either case, this call fails with the below
>> error.
>>
>>
>> let p = Piece X
>> <interactive>:20:9-13: Not in scope: data constructor `Piece'
>>
>>
>> *B)* And how do I make a *custom datatype* that's one of two strings
>> (enumeration of either "X" or "O"). Cabal builds and runs the abouve code,
>> so I know it can compile. But I'm confused as to where X or O is defined,
>> and how I would supply it as an input.
>>
>> *C)* Finally, how do we update nested lists in Haskell. I want the move
>> function to take a Board, Piece, and Position, and return a Board. I see
>> some results from Hoogle <https://www.haskell.org/hoogle/?hoogle=update>.
>> Is this where Lenses <https://www.haskell.org/hoogle/?hoogle=lens> or
>> Zippers <https://www.haskell.org/hoogle/?hoogle=zipper> come into play?
>>
>>
>> Thanks
>>
>> Tim Washington
>> Interruptsoftware.com <http://interruptsoftware.com>
>>
>>
>> _______________________________________________
>> 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/20150312/91f26cf3/attachment-0001.html>

------------------------------

Message: 3
Date: Fri, 13 Mar 2015 06:53:05 -0500
From: Joel Neely <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: [Haskell-beginners] Problems installing lambdabot
Message-ID:
        <caeezxagbyxntf6vhyautf3pmnu2a8bcwiyhp5mjrm1fddg7...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

I am using a recent install of Haskell platform (GHC/GHCi version 7.8.3) in
OS X 10.9.5, and have been working through Real World Haskell and last
year's CIS194 lectures and exercises.

I attempted to follow the instructions for installing lambdabot (as given
by https://wiki.haskell.org/Lambdabot ) via cabal install lambdabot.

After 24 1/2 minutes, the process ended with a little over a dozen error
messages apparently tracing to two occurrences of ExitFailure 1:

MonadRandom-0.3.0.1 failed during the building phase. The exception was:

ExitFailure 1

regex-pcre-0.94.4 failed during the building phase. The exception was:

ExitFailure 1

?The remaining messages were from components dependent on one or the other
of those two.

The logged failure for regex-pcre-0.94.4 ?included the following:

Preprocessing library regex-pcre-0.94.4...
Wrap.hsc:148:10: fatal error: 'pcre.h' file not found
#include <pcre.h>
         ^
1 error generated.
compiling dist/build/Text/Regex/PCRE/Wrap_hsc_make.c failed (exit code 1)


?and for MonadRandom-0.3.0.1 included:

Preprocessing library MonadRandom-0.3.0.1...
[1 of 2] Compiling Control.Monad.Random.Class (
Control/Monad/Random/Class.hs, dist/build/Control/Monad/Random/Class.o )
[2 of 2] Compiling Control.Monad.Random ( Control/Monad/Random.hs,
dist/build/Control/Monad/Random.o )
[1 of 2] Compiling Control.Monad.Random.Class (
Control/Monad/Random/Class.hs, dist/build/Control/Monad/Random/Class.p_o )
[2 of 2] Compiling Control.Monad.Random ( Control/Monad/Random.hs,
dist/build/Control/Monad/Random.p_o )
/Users/joel/.ghc/x86_64-darwin-7.8.3/package.conf.d/package.cache:
openBinaryFile: does not exist (No such file or directory)

?
?I am at a loss for corrective actions. I would assume that I need to
locate the pcre.h header file and put it in the "right place"?, but was
unable to find the location of Wrap_hsc_make.c. And I don't know how to
address the non-existence of openBinaryFile in package.cache.

Thanks in advance for any advice on correcting the above problems!

-jn-


-- 
Beauty of style and harmony and grace and good rhythm depend on simplicity.
- Plato
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20150313/f8a5c974/attachment.html>

------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 81, Issue 40
*****************************************

Reply via email to