From 6513755670892983db88a6633b8c1ea6019c03d1 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Fri, 15 Nov 2024 14:55:37 -0500 Subject: Re-namespace some stuff to Omni I was getting confused about what is a product and what is internal infrastructure; I think it is good to keep those things separate. So I moved a bunch of stuff to an Omni namespace, actually most stuff went there. Only things that are explicitly external products are still in the Biz namespace. --- Biz/Id.hs | 56 -------------------------------------------------------- 1 file changed, 56 deletions(-) delete mode 100644 Biz/Id.hs (limited to 'Biz/Id.hs') diff --git a/Biz/Id.hs b/Biz/Id.hs deleted file mode 100644 index 344149d..0000000 --- a/Biz/Id.hs +++ /dev/null @@ -1,56 +0,0 @@ -{-# LANGUAGE DeriveDataTypeable #-} -{-# LANGUAGE DeriveGeneric #-} -{-# LANGUAGE NoImplicitPrelude #-} - --- Integer-based identifier. -module Biz.Id - ( Id (..), - mk, - untag, - ) -where - -import Alpha -import Data.Aeson (FromJSON (..), ToJSON (..)) -import Data.Binary (Binary) -import Data.Data (Data) -import Servant (FromHttpApiData (..), ToHttpApiData (..)) - -newtype Id entity = Id Int - deriving (Eq, Ord, Show, Generic, Typeable, Data) - -mk :: proxy entity -> Int -> Id entity -mk _ = Id - -untag :: Id entity -> Int -untag (Id i) = i - -instance Hashable (Id entity) - -instance Binary (Id entity) - -instance Enum (Id entity) where - toEnum = mk (Proxy :: Proxy entity) - fromEnum = untag - -instance NFData (Id entity) where - rnf (Id s) = rnf s - -instance FromJSON (Id entity) where - parseJSON = fmap Id <. parseJSON - -instance ToJSON (Id entity) where - toJSON = toJSON <. untag - --- this is just provided to satisfy Monoid, no reason to actually use it -instance Semigroup (Id entity) where - a <> b = mk (Proxy :: Proxy entity) <| untag a + untag b - -instance Monoid (Id entity) where - mempty = mk (Proxy :: Proxy entity) 0 - -instance FromHttpApiData (Id entity) where - parseUrlPiece p = mk (Proxy :: Proxy entity) tshow -- cgit v1.2.3