This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE TypeApplications #-} | |
{-# LANGUAGE RankNTypes #-} | |
{-# LANGUAGE ViewPatterns, TemplateHaskell #-} | |
module Data.Tracer where | |
import Data.Functor.Contravariant | |
import Data.Time (getCurrentTime) | |
import Control.Lens |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Control.Applicative ((<|>)) | |
import Data.Attoparsec.Text hiding (match) | |
import Data.Text (Text) | |
atto :: Text -> Text -> Text -> Either String [Char] | |
atto x y = parseOnly $ untilWord x >> untilWord y | |
untilWord :: Text -> Parser [Char] | |
untilWord x = mempty <$ string x <|> (:) <$> anyChar <*> untilWord |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extract :: Eq a => [a] -> [a] -> [a] -> Maybe [a] | |
extract start end xs = do | |
ys <- snd <$> split start xs | |
fst <$> split end ys | |
split :: Eq a => [a] -> [a] -> Maybe ([a], [a]) | |
split p = go id | |
where | |
go _ [] = Nothing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE AllowAmbiguousTypes #-} | |
{-# LANGUAGE BlockArguments #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE TypeApplications #-} | |
{-# LANGUAGE TypeFamilies #-} | |
import Control.Lens -- (over) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
-- needed for example | |
{-# LANGUAGE TemplateHaskell #-} | |
{-# LANGUAGE TypeApplications #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE TypeOperators #-} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{- | |
dependencies: | |
- lens | |
- template-haskell | |
create all lenses for a record type preponing an l_ instead of removing the underscore | |
-} | |
import Control.Lens ((.~), lensRules, lensField, makeLensesWith, DefName(TopName), FieldNamer) | |
import Language.Haskell.TH (DecsQ, Name, nameBase, mkName) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{- | |
dependencies: | |
- lens | |
- template-haskell | |
create all lenses for a record type preponing an l_ | |
-} | |
import Control.Lens ((.~), lensRules, lensField, makeLensesWith, DefName(TopName), FieldNamer) | |
import Language.Haskell.TH (DecsQ, Name, nameBase, mkName) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{- | |
dependencies: | |
- base | |
- protolude | |
- tree-diff | |
-} | |
import Data.Typeable (Typeable) | |
import Data.TreeDiff (toExpr, exprDiff, ansiWlEditExpr, ToExpr) | |
import Text.Printf (printf) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE RankNTypes #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE TypeApplications #-} | |
{-# LANGUAGE TypeOperators #-} | |
module Lib.Parse where | |
import Control.Lens (Getting, (^?), _Just) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE UndecidableInstances #-} | |
{-# LANGUAGE DerivingStrategies #-} | |
{-# LANGUAGE AllowAmbiguousTypes #-} | |
{-# LANGUAGE BlockArguments #-} | |
{-# LANGUAGE ConstraintKinds #-} | |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE ExistentialQuantification #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE NoImplicitPrelude #-} |