summaryrefslogtreecommitdiff
blob: c8eb28e6350a8ed62030674e4afc1d1e79cf3738 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
module Struct.Direction exposing (Type(..), opposite_of, to_string)

--------------------------------------------------------------------------------
-- TYPES -----------------------------------------------------------------------
--------------------------------------------------------------------------------
type Type =
   None
   | Left
   | Right
   | Up
   | Down

--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
opposite_of : Type -> Type
opposite_of d =
   case d of
      Left -> Right
      Right -> Left
      Up -> Down
      Down -> Up
      None -> None

to_string : Type -> String
to_string dir =
   case dir of
      Right -> "R"
      Left -> "L"
      Up -> "U"
      Down -> "D"
      None -> "N"