diff options
Diffstat (limited to 'interactive-edit-lens/src/Main.hs')
-rw-r--r-- | interactive-edit-lens/src/Main.hs | 17 |
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 | ||
5 | module Main where | 6 | module Main where |
@@ -30,18 +31,23 @@ import Debug.Trace | |||
30 | 31 | ||
31 | import Data.Universe | 32 | import Data.Universe |
32 | 33 | ||
33 | data SomeDFST = forall state. (Ord state, Show state, Finite state) => SomeDFST { someDFST :: DFST state Char Char } | 34 | import Control.DeepSeq |
35 | import GHC.Generics (Generic) | ||
36 | |||
37 | data SomeDFST = forall state. (Ord state, Show state, Finite state, NFData (DFSTComplement state Char Char)) => SomeDFST { someDFST :: DFST state Char Char } | ||
34 | 38 | ||
35 | data JsonContext = JCInDet | JCDict | JCDictKey | JCDictVal | JCArray | JCArrayVal | JCTop | 39 | data 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) |
37 | instance Universe JsonContext | 41 | instance Universe JsonContext |
38 | instance Finite JsonContext | 42 | instance Finite JsonContext |
39 | 43 | ||
44 | instance NFData JsonContext | ||
45 | |||
40 | data JsonNewlState = JNElement JsonContext | 46 | data 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) |
45 | instance Universe JsonNewlState where | 51 | instance 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 \\ [""] |
64 | instance Finite JsonNewlState | 70 | instance Finite JsonNewlState |
65 | 71 | ||
72 | instance NFData JsonNewlState | ||
73 | |||
66 | jsonStrEscapes :: [(Char, Seq Char)] | 74 | jsonStrEscapes :: [(Char, Seq Char)] |
67 | jsonStrEscapes = [ ('"', "\\\"") | 75 | jsonStrEscapes = [ ('"', "\\\"") |
68 | , ('\\', "\\\\") | 76 | , ('\\', "\\\\") |
@@ -78,10 +86,11 @@ hexDigits :: [Char] | |||
78 | hexDigits = ['0'..'9'] ++ ['a'..'f'] | 86 | hexDigits = ['0'..'9'] ++ ['a'..'f'] |
79 | 87 | ||
80 | data LineBreakState = LineBreak Int | 88 | data LineBreakState = LineBreak Int |
81 | deriving (Eq, Ord, Show, Read) | 89 | deriving (Eq, Ord, Show, Read, Generic) |
82 | instance Universe LineBreakState where | 90 | instance Universe LineBreakState where |
83 | universe = [ LineBreak n | n <- [0..80] ] | 91 | universe = [ LineBreak n | n <- [0..80] ] |
84 | instance Finite LineBreakState | 92 | instance Finite LineBreakState |
93 | instance NFData LineBreakState | ||
85 | 94 | ||
86 | dfstMap :: String -> Maybe SomeDFST | 95 | dfstMap :: String -> Maybe SomeDFST |
87 | dfstMap "double" = Just . SomeDFST $ DFST | 96 | dfstMap "double" = Just . SomeDFST $ DFST |