Commit 4cba30e8 authored by MrMan's avatar MrMan

Over-specified Task type

parent a0f584ce
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Types where
import Data.Text
import Data.Functor.Identity
----------------
-- First Stab --
----------------
-- data TaskState = NotStarted | InProgress | Completed
-- data Task= Task { tName :: Text
-- , tDescription :: Text
-- , tState :: TaskState
-- }
---------------------
-- More Type Power --
---------------------
-- data TaskState = NotStarted
-- | InProgress
-- | Completed deriving (Enum, Read, Show)
-- data Task f = Task { tName :: f Text
-- , tDescription :: f Text
-- , tState :: f TaskState
-- }
-- type Complete f = f Identity
-- type Partial f = f Maybe
---------------
-- Too Much? --
---------------
-- data Completed
-- data InProgress
-- data NotStarted
-- data TaskState = Completed | InProgress | NotStarted
-- data Task f state = Task { tName :: f Text
-- , tDescription :: f Text
-- , tState :: f state
-- }
-- type Complete f = f Identity
-- type Partial f = f Maybe
-- type CompleteTask f = f Identity Completed
-- type IncompletePartialTask f = f Maybe InProgress
-- type IncompleteTask f = f Identity InProgress
-- type NotStartedPartialTask f = f Maybe NotStarted
-- type NotStartedTask f = f Identity NotStarted
-------------------------------------------
-- Definitely too much, but it compiles? --
-------------------------------------------
-- Individual separate types for tasks to enable specifying them as part of (Task f state)
data Finished = FinishedTask deriving (Eq, Read, Show)
data InProgress = InProgressTask deriving (Eq, Read, Show)
data NotStarted = NotStartedTask deriving (Eq, Read, Show)
-- Task state for abstracting over TaskState
data TaskState = Finished
| InProgress
| NotStarted deriving (Eq, Enum, Read, Show)
-- Newtypes preventing careless
newtype TaskName = TaskName { getTName :: Text } deriving (Eq, Show)
newtype TaskDesc = TaskDesc { getTDesc :: Text } deriving (Eq, Show)
-- The beefy task class
data Task f state = Task { tName :: f TaskName
, tDescription :: f TaskDesc
, tState :: f state
}
-- Completed tasks
type CompletedTask = Task Identity Finished
deriving instance Eq CompletedTask
deriving instance Show CompletedTask
-- Incomplete, partially specified tasks
type IncompletePartialTask = Task Maybe InProgress
deriving instance Eq IncompletePartialTask
deriving instance Show IncompletePartialTask
-- Incomplete, fully specified tasks
type IncompleteTask = Task Identity InProgress
deriving instance Eq IncompleteTask
deriving instance Show IncompleteTask
-- Not started, partially specified tasks
type NotStartedPartialTask = Task Maybe NotStarted
deriving instance Eq NotStartedPartialTask
deriving instance Show NotStartedPartialTask
-- Not started, completely specified tasks
type NotStartedTask = Task Identity NotStarted
deriving instance Eq NotStartedTask
deriving instance Show NotStartedTask
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment