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. Making a Tic-Tac-Toe Game (Sudhanshu Jaiswal)
2. Re: Understanding the function monad ((->) r) (Benjamin Edwards)
3. Re: Making a Tic-Tac-Toe Game (Theodore Lief Gannon)
4. Type error when using splitOn function. (S. H. Aegis)
----------------------------------------------------------------------
Message: 1
Date: Tue, 21 Feb 2017 22:05:25 +0530
From: Sudhanshu Jaiswal <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] Making a Tic-Tac-Toe Game
Message-ID:
<cac2ygferkbbfbubxpsm-7rmkevpnc9ofhufrdswnzpbn22y...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Also called as Noughts and crosses or Xs and Os.
Hello everyone,
How do I start making a *Two Player* Tic Tac Toe game in Haskell?
The program basically has to show the 3*3 grid as coordinates and let each
player choose his coordinates in his turn by entering the coordinates of
the required cell. I also want to be able to check if a player has won and
display it once the winning move has been made or the same for a Draw.
What have I done? - I have read Learn You a Haskell till Modules and know
basic I/O.
I don't want the code instead, I am interested in learning stuff and trying
problems which would lead me to get the intuition and ability to make the
game by myself.
I would be thankful if you folks could direct me to related problems which
I could do or some advice as to how I should go about implementing such a
program.
--
Sudhanshu
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20170221/c3e016d7/attachment-0001.html>
------------------------------
Message: 2
Date: Tue, 21 Feb 2017 18:06:00 +0000
From: Benjamin Edwards <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Understanding the function monad
((->) r)
Message-ID:
<can6k4njpnuyg2mrrrtwj_zvto1vwocmzq18ewc8r08ofsak...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
I did, sorry!
On Tue, 21 Feb 2017 at 15:53 Olumide <[email protected]> wrote:
> On 21/02/2017 15:08, Benjamin Edwards wrote:
> > The thing that you might also be missing is that function application
> > binds tightest. Hopefully the parenthesis that Rahul has added help you
> > out there. If not:
> >
> > \w -> f (h w) w
> >
> > f will be applied to the result of (h r) which yields another function,
> > which is then applied to r
>
> Did you mean to write (h w)?
>
> - Olumide
>
> _______________________________________________
> 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/20170221/f698420c/attachment-0001.html>
------------------------------
Message: 3
Date: Tue, 21 Feb 2017 23:18:55 -0800
From: Theodore Lief Gannon <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Making a Tic-Tac-Toe Game
Message-ID:
<cajopsubnoigpo2oxn92nbxwjhhlp8xngrobi-xhsa7+tw2m...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
I know you said you didn't want code, but I think this will be helpful.
Here is an example of what the very top of your logic might reasonably look
like.
main :: IO ()
main = do
someInitialization
config <- someConfigurator
result <- gameLoop $ makeInitialState config
print result
gameLoop :: GameState -> IO GameResult
gameLoop gameState =
let maybeEndState = discoverEndState gameState
in case maybeEndState of
Just endState -> return endState
Nothing -> do
playerMove <- fetchInput gameState
gameLoop $ makeNextState playerMove
On Tue, Feb 21, 2017 at 8:35 AM, Sudhanshu Jaiswal <[email protected]>
wrote:
> Also called as Noughts and crosses or Xs and Os.
>
> Hello everyone,
>
> How do I start making a *Two Player* Tic Tac Toe game in Haskell?
>
> The program basically has to show the 3*3 grid as coordinates and let each
> player choose his coordinates in his turn by entering the coordinates of
> the required cell. I also want to be able to check if a player has won and
> display it once the winning move has been made or the same for a Draw.
>
> What have I done? - I have read Learn You a Haskell till Modules and know
> basic I/O.
>
> I don't want the code instead, I am interested in learning stuff and
> trying problems which would lead me to get the intuition and ability to
> make the game by myself.
>
> I would be thankful if you folks could direct me to related problems which
> I could do or some advice as to how I should go about implementing such a
> program.
> --
> Sudhanshu
>
>
>
> _______________________________________________
> 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/20170221/7205ce91/attachment-0001.html>
------------------------------
Message: 4
Date: Wed, 22 Feb 2017 17:33:01 +0900
From: "S. H. Aegis" <[email protected]>
To: "[email protected]" <[email protected]>
Subject: [Haskell-beginners] Type error when using splitOn function.
Message-ID:
<CAJp-NqxW=cr-kbv8hecgv-rvbvckdzn88vgsixx5bb8vciq...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Hello.
I'm new to Haskell and this is the first time I use Data.Text module.
And using stack on OSX 10.12.3
I'm try several times, but fail. and I don't understand what error message
says.
How can I fix this?
Thank you a lot.
Code is
Main.hs :
module Main where
import Lib
main :: IO ()
main = do
sam <- readSam
rxDxData <- readCSV
print $ makeRxDxList rxDxData
Lib.hs :
module Lib
-- ( someFunc
-- ) where
where
import Data.Text as T
import Text.Regex.TDFA
import Prelude hiding (take, drop, map, lines)
type RowSAM = Text
type RowRxDx = Text
--makeRxDxList :: Functor f => f Text -> f [Text]
--makeRxDxList rowRxDx = fmap (\x -> splitOn (pack ",") x) rowRxDx -- This
code pass a compile.
makeRxDxList rowRxDx = map (\x -> splitOn (pack ",") pack x) $ lines rowRxDx
(whole code is below...)
Error Message is
/Users/shaegis/Documents/Haskell/samChecker3/src/Lib.hs:25:35: error:
• Couldn't match expected type ‘Char -> Char’
with actual type ‘[Text]’
• The function ‘splitOn’ is applied to three arguments,
but its type ‘Text -> Text -> [Text]’ has only two
In the expression: splitOn (pack ",") pack x
In the first argument of ‘map’, namely
‘(\ x -> splitOn (pack ",") pack x)’
/Users/shaegis/Documents/Haskell/samChecker3/src/Lib.hs:25:54: error:
• Couldn't match expected type ‘Text’
with actual type ‘String -> Text’
• Probable cause: ‘pack’ is applied to too few arguments
In the second argument of ‘splitOn’, namely ‘pack’
In the expression: splitOn (pack ",") pack x
In the first argument of ‘map’, namely
‘(\ x -> splitOn (pack ",") pack x)’
/Users/shaegis/Documents/Haskell/samChecker3/src/Lib.hs:25:64: error:
• Couldn't match expected type ‘Text’ with actual type ‘[Text]’
• In the second argument of ‘($)’, namely ‘lines rowRxDx’
In the expression:
map (\ x -> splitOn (pack ",") pack x) $ lines rowRxDx
In an equation for ‘makeRxDxList’:
makeRxDxList rowRxDx
= map (\ x -> splitOn (pack ",") pack x) $ lines rowRxDx
------------------------------------------------------------------------------------------------------
Lib.hs
module Lib
-- ( someFunc
-- ) where
where
import Data.Text as T
import Text.Regex.TDFA
import Prelude hiding (take, drop, map, lines)
type RowSAM = Text
type SAM = [Text]
type Case = Text
type RowRxDx = Text
type RxDx = [Text]
type RxDxList = [[Text]]
type Rx = Text
type Dx = Text
type MediName = Text
type Message = Text
type Date = Text
type PtName = Text
--makeRxDxList :: Functor f => f Text -> f [Text]
--makeRxDxList rowRxDx = fmap (\x -> splitOn (pack ",") x) rowRxDx
makeRxDxList rowRxDx = map (\x -> splitOn (pack ",") pack x) $ lines rowRxDx
pickupMediName :: RxDx -> MediName
pickupMediName rxDx = rxDx !! 0
pickupDx :: RxDx -> Dx
pickupDx rxDx = rxDx !! 2
pickupRx :: RxDx -> Rx
pickupRx rxDx = rxDx !! 1
pickupPtName :: Case -> PtName
pickupPtName ptCase = take 3 $ drop 45 ptCase
pickupCaseDate :: Case -> Date
pickupCaseDate ptCase = take 8 $ drop (348 + 2) ptCase
isErrorRxDx :: Rx -> Dx -> Case -> Bool
isErrorRxDx rxCode dxCode ptCase =
case isExistRx rxCode ptCase of
True -> if (isExistDx dxCode ptCase) then False else True
False -> False
isExistDx :: Dx -> Case -> Bool
isExistDx dxCode ptCase = (unpack ptCase) =~ (unpack dxCode)
isExistRx :: Rx -> Case -> Bool
isExistRx rxCode ptCase = rxCode `isInfixOf` ptCase
splitIntoCase :: RowSAM -> SAM
splitIntoCase = splitOn $ pack "AH021"
readCSV :: IO Text
readCSV = pack <$> readFile
"/Users/shaegis/Documents/Haskell/samChecker3/RxDxData.csv"
readSam :: IO Text
readSam = pack <$> readFile
"/Users/shaegis/Documents/Haskell/samChecker3/BoHomUTF8.dat"
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20170222/a1907d73/attachment.html>
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 104, Issue 13
******************************************