diff options
author | Jed Barber <jjbarber@y7mail.com> | 2014-11-24 02:07:13 +1100 |
---|---|---|
committer | Jed Barber <jjbarber@y7mail.com> | 2014-11-24 02:07:13 +1100 |
commit | 7b8583d6494ffe6f8f78ac6b9f5927b5edd3959b (patch) | |
tree | 81d05fb413eb1a99d82006e18ff620379ee9edc0 /src/Grasp/IP.hs | |
parent | 92e5783f59ae689cf8b2da6a6e68f6b1e48b405e (diff) |
Updated to make proper use of newtypes
Diffstat (limited to 'src/Grasp/IP.hs')
-rw-r--r-- | src/Grasp/IP.hs | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/Grasp/IP.hs b/src/Grasp/IP.hs index 7b70e21..efb904d 100644 --- a/src/Grasp/IP.hs +++ b/src/Grasp/IP.hs @@ -10,27 +10,30 @@ module Grasp.IP ( -import Grasp.Node( GNode ) -import qualified Grasp.Node as GN +import Grasp.Types( GNode ) -type IP = [GNode] + + +newtype IP = IP [GNode] + deriving (Eq, Show) + singleton :: GNode -> IP -singleton = (:[]) +singleton n = IP [n] peek :: IP -> GNode -peek = head +peek (IP p) = head p push :: GNode -> IP -> IP -push = (:) +push n (IP p) = IP (n:p) pop :: IP -> IP -pop = tail +pop (IP p) = IP (tail p) isEmpty :: IP -> Bool -isEmpty = (==[]) +isEmpty (IP p) = (length p == 0) |