{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE TypeOperators #-}
module Language.SexpGrammar.Class
( SexpGrammar
, SexpIso(..)
) where
import Prelude hiding ((.), id)
import Control.Arrow
import Control.Category
import Data.InvertibleGrammar
import qualified Data.List.NonEmpty as NE
import Data.Map (Map)
import Data.Scientific
import Data.Set (Set)
import Data.Text (Text)
import qualified Data.Map as Map
import qualified Data.Set as Set
#if !MIN_VERSION_base(4,11,0)
import Data.Semigroup
#endif
import Language.Sexp.Located
import Language.SexpGrammar.Base
import Language.SexpGrammar.Generic
type SexpGrammar a = forall t. Grammar Position (Sexp :- t) (a :- t)
class SexpIso a where
sexpIso :: SexpGrammar a
instance SexpIso () where
sexpIso :: Grammar Position (Sexp :- t) (() :- t)
sexpIso = (Grammar Position t (() :- t)
-> Grammar Position (Sexp :- t) (() :- t))
-> Grammar Position (Sexp :- t) (() :- t)
forall a b s t (c :: Meta) (d :: Meta) (f :: * -> *) p.
(Generic a, MkPrismList (Rep a), MkStackPrism f,
Rep a ~ M1 D d (M1 C c f), StackPrismLhs f t ~ b, Constructor c) =>
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Grammar p s (a :- t)
with ((Grammar Position t (() :- t)
-> Grammar Position (Sexp :- t) (() :- t))
-> Grammar Position (Sexp :- t) (() :- t))
-> (Grammar Position t (() :- t)
-> Grammar Position (Sexp :- t) (() :- t))
-> Grammar Position (Sexp :- t) (() :- t)
forall a b. (a -> b) -> a -> b
$ \Grammar Position t (() :- t)
unit ->
Text -> Grammar Position (Sexp :- t) t
forall t. Text -> Grammar Position (Sexp :- t) t
sym Text
"nil" Grammar Position (Sexp :- t) t
-> Grammar Position t (() :- t)
-> Grammar Position (Sexp :- t) (() :- t)
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position t (() :- t)
unit
instance SexpIso Bool where
sexpIso :: Grammar Position (Sexp :- t) (Bool :- t)
sexpIso = Coproduct Position (Sexp :- t) '[t, t] Bool t
-> Grammar Position (Sexp :- t) (Bool :- t)
forall a (bs :: [*]) t p s.
(Generic a, MkPrismList (Rep a), Match (Rep a) bs t,
bs ~ Coll (Rep a) t) =>
Coproduct p s bs a t -> Grammar p s (a :- t)
match
(Coproduct Position (Sexp :- t) '[t, t] Bool t
-> Grammar Position (Sexp :- t) (Bool :- t))
-> Coproduct Position (Sexp :- t) '[t, t] Bool t
-> Grammar Position (Sexp :- t) (Bool :- t)
forall a b. (a -> b) -> a -> b
$ (Grammar Position t (Bool :- t)
-> Grammar Position (Sexp :- t) (Bool :- t))
-> Coproduct Position (Sexp :- t) '[t] Bool t
-> Coproduct Position (Sexp :- t) '[t, t] Bool t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With (\Grammar Position t (Bool :- t)
false_ -> Text -> Grammar Position (Sexp :- t) t
forall t. Text -> Grammar Position (Sexp :- t) t
sym Text
"false" Grammar Position (Sexp :- t) t
-> Grammar Position t (Bool :- t)
-> Grammar Position (Sexp :- t) (Bool :- t)
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position t (Bool :- t)
false_)
(Coproduct Position (Sexp :- t) '[t] Bool t
-> Coproduct Position (Sexp :- t) '[t, t] Bool t)
-> Coproduct Position (Sexp :- t) '[t] Bool t
-> Coproduct Position (Sexp :- t) '[t, t] Bool t
forall a b. (a -> b) -> a -> b
$ (Grammar Position t (Bool :- t)
-> Grammar Position (Sexp :- t) (Bool :- t))
-> Coproduct Position (Sexp :- t) '[] Bool t
-> Coproduct Position (Sexp :- t) '[t] Bool t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With (\Grammar Position t (Bool :- t)
true_ -> Text -> Grammar Position (Sexp :- t) t
forall t. Text -> Grammar Position (Sexp :- t) t
sym Text
"true" Grammar Position (Sexp :- t) t
-> Grammar Position t (Bool :- t)
-> Grammar Position (Sexp :- t) (Bool :- t)
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position t (Bool :- t)
true_)
(Coproduct Position (Sexp :- t) '[] Bool t
-> Coproduct Position (Sexp :- t) '[t] Bool t)
-> Coproduct Position (Sexp :- t) '[] Bool t
-> Coproduct Position (Sexp :- t) '[t] Bool t
forall a b. (a -> b) -> a -> b
$ Coproduct Position (Sexp :- t) '[] Bool t
forall p s a t. Coproduct p s '[] a t
End
instance SexpIso Int where
sexpIso :: Grammar Position (Sexp :- t) (Int :- t)
sexpIso = Grammar Position (Sexp :- t) (Int :- t)
SexpGrammar Int
int
instance SexpIso Integer where
sexpIso :: Grammar Position (Sexp :- t) (Integer :- t)
sexpIso = Grammar Position (Sexp :- t) (Integer :- t)
SexpGrammar Integer
integer
instance SexpIso Double where
sexpIso :: Grammar Position (Sexp :- t) (Double :- t)
sexpIso = Grammar Position (Sexp :- t) (Double :- t)
SexpGrammar Double
double
instance SexpIso Scientific where
sexpIso :: Grammar Position (Sexp :- t) (Scientific :- t)
sexpIso = Grammar Position (Sexp :- t) (Scientific :- t)
SexpGrammar Scientific
real
instance SexpIso Text where
sexpIso :: Grammar Position (Sexp :- t) (Text :- t)
sexpIso = Grammar Position (Sexp :- t) (Text :- t)
SexpGrammar Text
string
instance (SexpIso a, SexpIso b) => SexpIso (a, b) where
sexpIso :: Grammar Position (Sexp :- t) ((a, b) :- t)
sexpIso =
Grammar Position (List :- t) (List :- (b :- (a :- t)))
-> Grammar Position (Sexp :- t) (b :- (a :- t))
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
list (
Grammar Position (Sexp :- t) (a :- t)
-> Grammar Position (List :- t) (List :- (a :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
el Grammar Position (Sexp :- t) (a :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar Position (List :- t) (List :- (a :- t))
-> Grammar Position (List :- (a :- t)) (List :- (b :- (a :- t)))
-> Grammar Position (List :- t) (List :- (b :- (a :- t)))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
Grammar Position (Sexp :- (a :- t)) (b :- (a :- t))
-> Grammar Position (List :- (a :- t)) (List :- (b :- (a :- t)))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
el Grammar Position (Sexp :- (a :- t)) (b :- (a :- t))
forall a. SexpIso a => SexpGrammar a
sexpIso) Grammar Position (Sexp :- t) (b :- (a :- t))
-> Grammar Position (b :- (a :- t)) ((a, b) :- t)
-> Grammar Position (Sexp :- t) ((a, b) :- t)
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (b :- (a :- t)) ((a, b) :- t)
forall p b a t. Grammar p (b :- (a :- t)) ((a, b) :- t)
pair
instance (SexpIso a, SexpIso b, SexpIso c) => SexpIso (a, b, c) where
sexpIso :: Grammar Position (Sexp :- t) ((a, b, c) :- t)
sexpIso = (Grammar Position (c :- (b :- (a :- t))) ((a, b, c) :- t)
-> Grammar Position (Sexp :- t) ((a, b, c) :- t))
-> Grammar Position (Sexp :- t) ((a, b, c) :- t)
forall a b s t (c :: Meta) (d :: Meta) (f :: * -> *) p.
(Generic a, MkPrismList (Rep a), MkStackPrism f,
Rep a ~ M1 D d (M1 C c f), StackPrismLhs f t ~ b, Constructor c) =>
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Grammar p s (a :- t)
with ((Grammar Position (c :- (b :- (a :- t))) ((a, b, c) :- t)
-> Grammar Position (Sexp :- t) ((a, b, c) :- t))
-> Grammar Position (Sexp :- t) ((a, b, c) :- t))
-> (Grammar Position (c :- (b :- (a :- t))) ((a, b, c) :- t)
-> Grammar Position (Sexp :- t) ((a, b, c) :- t))
-> Grammar Position (Sexp :- t) ((a, b, c) :- t)
forall a b. (a -> b) -> a -> b
$ \Grammar Position (c :- (b :- (a :- t))) ((a, b, c) :- t)
tuple3 ->
Grammar Position (List :- t) (List :- (c :- (b :- (a :- t))))
-> Grammar Position (Sexp :- t) (c :- (b :- (a :- t)))
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
list (
Grammar Position (Sexp :- t) (a :- t)
-> Grammar Position (List :- t) (List :- (a :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
el Grammar Position (Sexp :- t) (a :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar Position (List :- t) (List :- (a :- t))
-> Grammar
Position (List :- (a :- t)) (List :- (c :- (b :- (a :- t))))
-> Grammar Position (List :- t) (List :- (c :- (b :- (a :- t))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
Grammar Position (Sexp :- (a :- t)) (b :- (a :- t))
-> Grammar Position (List :- (a :- t)) (List :- (b :- (a :- t)))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
el Grammar Position (Sexp :- (a :- t)) (b :- (a :- t))
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar Position (List :- (a :- t)) (List :- (b :- (a :- t)))
-> Grammar
Position (List :- (b :- (a :- t))) (List :- (c :- (b :- (a :- t))))
-> Grammar
Position (List :- (a :- t)) (List :- (c :- (b :- (a :- t))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
Grammar Position (Sexp :- (b :- (a :- t))) (c :- (b :- (a :- t)))
-> Grammar
Position (List :- (b :- (a :- t))) (List :- (c :- (b :- (a :- t))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
el Grammar Position (Sexp :- (b :- (a :- t))) (c :- (b :- (a :- t)))
forall a. SexpIso a => SexpGrammar a
sexpIso) Grammar Position (Sexp :- t) (c :- (b :- (a :- t)))
-> Grammar Position (c :- (b :- (a :- t))) ((a, b, c) :- t)
-> Grammar Position (Sexp :- t) ((a, b, c) :- t)
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (c :- (b :- (a :- t))) ((a, b, c) :- t)
tuple3
instance (SexpIso a, SexpIso b, SexpIso c, SexpIso d) => SexpIso (a, b, c, d) where
sexpIso :: Grammar Position (Sexp :- t) ((a, b, c, d) :- t)
sexpIso = (Grammar Position (d :- (c :- (b :- (a :- t)))) ((a, b, c, d) :- t)
-> Grammar Position (Sexp :- t) ((a, b, c, d) :- t))
-> Grammar Position (Sexp :- t) ((a, b, c, d) :- t)
forall a b s t (c :: Meta) (d :: Meta) (f :: * -> *) p.
(Generic a, MkPrismList (Rep a), MkStackPrism f,
Rep a ~ M1 D d (M1 C c f), StackPrismLhs f t ~ b, Constructor c) =>
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Grammar p s (a :- t)
with ((Grammar
Position (d :- (c :- (b :- (a :- t)))) ((a, b, c, d) :- t)
-> Grammar Position (Sexp :- t) ((a, b, c, d) :- t))
-> Grammar Position (Sexp :- t) ((a, b, c, d) :- t))
-> (Grammar
Position (d :- (c :- (b :- (a :- t)))) ((a, b, c, d) :- t)
-> Grammar Position (Sexp :- t) ((a, b, c, d) :- t))
-> Grammar Position (Sexp :- t) ((a, b, c, d) :- t)
forall a b. (a -> b) -> a -> b
$ \Grammar Position (d :- (c :- (b :- (a :- t)))) ((a, b, c, d) :- t)
tuple4 ->
Grammar
Position (List :- t) (List :- (d :- (c :- (b :- (a :- t)))))
-> Grammar Position (Sexp :- t) (d :- (c :- (b :- (a :- t))))
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
list (
Grammar Position (Sexp :- t) (a :- t)
-> Grammar Position (List :- t) (List :- (a :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
el Grammar Position (Sexp :- t) (a :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar Position (List :- t) (List :- (a :- t))
-> Grammar
Position (List :- (a :- t)) (List :- (d :- (c :- (b :- (a :- t)))))
-> Grammar
Position (List :- t) (List :- (d :- (c :- (b :- (a :- t)))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
Grammar Position (Sexp :- (a :- t)) (b :- (a :- t))
-> Grammar Position (List :- (a :- t)) (List :- (b :- (a :- t)))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
el Grammar Position (Sexp :- (a :- t)) (b :- (a :- t))
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar Position (List :- (a :- t)) (List :- (b :- (a :- t)))
-> Grammar
Position
(List :- (b :- (a :- t)))
(List :- (d :- (c :- (b :- (a :- t)))))
-> Grammar
Position (List :- (a :- t)) (List :- (d :- (c :- (b :- (a :- t)))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
Grammar Position (Sexp :- (b :- (a :- t))) (c :- (b :- (a :- t)))
-> Grammar
Position (List :- (b :- (a :- t))) (List :- (c :- (b :- (a :- t))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
el Grammar Position (Sexp :- (b :- (a :- t))) (c :- (b :- (a :- t)))
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar
Position (List :- (b :- (a :- t))) (List :- (c :- (b :- (a :- t))))
-> Grammar
Position
(List :- (c :- (b :- (a :- t))))
(List :- (d :- (c :- (b :- (a :- t)))))
-> Grammar
Position
(List :- (b :- (a :- t)))
(List :- (d :- (c :- (b :- (a :- t)))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
Grammar
Position
(Sexp :- (c :- (b :- (a :- t))))
(d :- (c :- (b :- (a :- t))))
-> Grammar
Position
(List :- (c :- (b :- (a :- t))))
(List :- (d :- (c :- (b :- (a :- t)))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
el Grammar
Position
(Sexp :- (c :- (b :- (a :- t))))
(d :- (c :- (b :- (a :- t))))
forall a. SexpIso a => SexpGrammar a
sexpIso) Grammar Position (Sexp :- t) (d :- (c :- (b :- (a :- t))))
-> Grammar
Position (d :- (c :- (b :- (a :- t)))) ((a, b, c, d) :- t)
-> Grammar Position (Sexp :- t) ((a, b, c, d) :- t)
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (d :- (c :- (b :- (a :- t)))) ((a, b, c, d) :- t)
tuple4
instance (SexpIso a, SexpIso b, SexpIso c, SexpIso d, SexpIso e) => SexpIso (a, b, c, d, e) where
sexpIso :: Grammar Position (Sexp :- t) ((a, b, c, d, e) :- t)
sexpIso = (Grammar
Position
(e :- (d :- (c :- (b :- (a :- t)))))
((a, b, c, d, e) :- t)
-> Grammar Position (Sexp :- t) ((a, b, c, d, e) :- t))
-> Grammar Position (Sexp :- t) ((a, b, c, d, e) :- t)
forall a b s t (c :: Meta) (d :: Meta) (f :: * -> *) p.
(Generic a, MkPrismList (Rep a), MkStackPrism f,
Rep a ~ M1 D d (M1 C c f), StackPrismLhs f t ~ b, Constructor c) =>
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Grammar p s (a :- t)
with ((Grammar
Position
(e :- (d :- (c :- (b :- (a :- t)))))
((a, b, c, d, e) :- t)
-> Grammar Position (Sexp :- t) ((a, b, c, d, e) :- t))
-> Grammar Position (Sexp :- t) ((a, b, c, d, e) :- t))
-> (Grammar
Position
(e :- (d :- (c :- (b :- (a :- t)))))
((a, b, c, d, e) :- t)
-> Grammar Position (Sexp :- t) ((a, b, c, d, e) :- t))
-> Grammar Position (Sexp :- t) ((a, b, c, d, e) :- t)
forall a b. (a -> b) -> a -> b
$ \Grammar
Position
(e :- (d :- (c :- (b :- (a :- t)))))
((a, b, c, d, e) :- t)
tuple5 ->
Grammar
Position (List :- t) (List :- (e :- (d :- (c :- (b :- (a :- t))))))
-> Grammar
Position (Sexp :- t) (e :- (d :- (c :- (b :- (a :- t)))))
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
list (
Grammar Position (Sexp :- t) (a :- t)
-> Grammar Position (List :- t) (List :- (a :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
el Grammar Position (Sexp :- t) (a :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar Position (List :- t) (List :- (a :- t))
-> Grammar
Position
(List :- (a :- t))
(List :- (e :- (d :- (c :- (b :- (a :- t))))))
-> Grammar
Position (List :- t) (List :- (e :- (d :- (c :- (b :- (a :- t))))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
Grammar Position (Sexp :- (a :- t)) (b :- (a :- t))
-> Grammar Position (List :- (a :- t)) (List :- (b :- (a :- t)))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
el Grammar Position (Sexp :- (a :- t)) (b :- (a :- t))
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar Position (List :- (a :- t)) (List :- (b :- (a :- t)))
-> Grammar
Position
(List :- (b :- (a :- t)))
(List :- (e :- (d :- (c :- (b :- (a :- t))))))
-> Grammar
Position
(List :- (a :- t))
(List :- (e :- (d :- (c :- (b :- (a :- t))))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
Grammar Position (Sexp :- (b :- (a :- t))) (c :- (b :- (a :- t)))
-> Grammar
Position (List :- (b :- (a :- t))) (List :- (c :- (b :- (a :- t))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
el Grammar Position (Sexp :- (b :- (a :- t))) (c :- (b :- (a :- t)))
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar
Position (List :- (b :- (a :- t))) (List :- (c :- (b :- (a :- t))))
-> Grammar
Position
(List :- (c :- (b :- (a :- t))))
(List :- (e :- (d :- (c :- (b :- (a :- t))))))
-> Grammar
Position
(List :- (b :- (a :- t)))
(List :- (e :- (d :- (c :- (b :- (a :- t))))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
Grammar
Position
(Sexp :- (c :- (b :- (a :- t))))
(d :- (c :- (b :- (a :- t))))
-> Grammar
Position
(List :- (c :- (b :- (a :- t))))
(List :- (d :- (c :- (b :- (a :- t)))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
el Grammar
Position
(Sexp :- (c :- (b :- (a :- t))))
(d :- (c :- (b :- (a :- t))))
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar
Position
(List :- (c :- (b :- (a :- t))))
(List :- (d :- (c :- (b :- (a :- t)))))
-> Grammar
Position
(List :- (d :- (c :- (b :- (a :- t)))))
(List :- (e :- (d :- (c :- (b :- (a :- t))))))
-> Grammar
Position
(List :- (c :- (b :- (a :- t))))
(List :- (e :- (d :- (c :- (b :- (a :- t))))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
Grammar
Position
(Sexp :- (d :- (c :- (b :- (a :- t)))))
(e :- (d :- (c :- (b :- (a :- t)))))
-> Grammar
Position
(List :- (d :- (c :- (b :- (a :- t)))))
(List :- (e :- (d :- (c :- (b :- (a :- t))))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
el Grammar
Position
(Sexp :- (d :- (c :- (b :- (a :- t)))))
(e :- (d :- (c :- (b :- (a :- t)))))
forall a. SexpIso a => SexpGrammar a
sexpIso) Grammar Position (Sexp :- t) (e :- (d :- (c :- (b :- (a :- t)))))
-> Grammar
Position
(e :- (d :- (c :- (b :- (a :- t)))))
((a, b, c, d, e) :- t)
-> Grammar Position (Sexp :- t) ((a, b, c, d, e) :- t)
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
Position
(e :- (d :- (c :- (b :- (a :- t)))))
((a, b, c, d, e) :- t)
tuple5
instance (SexpIso a, SexpIso b, SexpIso c, SexpIso d, SexpIso e, SexpIso f) => SexpIso (a, b, c, d, e, f) where
sexpIso :: Grammar Position (Sexp :- t) ((a, b, c, d, e, f) :- t)
sexpIso = (Grammar
Position
(f :- (e :- (d :- (c :- (b :- (a :- t))))))
((a, b, c, d, e, f) :- t)
-> Grammar Position (Sexp :- t) ((a, b, c, d, e, f) :- t))
-> Grammar Position (Sexp :- t) ((a, b, c, d, e, f) :- t)
forall a b s t (c :: Meta) (d :: Meta) (f :: * -> *) p.
(Generic a, MkPrismList (Rep a), MkStackPrism f,
Rep a ~ M1 D d (M1 C c f), StackPrismLhs f t ~ b, Constructor c) =>
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Grammar p s (a :- t)
with ((Grammar
Position
(f :- (e :- (d :- (c :- (b :- (a :- t))))))
((a, b, c, d, e, f) :- t)
-> Grammar Position (Sexp :- t) ((a, b, c, d, e, f) :- t))
-> Grammar Position (Sexp :- t) ((a, b, c, d, e, f) :- t))
-> (Grammar
Position
(f :- (e :- (d :- (c :- (b :- (a :- t))))))
((a, b, c, d, e, f) :- t)
-> Grammar Position (Sexp :- t) ((a, b, c, d, e, f) :- t))
-> Grammar Position (Sexp :- t) ((a, b, c, d, e, f) :- t)
forall a b. (a -> b) -> a -> b
$ \Grammar
Position
(f :- (e :- (d :- (c :- (b :- (a :- t))))))
((a, b, c, d, e, f) :- t)
tuple6 ->
Grammar
Position
(List :- t)
(List :- (f :- (e :- (d :- (c :- (b :- (a :- t)))))))
-> Grammar
Position (Sexp :- t) (f :- (e :- (d :- (c :- (b :- (a :- t))))))
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
list (
Grammar Position (Sexp :- t) (a :- t)
-> Grammar Position (List :- t) (List :- (a :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
el Grammar Position (Sexp :- t) (a :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar Position (List :- t) (List :- (a :- t))
-> Grammar
Position
(List :- (a :- t))
(List :- (f :- (e :- (d :- (c :- (b :- (a :- t)))))))
-> Grammar
Position
(List :- t)
(List :- (f :- (e :- (d :- (c :- (b :- (a :- t)))))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
Grammar Position (Sexp :- (a :- t)) (b :- (a :- t))
-> Grammar Position (List :- (a :- t)) (List :- (b :- (a :- t)))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
el Grammar Position (Sexp :- (a :- t)) (b :- (a :- t))
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar Position (List :- (a :- t)) (List :- (b :- (a :- t)))
-> Grammar
Position
(List :- (b :- (a :- t)))
(List :- (f :- (e :- (d :- (c :- (b :- (a :- t)))))))
-> Grammar
Position
(List :- (a :- t))
(List :- (f :- (e :- (d :- (c :- (b :- (a :- t)))))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
Grammar Position (Sexp :- (b :- (a :- t))) (c :- (b :- (a :- t)))
-> Grammar
Position (List :- (b :- (a :- t))) (List :- (c :- (b :- (a :- t))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
el Grammar Position (Sexp :- (b :- (a :- t))) (c :- (b :- (a :- t)))
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar
Position (List :- (b :- (a :- t))) (List :- (c :- (b :- (a :- t))))
-> Grammar
Position
(List :- (c :- (b :- (a :- t))))
(List :- (f :- (e :- (d :- (c :- (b :- (a :- t)))))))
-> Grammar
Position
(List :- (b :- (a :- t)))
(List :- (f :- (e :- (d :- (c :- (b :- (a :- t)))))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
Grammar
Position
(Sexp :- (c :- (b :- (a :- t))))
(d :- (c :- (b :- (a :- t))))
-> Grammar
Position
(List :- (c :- (b :- (a :- t))))
(List :- (d :- (c :- (b :- (a :- t)))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
el Grammar
Position
(Sexp :- (c :- (b :- (a :- t))))
(d :- (c :- (b :- (a :- t))))
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar
Position
(List :- (c :- (b :- (a :- t))))
(List :- (d :- (c :- (b :- (a :- t)))))
-> Grammar
Position
(List :- (d :- (c :- (b :- (a :- t)))))
(List :- (f :- (e :- (d :- (c :- (b :- (a :- t)))))))
-> Grammar
Position
(List :- (c :- (b :- (a :- t))))
(List :- (f :- (e :- (d :- (c :- (b :- (a :- t)))))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
Grammar
Position
(Sexp :- (d :- (c :- (b :- (a :- t)))))
(e :- (d :- (c :- (b :- (a :- t)))))
-> Grammar
Position
(List :- (d :- (c :- (b :- (a :- t)))))
(List :- (e :- (d :- (c :- (b :- (a :- t))))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
el Grammar
Position
(Sexp :- (d :- (c :- (b :- (a :- t)))))
(e :- (d :- (c :- (b :- (a :- t)))))
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar
Position
(List :- (d :- (c :- (b :- (a :- t)))))
(List :- (e :- (d :- (c :- (b :- (a :- t))))))
-> Grammar
Position
(List :- (e :- (d :- (c :- (b :- (a :- t))))))
(List :- (f :- (e :- (d :- (c :- (b :- (a :- t)))))))
-> Grammar
Position
(List :- (d :- (c :- (b :- (a :- t)))))
(List :- (f :- (e :- (d :- (c :- (b :- (a :- t)))))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
Grammar
Position
(Sexp :- (e :- (d :- (c :- (b :- (a :- t))))))
(f :- (e :- (d :- (c :- (b :- (a :- t))))))
-> Grammar
Position
(List :- (e :- (d :- (c :- (b :- (a :- t))))))
(List :- (f :- (e :- (d :- (c :- (b :- (a :- t)))))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
el Grammar
Position
(Sexp :- (e :- (d :- (c :- (b :- (a :- t))))))
(f :- (e :- (d :- (c :- (b :- (a :- t))))))
forall a. SexpIso a => SexpGrammar a
sexpIso) Grammar
Position (Sexp :- t) (f :- (e :- (d :- (c :- (b :- (a :- t))))))
-> Grammar
Position
(f :- (e :- (d :- (c :- (b :- (a :- t))))))
((a, b, c, d, e, f) :- t)
-> Grammar Position (Sexp :- t) ((a, b, c, d, e, f) :- t)
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
Position
(f :- (e :- (d :- (c :- (b :- (a :- t))))))
((a, b, c, d, e, f) :- t)
tuple6
instance (SexpIso a, SexpIso b, SexpIso c, SexpIso d, SexpIso e, SexpIso f, SexpIso g) =>
SexpIso (a, b, c, d, e, f, g) where
sexpIso :: Grammar Position (Sexp :- t) ((a, b, c, d, e, f, g) :- t)
sexpIso = (Grammar
Position
(g :- (f :- (e :- (d :- (c :- (b :- (a :- t)))))))
((a, b, c, d, e, f, g) :- t)
-> Grammar Position (Sexp :- t) ((a, b, c, d, e, f, g) :- t))
-> Grammar Position (Sexp :- t) ((a, b, c, d, e, f, g) :- t)
forall a b s t (c :: Meta) (d :: Meta) (f :: * -> *) p.
(Generic a, MkPrismList (Rep a), MkStackPrism f,
Rep a ~ M1 D d (M1 C c f), StackPrismLhs f t ~ b, Constructor c) =>
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Grammar p s (a :- t)
with ((Grammar
Position
(g :- (f :- (e :- (d :- (c :- (b :- (a :- t)))))))
((a, b, c, d, e, f, g) :- t)
-> Grammar Position (Sexp :- t) ((a, b, c, d, e, f, g) :- t))
-> Grammar Position (Sexp :- t) ((a, b, c, d, e, f, g) :- t))
-> (Grammar
Position
(g :- (f :- (e :- (d :- (c :- (b :- (a :- t)))))))
((a, b, c, d, e, f, g) :- t)
-> Grammar Position (Sexp :- t) ((a, b, c, d, e, f, g) :- t))
-> Grammar Position (Sexp :- t) ((a, b, c, d, e, f, g) :- t)
forall a b. (a -> b) -> a -> b
$ \Grammar
Position
(g :- (f :- (e :- (d :- (c :- (b :- (a :- t)))))))
((a, b, c, d, e, f, g) :- t)
tuple7 ->
Grammar
Position
(List :- t)
(List :- (g :- (f :- (e :- (d :- (c :- (b :- (a :- t))))))))
-> Grammar
Position
(Sexp :- t)
(g :- (f :- (e :- (d :- (c :- (b :- (a :- t)))))))
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
list (
Grammar Position (Sexp :- t) (a :- t)
-> Grammar Position (List :- t) (List :- (a :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
el Grammar Position (Sexp :- t) (a :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar Position (List :- t) (List :- (a :- t))
-> Grammar
Position
(List :- (a :- t))
(List :- (g :- (f :- (e :- (d :- (c :- (b :- (a :- t))))))))
-> Grammar
Position
(List :- t)
(List :- (g :- (f :- (e :- (d :- (c :- (b :- (a :- t))))))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
Grammar Position (Sexp :- (a :- t)) (b :- (a :- t))
-> Grammar Position (List :- (a :- t)) (List :- (b :- (a :- t)))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
el Grammar Position (Sexp :- (a :- t)) (b :- (a :- t))
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar Position (List :- (a :- t)) (List :- (b :- (a :- t)))
-> Grammar
Position
(List :- (b :- (a :- t)))
(List :- (g :- (f :- (e :- (d :- (c :- (b :- (a :- t))))))))
-> Grammar
Position
(List :- (a :- t))
(List :- (g :- (f :- (e :- (d :- (c :- (b :- (a :- t))))))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
Grammar Position (Sexp :- (b :- (a :- t))) (c :- (b :- (a :- t)))
-> Grammar
Position (List :- (b :- (a :- t))) (List :- (c :- (b :- (a :- t))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
el Grammar Position (Sexp :- (b :- (a :- t))) (c :- (b :- (a :- t)))
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar
Position (List :- (b :- (a :- t))) (List :- (c :- (b :- (a :- t))))
-> Grammar
Position
(List :- (c :- (b :- (a :- t))))
(List :- (g :- (f :- (e :- (d :- (c :- (b :- (a :- t))))))))
-> Grammar
Position
(List :- (b :- (a :- t)))
(List :- (g :- (f :- (e :- (d :- (c :- (b :- (a :- t))))))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
Grammar
Position
(Sexp :- (c :- (b :- (a :- t))))
(d :- (c :- (b :- (a :- t))))
-> Grammar
Position
(List :- (c :- (b :- (a :- t))))
(List :- (d :- (c :- (b :- (a :- t)))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
el Grammar
Position
(Sexp :- (c :- (b :- (a :- t))))
(d :- (c :- (b :- (a :- t))))
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar
Position
(List :- (c :- (b :- (a :- t))))
(List :- (d :- (c :- (b :- (a :- t)))))
-> Grammar
Position
(List :- (d :- (c :- (b :- (a :- t)))))
(List :- (g :- (f :- (e :- (d :- (c :- (b :- (a :- t))))))))
-> Grammar
Position
(List :- (c :- (b :- (a :- t))))
(List :- (g :- (f :- (e :- (d :- (c :- (b :- (a :- t))))))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
Grammar
Position
(Sexp :- (d :- (c :- (b :- (a :- t)))))
(e :- (d :- (c :- (b :- (a :- t)))))
-> Grammar
Position
(List :- (d :- (c :- (b :- (a :- t)))))
(List :- (e :- (d :- (c :- (b :- (a :- t))))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
el Grammar
Position
(Sexp :- (d :- (c :- (b :- (a :- t)))))
(e :- (d :- (c :- (b :- (a :- t)))))
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar
Position
(List :- (d :- (c :- (b :- (a :- t)))))
(List :- (e :- (d :- (c :- (b :- (a :- t))))))
-> Grammar
Position
(List :- (e :- (d :- (c :- (b :- (a :- t))))))
(List :- (g :- (f :- (e :- (d :- (c :- (b :- (a :- t))))))))
-> Grammar
Position
(List :- (d :- (c :- (b :- (a :- t)))))
(List :- (g :- (f :- (e :- (d :- (c :- (b :- (a :- t))))))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
Grammar
Position
(Sexp :- (e :- (d :- (c :- (b :- (a :- t))))))
(f :- (e :- (d :- (c :- (b :- (a :- t))))))
-> Grammar
Position
(List :- (e :- (d :- (c :- (b :- (a :- t))))))
(List :- (f :- (e :- (d :- (c :- (b :- (a :- t)))))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
el Grammar
Position
(Sexp :- (e :- (d :- (c :- (b :- (a :- t))))))
(f :- (e :- (d :- (c :- (b :- (a :- t))))))
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar
Position
(List :- (e :- (d :- (c :- (b :- (a :- t))))))
(List :- (f :- (e :- (d :- (c :- (b :- (a :- t)))))))
-> Grammar
Position
(List :- (f :- (e :- (d :- (c :- (b :- (a :- t)))))))
(List :- (g :- (f :- (e :- (d :- (c :- (b :- (a :- t))))))))
-> Grammar
Position
(List :- (e :- (d :- (c :- (b :- (a :- t))))))
(List :- (g :- (f :- (e :- (d :- (c :- (b :- (a :- t))))))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
Grammar
Position
(Sexp :- (f :- (e :- (d :- (c :- (b :- (a :- t)))))))
(g :- (f :- (e :- (d :- (c :- (b :- (a :- t)))))))
-> Grammar
Position
(List :- (f :- (e :- (d :- (c :- (b :- (a :- t)))))))
(List :- (g :- (f :- (e :- (d :- (c :- (b :- (a :- t))))))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
el Grammar
Position
(Sexp :- (f :- (e :- (d :- (c :- (b :- (a :- t)))))))
(g :- (f :- (e :- (d :- (c :- (b :- (a :- t)))))))
forall a. SexpIso a => SexpGrammar a
sexpIso) Grammar
Position
(Sexp :- t)
(g :- (f :- (e :- (d :- (c :- (b :- (a :- t)))))))
-> Grammar
Position
(g :- (f :- (e :- (d :- (c :- (b :- (a :- t)))))))
((a, b, c, d, e, f, g) :- t)
-> Grammar Position (Sexp :- t) ((a, b, c, d, e, f, g) :- t)
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
Position
(g :- (f :- (e :- (d :- (c :- (b :- (a :- t)))))))
((a, b, c, d, e, f, g) :- t)
tuple7
instance (Ord k, SexpIso k, SexpIso v) => SexpIso (Map k v) where
sexpIso :: Grammar Position (Sexp :- t) (Map k v :- t)
sexpIso = ([(k, v)] -> Map k v)
-> (Map k v -> [(k, v)])
-> Grammar Position ([(k, v)] :- t) (Map k v :- t)
forall a b p t. (a -> b) -> (b -> a) -> Grammar p (a :- t) (b :- t)
iso [(k, v)] -> Map k v
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList Map k v -> [(k, v)]
forall k a. Map k a -> [(k, a)]
Map.toList Grammar Position ([(k, v)] :- t) (Map k v :- t)
-> Grammar Position (Sexp :- t) ([(k, v)] :- t)
-> Grammar Position (Sexp :- t) (Map k v :- t)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Grammar Position (List :- t) (List :- ([(k, v)] :- t))
-> Grammar Position (Sexp :- t) ([(k, v)] :- t)
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
braceList ((forall t1. Grammar Position (Sexp :- t1) ((k, v) :- t1))
-> Grammar Position (List :- t) (List :- ([(k, v)] :- t))
forall a t.
(forall t1. Grammar Position (Sexp :- t1) (a :- t1))
-> Grammar Position (List :- t) (List :- ([a] :- t))
rest forall t1. Grammar Position (Sexp :- t1) ((k, v) :- t1)
forall a. SexpIso a => SexpGrammar a
sexpIso)
instance (Ord a, SexpIso a) => SexpIso (Set a) where
sexpIso :: Grammar Position (Sexp :- t) (Set a :- t)
sexpIso = ([a] -> Set a)
-> (Set a -> [a]) -> Grammar Position ([a] :- t) (Set a :- t)
forall a b p t. (a -> b) -> (b -> a) -> Grammar p (a :- t) (b :- t)
iso [a] -> Set a
forall a. Ord a => [a] -> Set a
Set.fromList Set a -> [a]
forall a. Set a -> [a]
Set.toList Grammar Position ([a] :- t) (Set a :- t)
-> Grammar Position (Sexp :- t) ([a] :- t)
-> Grammar Position (Sexp :- t) (Set a :- t)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Grammar Position (List :- t) (List :- ([a] :- t))
-> Grammar Position (Sexp :- t) ([a] :- t)
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
braceList ((forall t1. Grammar Position (Sexp :- t1) (a :- t1))
-> Grammar Position (List :- t) (List :- ([a] :- t))
forall a t.
(forall t1. Grammar Position (Sexp :- t1) (a :- t1))
-> Grammar Position (List :- t) (List :- ([a] :- t))
rest forall t1. Grammar Position (Sexp :- t1) (a :- t1)
forall a. SexpIso a => SexpGrammar a
sexpIso)
instance (SexpIso a) => SexpIso (Maybe a) where
sexpIso :: Grammar Position (Sexp :- t) (Maybe a :- t)
sexpIso = Coproduct Position (Sexp :- t) '[t, a :- t] (Maybe a) t
-> Grammar Position (Sexp :- t) (Maybe a :- t)
forall a (bs :: [*]) t p s.
(Generic a, MkPrismList (Rep a), Match (Rep a) bs t,
bs ~ Coll (Rep a) t) =>
Coproduct p s bs a t -> Grammar p s (a :- t)
match
(Coproduct Position (Sexp :- t) '[t, a :- t] (Maybe a) t
-> Grammar Position (Sexp :- t) (Maybe a :- t))
-> Coproduct Position (Sexp :- t) '[t, a :- t] (Maybe a) t
-> Grammar Position (Sexp :- t) (Maybe a :- t)
forall a b. (a -> b) -> a -> b
$ (Grammar Position t (Maybe a :- t)
-> Grammar Position (Sexp :- t) (Maybe a :- t))
-> Coproduct Position (Sexp :- t) '[a :- t] (Maybe a) t
-> Coproduct Position (Sexp :- t) '[t, a :- t] (Maybe a) t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With (\Grammar Position t (Maybe a :- t)
nothing -> Text -> Grammar Position (Sexp :- t) t
forall t. Text -> Grammar Position (Sexp :- t) t
sym Text
"nil" Grammar Position (Sexp :- t) t
-> Grammar Position t (Maybe a :- t)
-> Grammar Position (Sexp :- t) (Maybe a :- t)
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position t (Maybe a :- t)
nothing)
(Coproduct Position (Sexp :- t) '[a :- t] (Maybe a) t
-> Coproduct Position (Sexp :- t) '[t, a :- t] (Maybe a) t)
-> Coproduct Position (Sexp :- t) '[a :- t] (Maybe a) t
-> Coproduct Position (Sexp :- t) '[t, a :- t] (Maybe a) t
forall a b. (a -> b) -> a -> b
$ (Grammar Position (a :- t) (Maybe a :- t)
-> Grammar Position (Sexp :- t) (Maybe a :- t))
-> Coproduct Position (Sexp :- t) '[] (Maybe a) t
-> Coproduct Position (Sexp :- t) '[a :- t] (Maybe a) t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With (\Grammar Position (a :- t) (Maybe a :- t)
just -> Grammar Position (List :- t) (List :- (a :- t))
-> Grammar Position (Sexp :- t) (a :- t)
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
list (Grammar Position (Sexp :- t) t
-> Grammar Position (List :- t) (List :- t)
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
el (Text -> Grammar Position (Sexp :- t) t
forall t. Text -> Grammar Position (Sexp :- t) t
sym Text
"just") Grammar Position (List :- t) (List :- t)
-> Grammar Position (List :- t) (List :- (a :- t))
-> Grammar Position (List :- t) (List :- (a :- t))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- t) (a :- t)
-> Grammar Position (List :- t) (List :- (a :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
el Grammar Position (Sexp :- t) (a :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso) Grammar Position (Sexp :- t) (a :- t)
-> Grammar Position (a :- t) (Maybe a :- t)
-> Grammar Position (Sexp :- t) (Maybe a :- t)
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (a :- t) (Maybe a :- t)
just)
(Coproduct Position (Sexp :- t) '[] (Maybe a) t
-> Coproduct Position (Sexp :- t) '[a :- t] (Maybe a) t)
-> Coproduct Position (Sexp :- t) '[] (Maybe a) t
-> Coproduct Position (Sexp :- t) '[a :- t] (Maybe a) t
forall a b. (a -> b) -> a -> b
$ Coproduct Position (Sexp :- t) '[] (Maybe a) t
forall p s a t. Coproduct p s '[] a t
End
instance (SexpIso a, SexpIso b) => SexpIso (Either a b) where
sexpIso :: Grammar Position (Sexp :- t) (Either a b :- t)
sexpIso = Coproduct Position (Sexp :- t) '[a :- t, b :- t] (Either a b) t
-> Grammar Position (Sexp :- t) (Either a b :- t)
forall a (bs :: [*]) t p s.
(Generic a, MkPrismList (Rep a), Match (Rep a) bs t,
bs ~ Coll (Rep a) t) =>
Coproduct p s bs a t -> Grammar p s (a :- t)
match
(Coproduct Position (Sexp :- t) '[a :- t, b :- t] (Either a b) t
-> Grammar Position (Sexp :- t) (Either a b :- t))
-> Coproduct Position (Sexp :- t) '[a :- t, b :- t] (Either a b) t
-> Grammar Position (Sexp :- t) (Either a b :- t)
forall a b. (a -> b) -> a -> b
$ (Grammar Position (a :- t) (Either a b :- t)
-> Grammar Position (Sexp :- t) (Either a b :- t))
-> Coproduct Position (Sexp :- t) '[b :- t] (Either a b) t
-> Coproduct Position (Sexp :- t) '[a :- t, b :- t] (Either a b) t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With (\Grammar Position (a :- t) (Either a b :- t)
left -> Grammar Position (List :- t) (List :- (a :- t))
-> Grammar Position (Sexp :- t) (a :- t)
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
list (Grammar Position (Sexp :- t) t
-> Grammar Position (List :- t) (List :- t)
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
el (Text -> Grammar Position (Sexp :- t) t
forall t. Text -> Grammar Position (Sexp :- t) t
sym Text
"left") Grammar Position (List :- t) (List :- t)
-> Grammar Position (List :- t) (List :- (a :- t))
-> Grammar Position (List :- t) (List :- (a :- t))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- t) (a :- t)
-> Grammar Position (List :- t) (List :- (a :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
el Grammar Position (Sexp :- t) (a :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso) Grammar Position (Sexp :- t) (a :- t)
-> Grammar Position (a :- t) (Either a b :- t)
-> Grammar Position (Sexp :- t) (Either a b :- t)
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (a :- t) (Either a b :- t)
left)
(Coproduct Position (Sexp :- t) '[b :- t] (Either a b) t
-> Coproduct Position (Sexp :- t) '[a :- t, b :- t] (Either a b) t)
-> Coproduct Position (Sexp :- t) '[b :- t] (Either a b) t
-> Coproduct Position (Sexp :- t) '[a :- t, b :- t] (Either a b) t
forall a b. (a -> b) -> a -> b
$ (Grammar Position (b :- t) (Either a b :- t)
-> Grammar Position (Sexp :- t) (Either a b :- t))
-> Coproduct Position (Sexp :- t) '[] (Either a b) t
-> Coproduct Position (Sexp :- t) '[b :- t] (Either a b) t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With (\Grammar Position (b :- t) (Either a b :- t)
right -> Grammar Position (List :- t) (List :- (b :- t))
-> Grammar Position (Sexp :- t) (b :- t)
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
list (Grammar Position (Sexp :- t) t
-> Grammar Position (List :- t) (List :- t)
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
el (Text -> Grammar Position (Sexp :- t) t
forall t. Text -> Grammar Position (Sexp :- t) t
sym Text
"right") Grammar Position (List :- t) (List :- t)
-> Grammar Position (List :- t) (List :- (b :- t))
-> Grammar Position (List :- t) (List :- (b :- t))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- t) (b :- t)
-> Grammar Position (List :- t) (List :- (b :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
el Grammar Position (Sexp :- t) (b :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso) Grammar Position (Sexp :- t) (b :- t)
-> Grammar Position (b :- t) (Either a b :- t)
-> Grammar Position (Sexp :- t) (Either a b :- t)
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (b :- t) (Either a b :- t)
right)
(Coproduct Position (Sexp :- t) '[] (Either a b) t
-> Coproduct Position (Sexp :- t) '[b :- t] (Either a b) t)
-> Coproduct Position (Sexp :- t) '[] (Either a b) t
-> Coproduct Position (Sexp :- t) '[b :- t] (Either a b) t
forall a b. (a -> b) -> a -> b
$ Coproduct Position (Sexp :- t) '[] (Either a b) t
forall p s a t. Coproduct p s '[] a t
End
instance (SexpIso a) => SexpIso [a] where
sexpIso :: Grammar Position (Sexp :- t) ([a] :- t)
sexpIso = Grammar Position (List :- t) (List :- ([a] :- t))
-> Grammar Position (Sexp :- t) ([a] :- t)
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
list (Grammar Position (List :- t) (List :- ([a] :- t))
-> Grammar Position (Sexp :- t) ([a] :- t))
-> Grammar Position (List :- t) (List :- ([a] :- t))
-> Grammar Position (Sexp :- t) ([a] :- t)
forall a b. (a -> b) -> a -> b
$ (forall t1. Grammar Position (Sexp :- t1) (a :- t1))
-> Grammar Position (List :- t) (List :- ([a] :- t))
forall a t.
(forall t1. Grammar Position (Sexp :- t1) (a :- t1))
-> Grammar Position (List :- t) (List :- ([a] :- t))
rest forall t1. Grammar Position (Sexp :- t1) (a :- t1)
forall a. SexpIso a => SexpGrammar a
sexpIso
instance (SexpIso a) => SexpIso (NE.NonEmpty a) where
sexpIso :: Grammar Position (Sexp :- t) (NonEmpty a :- t)
sexpIso =
Grammar Position (List :- t) (List :- ([a] :- (a :- t)))
-> Grammar Position (Sexp :- t) ([a] :- (a :- t))
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
list (Grammar Position (Sexp :- t) (a :- t)
-> Grammar Position (List :- t) (List :- (a :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
el Grammar Position (Sexp :- t) (a :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar Position (List :- t) (List :- (a :- t))
-> Grammar Position (List :- (a :- t)) (List :- ([a] :- (a :- t)))
-> Grammar Position (List :- t) (List :- ([a] :- (a :- t)))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> (forall t1. Grammar Position (Sexp :- t1) (a :- t1))
-> Grammar Position (List :- (a :- t)) (List :- ([a] :- (a :- t)))
forall a t.
(forall t1. Grammar Position (Sexp :- t1) (a :- t1))
-> Grammar Position (List :- t) (List :- ([a] :- t))
rest forall t1. Grammar Position (Sexp :- t1) (a :- t1)
forall a. SexpIso a => SexpGrammar a
sexpIso) Grammar Position (Sexp :- t) ([a] :- (a :- t))
-> Grammar Position ([a] :- (a :- t)) (NonEmpty a :- t)
-> Grammar Position (Sexp :- t) (NonEmpty a :- t)
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
Grammar Position ([a] :- (a :- t)) ((a, [a]) :- t)
forall p b a t. Grammar p (b :- (a :- t)) ((a, b) :- t)
pair Grammar Position ([a] :- (a :- t)) ((a, [a]) :- t)
-> Grammar Position ((a, [a]) :- t) (NonEmpty a :- t)
-> Grammar Position ([a] :- (a :- t)) (NonEmpty a :- t)
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
((a, [a]) -> NonEmpty a)
-> (NonEmpty a -> (a, [a]))
-> Grammar Position ((a, [a]) :- t) (NonEmpty a :- t)
forall a b p t. (a -> b) -> (b -> a) -> Grammar p (a :- t) (b :- t)
iso (\(a
x,[a]
xs) -> a
x a -> [a] -> NonEmpty a
forall a. a -> [a] -> NonEmpty a
NE.:| [a]
xs )
(\(a
x NE.:| [a]
xs) -> (a
x, [a]
xs))