summaryrefslogtreecommitdiff
path: root/interactive-edit-lens/src/Main.hs
diff options
context:
space:
mode:
Diffstat (limited to 'interactive-edit-lens/src/Main.hs')
-rw-r--r--interactive-edit-lens/src/Main.hs17
1 files changed, 13 insertions, 4 deletions
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 @@
1{-# LANGUAGE OverloadedStrings 1{-# LANGUAGE OverloadedStrings
2 , ExistentialQuantification 2 , ExistentialQuantification
3 , DeriveGeneric
3 #-} 4 #-}
4 5
5module Main where 6module Main where
@@ -30,18 +31,23 @@ import Debug.Trace
30 31
31import Data.Universe 32import Data.Universe
32 33
33data SomeDFST = forall state. (Ord state, Show state, Finite state) => SomeDFST { someDFST :: DFST state Char Char } 34import Control.DeepSeq
35import GHC.Generics (Generic)
36
37data SomeDFST = forall state. (Ord state, Show state, Finite state, NFData (DFSTComplement state Char Char)) => SomeDFST { someDFST :: DFST state Char Char }
34 38
35data JsonContext = JCInDet | JCDict | JCDictKey | JCDictVal | JCArray | JCArrayVal | JCTop 39data JsonContext = JCInDet | JCDict | JCDictKey | JCDictVal | JCArray | JCArrayVal | JCTop
36 deriving (Eq, Ord, Show, Read, Enum, Bounded) 40 deriving (Eq, Ord, Show, Read, Enum, Bounded, Generic)
37instance Universe JsonContext 41instance Universe JsonContext
38instance Finite JsonContext 42instance Finite JsonContext
39 43
44instance NFData JsonContext
45
40data JsonNewlState = JNElement JsonContext 46data JsonNewlState = JNElement JsonContext
41 | JNTrue String JsonContext | JNFalse String JsonContext | JNNull String JsonContext | JNLitEnd JsonContext 47 | JNTrue String JsonContext | JNFalse String JsonContext | JNNull String JsonContext | JNLitEnd JsonContext
42 | JNString JsonContext | JNStringEsc Int JsonContext | JNStringEnd JsonContext 48 | JNString JsonContext | JNStringEsc Int JsonContext | JNStringEnd JsonContext
43 | JNNumberDigits Bool JsonContext | JNNumberDecimal JsonContext | JNNumberDecimalDigits Bool JsonContext | JNNumberExpSign JsonContext | JNNumberExpDigits Bool JsonContext | JNNumberEnd JsonContext 49 | JNNumberDigits Bool JsonContext | JNNumberDecimal JsonContext | JNNumberDecimalDigits Bool JsonContext | JNNumberExpSign JsonContext | JNNumberExpDigits Bool JsonContext | JNNumberEnd JsonContext
44 deriving (Eq, Ord, Show, Read) 50 deriving (Eq, Ord, Show, Read, Generic)
45instance Universe JsonNewlState where 51instance Universe JsonNewlState where
46 universe = concat 52 universe = concat
47 [ JNElement <$> universeF 53 [ JNElement <$> universeF
@@ -63,6 +69,8 @@ instance Universe JsonNewlState where
63 inits' xs = inits xs \\ [""] 69 inits' xs = inits xs \\ [""]
64instance Finite JsonNewlState 70instance Finite JsonNewlState
65 71
72instance NFData JsonNewlState
73
66jsonStrEscapes :: [(Char, Seq Char)] 74jsonStrEscapes :: [(Char, Seq Char)]
67jsonStrEscapes = [ ('"', "\\\"") 75jsonStrEscapes = [ ('"', "\\\"")
68 , ('\\', "\\\\") 76 , ('\\', "\\\\")
@@ -78,10 +86,11 @@ hexDigits :: [Char]
78hexDigits = ['0'..'9'] ++ ['a'..'f'] 86hexDigits = ['0'..'9'] ++ ['a'..'f']
79 87
80data LineBreakState = LineBreak Int 88data LineBreakState = LineBreak Int
81 deriving (Eq, Ord, Show, Read) 89 deriving (Eq, Ord, Show, Read, Generic)
82instance Universe LineBreakState where 90instance Universe LineBreakState where
83 universe = [ LineBreak n | n <- [0..80] ] 91 universe = [ LineBreak n | n <- [0..80] ]
84instance Finite LineBreakState 92instance Finite LineBreakState
93instance NFData LineBreakState
85 94
86dfstMap :: String -> Maybe SomeDFST 95dfstMap :: String -> Maybe SomeDFST
87dfstMap "double" = Just . SomeDFST $ DFST 96dfstMap "double" = Just . SomeDFST $ DFST