How would you implement something like this in haskell?

how would you implement something like this in haskell?

Attached: 2018-04-23-165900_289x291_scrot.png (289x291, 23K)

Bump

I have no idea OP

You would put the player as a state in a StateT monad transformer. Read up on it, and the rest becomes relatively obvious.
t. currently failing a haskell course on uni

```haskell
data Player = Player Int Int

showPos :: Player -> IO ()
showPos (Player x y) = println (x, y)

moveNorth :: Player -> Player
moveNorth (Player x y) = Player (x + 1) y

```

>move_north
>x += 1

Thats East you fucking moron.

you don't because you shouldn't use haskell

did you just assume his coordinate system?!

Just represent the players with a ring of infinite dimension and work from here, we are not here to do your homework.

kek

In opengl it's
Y -> up
X -> right
Z -> towards screen
But this changes if you do any kind of matrix transformation. How do you know he hasn't?

interface IPlayer {
int x { get; }
int y { get; }
}
class Player : IPlayer {
public int x { get {
return 0;
} }
public int y { get {
return 0;
} }
}
class MovedPlayer : IPlayer {
private IPlayer origin;
private int xm, ym;
public MovedPlayer(IPlayer p, int _x, int _y) {
origin = p;
xm = _x; ym = _y;
}
public int x { get {
return origin.x + xm;
} }
public int y { get {
return origin.y + ym;
} }
}
class ShowPlayer: IPlayer {
private IPlayer origin;
public ShowPlayer(IPlayer p) {
origin = p;
}
public int x { get {
return origin.x;
} }
public int y { get {
return origin.y;
} }
public showPos() {
Console.WriteLine("x: {0}; y: {1}", x, y);
}
}

because he comes to Jow Forums to have his problems solved. Therefore, he must be a moron, hence the usage of the word moron in my previous post.

dude wtf

>Int Int
for wat pvrpose?

Carmack and his son did some gamedev in functional languages, maybe search that for inspiraro.

data Player = Player Int Int
moveNorth (Player x y) = Player (x + 1) y
new_player = Player 0 0

data Game = Game { p1 :: Player
, p2 :: Player
}

instance Show Player where
show (Player x y) = show x ++ " " ++ show y ++ "\n"

instance Show Game where
show g = show (p1 g) ++ " " ++ show (p2 g)

mainLoop game = Game {
p1 = moveNorth (p1 game),
p2 = (p2 game)
}

initial_state = Game {
p1 = new_player,
p2 = new_player
}

main = do
let gameactions = iterate mainLoop initial_state
print $ take 5 gameactions

Attached: 1522356355293.jpg (728x664, 53K)

Those are x and y. Look up algebraic data types.

Tллл

no it's longitude and latitude

I heard about this, but he didn't release his code didn't he?

probably a cartesian

i'll let you know i identify as transpolar

he could've done it using record syntax for additional clarity
data Player = Player { getX :: Int, getY :: Int }

Literally "like this". You can't. Haskell lacks OOP constructs. You can approximate it poorly with some useless academic jerk off pure functional bullshit but you won't achieve the beautiful simplicity the creators of Smalltalk envisioned for 21st century programming Haskell fags so diligently spit on.

Alan Kay considers a functional language, Lisp, as a perfect example of an OO language. If you don't understand even that, then you have no business talking about Haskell. And if you don't know who Alan Kay is, well, you don't have any business talking about OOP either lol

Lisp is not pure functional like Haskell, and as such has constructs which make writing OOP code much easier. CLOS for Common lisp is a great example. Also my post was bait, I have used Haskell Servant to write some web services for lulz.

My actual thoughts on Haskell are that the language needs to split to a better newer spec because having to add a shitton of extensions to get the most basic acceptable efficiency is fucking pathetic.

fair enough

You need to repost this in a few days and say "The isn't possible in haskell" and you'll have people crawling out of the woodwork to prove you wrong.

fucking gross

Brainlet here, how you do this in the haskell
for (int i = 0; i < 3; i++) {
do.something;
}

Attached: pile-of-poo_1f4a9.png (160x160, 24K)