Move from store to flat

This commit is contained in:
2022-08-20 17:54:35 +01:00
parent 8571ab9254
commit ff9dbdf068
95 changed files with 793 additions and 748 deletions
+14 -9
View File
@@ -1,18 +1,24 @@
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TemplateHaskell #-}
module MaybeHelp where
import Control.Lens
import Data.Aeson
import Data.Store
import Flat
import GHC.Generics
import TH.Derive
import Data.Store
data Maybe' a = Just' {__Just' :: a} | Nothing'
deriving (Eq,Ord,Show,Read,Generic)
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance ToJSON a => ToJSON (Maybe' a) where
toEncoding = genericToEncoding defaultOptions
toEncoding = genericToEncoding defaultOptions
instance FromJSON a => FromJSON (Maybe' a)
fromJust' :: Maybe' a -> a
@@ -21,15 +27,15 @@ fromJust' mx = case mx of
Nothing' -> error "no fromJust'"
isJust' :: Maybe' a -> Bool
isJust' Just' {} = True
isJust' Just'{} = True
isJust' Nothing' = False
isNothing' :: Maybe' a -> Bool
isNothing' Just' {} = False
isNothing' Just'{} = False
isNothing' Nothing' = True
strictify :: Maybe a -> Maybe' a
strictify Nothing = Nothing'
strictify Nothing = Nothing'
strictify (Just x) = Just' x
toggleJust :: Maybe a -> Maybe ()
@@ -37,4 +43,3 @@ toggleJust Nothing = Just ()
toggleJust _ = Nothing
makeLenses ''Maybe'
$($(derive [d| instance (Store a => Deriving (Store (Maybe' a))) |]))