From 7b8583d6494ffe6f8f78ac6b9f5927b5edd3959b Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Mon, 24 Nov 2014 02:07:13 +1100 Subject: Updated to make proper use of newtypes --- src/Grasp/IP.hs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src/Grasp/IP.hs') 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) -- cgit