Move from store to flat
This commit is contained in:
+14
-9
@@ -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))) |]))
|
||||
|
||||
Reference in New Issue
Block a user