From f4c419b9ddec15bad267a4463f0720d6e28042d2 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Thu, 30 May 2019 12:18:08 +0200 Subject: Further work --- interactive-edit-lens/src/Main.hs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'interactive-edit-lens/src/Main.hs') diff --git a/interactive-edit-lens/src/Main.hs b/interactive-edit-lens/src/Main.hs index 83c9725..c816515 100644 --- a/interactive-edit-lens/src/Main.hs +++ b/interactive-edit-lens/src/Main.hs @@ -1,5 +1,6 @@ {-# LANGUAGE OverloadedStrings , ExistentialQuantification + , DeriveGeneric #-} module Main where @@ -30,18 +31,23 @@ import Debug.Trace import Data.Universe -data SomeDFST = forall state. (Ord state, Show state, Finite state) => SomeDFST { someDFST :: DFST state Char Char } +import Control.DeepSeq +import GHC.Generics (Generic) + +data SomeDFST = forall state. (Ord state, Show state, Finite state, NFData (DFSTComplement state Char Char)) => SomeDFST { someDFST :: DFST state Char Char } data JsonContext = JCInDet | JCDict | JCDictKey | JCDictVal | JCArray | JCArrayVal | JCTop - deriving (Eq, Ord, Show, Read, Enum, Bounded) + deriving (Eq, Ord, Show, Read, Enum, Bounded, Generic) instance Universe JsonContext instance Finite JsonContext +instance NFData JsonContext + data JsonNewlState = JNElement JsonContext | JNTrue String JsonContext | JNFalse String JsonContext | JNNull String JsonContext | JNLitEnd JsonContext | JNString JsonContext | JNStringEsc Int JsonContext | JNStringEnd JsonContext | JNNumberDigits Bool JsonContext | JNNumberDecimal JsonContext | JNNumberDecimalDigits Bool JsonContext | JNNumberExpSign JsonContext | JNNumberExpDigits Bool JsonContext | JNNumberEnd JsonContext - deriving (Eq, Ord, Show, Read) + deriving (Eq, Ord, Show, Read, Generic) instance Universe JsonNewlState where universe = concat [ JNElement <$> universeF @@ -63,6 +69,8 @@ instance Universe JsonNewlState where inits' xs = inits xs \\ [""] instance Finite JsonNewlState +instance NFData JsonNewlState + jsonStrEscapes :: [(Char, Seq Char)] jsonStrEscapes = [ ('"', "\\\"") , ('\\', "\\\\") @@ -78,10 +86,11 @@ hexDigits :: [Char] hexDigits = ['0'..'9'] ++ ['a'..'f'] data LineBreakState = LineBreak Int - deriving (Eq, Ord, Show, Read) + deriving (Eq, Ord, Show, Read, Generic) instance Universe LineBreakState where universe = [ LineBreak n | n <- [0..80] ] instance Finite LineBreakState +instance NFData LineBreakState dfstMap :: String -> Maybe SomeDFST dfstMap "double" = Just . SomeDFST $ DFST -- cgit v1.2.3