mirror of
https://github.com/github/semantic.git
synced 2024-11-27 12:57:49 +03:00
Remove need for lens
This commit is contained in:
parent
1e7f3b394e
commit
17fbceb17a
@ -1,40 +0,0 @@
|
||||
---
|
||||
type: cabal
|
||||
name: microlens
|
||||
version: 0.4.9.1
|
||||
summary: A tiny lens library with no dependencies. If you're writing an app, you probably
|
||||
want microlens-platform, not this.
|
||||
homepage: https://github.com/aelve/microlens
|
||||
license: bsd-3-clause
|
||||
---
|
||||
Copyright (c) 2013-2016 Edward Kmett,
|
||||
2015-2016 Artyom
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
|
||||
* Neither the name of Artyom nor the names of other
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
@ -223,7 +223,6 @@ library
|
||||
, kdt
|
||||
, machines
|
||||
, mersenne-random-pure64
|
||||
, microlens
|
||||
, mtl
|
||||
, network
|
||||
, network-uri
|
||||
|
@ -42,7 +42,6 @@ import Data.Reprinting.Token
|
||||
import Data.Sequence (singleton)
|
||||
import Data.Source
|
||||
import Data.Term
|
||||
import Lens.Micro
|
||||
|
||||
-- | The 'Tokenizer' monad represents a context in which 'Control'
|
||||
-- tokens and 'Element' tokens can be sent to some downstream
|
||||
@ -139,11 +138,8 @@ newtype RPState = RPState
|
||||
{ _cursor :: Int -- from SYR, used to slice and dice a 'Source' (mutates)
|
||||
} deriving (Show, Eq)
|
||||
|
||||
cursor :: Lens' RPState Int
|
||||
cursor = lens _cursor (\s c -> s { _cursor = c })
|
||||
|
||||
strategy :: Lens' RPContext Strategy
|
||||
strategy = lens _strategy (\s t -> s { _strategy = t })
|
||||
setCursor :: Int -> RPState -> RPState
|
||||
setCursor c s = s { _cursor = c }
|
||||
|
||||
data RPContext = RPContext
|
||||
{ _source :: Source
|
||||
@ -156,8 +152,11 @@ data Strategy
|
||||
| PrettyPrinting
|
||||
deriving (Eq, Show)
|
||||
|
||||
history :: Lens' RPContext History
|
||||
history = lens _history (\c h -> c { _history = h })
|
||||
setStrategy :: Strategy -> RPContext -> RPContext
|
||||
setStrategy s c = c { _strategy = s }
|
||||
|
||||
setHistory :: History -> RPContext -> RPContext
|
||||
setHistory h c = c { _history = h }
|
||||
|
||||
chunk :: Source -> Tokenizer ()
|
||||
chunk = tell . singleton . Chunk
|
||||
@ -169,10 +168,10 @@ finish = do
|
||||
chunk (dropSource crs src)
|
||||
|
||||
withHistory :: (Annotated t (Record fields), HasField fields History) => t -> Tokenizer a -> Tokenizer a
|
||||
withHistory x = local (set history (getField (annotation x)))
|
||||
withHistory x = local (setHistory (getField (annotation x)))
|
||||
|
||||
withStrategy :: Strategy -> Tokenizer a -> Tokenizer a
|
||||
withStrategy x = local (set strategy x)
|
||||
withStrategy x = local (setStrategy x)
|
||||
|
||||
-- | A subterm algebra inspired by the /Scrap Your Reprinter/ algorithm.
|
||||
descend :: (Tokenize constr, HasField fields History) => SubtermAlgebra constr (Term a (Record fields)) (Tokenizer ())
|
||||
@ -190,6 +189,6 @@ descend t = do
|
||||
let delimiter = Range crs (start r)
|
||||
log ("slicing: " <> show delimiter)
|
||||
chunk (slice delimiter src)
|
||||
modify (set cursor (start r))
|
||||
modify' (setCursor (start r))
|
||||
tokenize (fmap (withStrategy PrettyPrinting . into) t)
|
||||
modify (set cursor (end r))
|
||||
modify' (setCursor (end r))
|
||||
|
Loading…
Reference in New Issue
Block a user