Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
sturdy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PLMZ
sturdy
Commits
41ab4f5f
Verified
Commit
41ab4f5f
authored
Sep 12, 2019
by
Sven Keidel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'context-sensitivity'
parents
4fe6f30f
2a2f6246
Changes
107
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
107 changed files
with
2370 additions
and
1470 deletions
+2370
-1470
lib/bench/ArrowTransformerBench.hs
lib/bench/ArrowTransformerBench.hs
+3
-1
lib/package.yaml
lib/package.yaml
+9
-1
lib/src/Control/Arrow/Fix.hs
lib/src/Control/Arrow/Fix.hs
+34
-15
lib/src/Control/Arrow/Fix/Cache.hs
lib/src/Control/Arrow/Fix/Cache.hs
+19
-0
lib/src/Control/Arrow/Fix/Chaotic.hs
lib/src/Control/Arrow/Fix/Chaotic.hs
+50
-0
lib/src/Control/Arrow/Fix/Context.hs
lib/src/Control/Arrow/Fix/Context.hs
+27
-0
lib/src/Control/Arrow/Fix/Reuse.hs
lib/src/Control/Arrow/Fix/Reuse.hs
+53
-0
lib/src/Control/Arrow/Fix/Stack.hs
lib/src/Control/Arrow/Fix/Stack.hs
+16
-0
lib/src/Control/Arrow/Fix/Widening.hs
lib/src/Control/Arrow/Fix/Widening.hs
+15
-0
lib/src/Control/Arrow/Monad.hs
lib/src/Control/Arrow/Monad.hs
+18
-0
lib/src/Control/Arrow/Order.hs
lib/src/Control/Arrow/Order.hs
+1
-0
lib/src/Control/Arrow/Reader.hs
lib/src/Control/Arrow/Reader.hs
+3
-11
lib/src/Control/Arrow/Store.hs
lib/src/Control/Arrow/Store.hs
+0
-1
lib/src/Control/Arrow/Trans.hs
lib/src/Control/Arrow/Trans.hs
+31
-8
lib/src/Control/Arrow/Transformer/Abstract/BoundedEnvironment.hs
.../Control/Arrow/Transformer/Abstract/BoundedEnvironment.hs
+6
-14
lib/src/Control/Arrow/Transformer/Abstract/Completion.hs
lib/src/Control/Arrow/Transformer/Abstract/Completion.hs
+2
-2
lib/src/Control/Arrow/Transformer/Abstract/Contour.hs
lib/src/Control/Arrow/Transformer/Abstract/Contour.hs
+0
-74
lib/src/Control/Arrow/Transformer/Abstract/Environment.hs
lib/src/Control/Arrow/Transformer/Abstract/Environment.hs
+4
-4
lib/src/Control/Arrow/Transformer/Abstract/Error.hs
lib/src/Control/Arrow/Transformer/Abstract/Error.hs
+2
-2
lib/src/Control/Arrow/Transformer/Abstract/Except.hs
lib/src/Control/Arrow/Transformer/Abstract/Except.hs
+2
-2
lib/src/Control/Arrow/Transformer/Abstract/Failure.hs
lib/src/Control/Arrow/Transformer/Abstract/Failure.hs
+2
-3
lib/src/Control/Arrow/Transformer/Abstract/Fix.hs
lib/src/Control/Arrow/Transformer/Abstract/Fix.hs
+4
-7
lib/src/Control/Arrow/Transformer/Abstract/Fix/Cache.hs
lib/src/Control/Arrow/Transformer/Abstract/Fix/Cache.hs
+60
-0
lib/src/Control/Arrow/Transformer/Abstract/Fix/Cache/Basic.hs
...src/Control/Arrow/Transformer/Abstract/Fix/Cache/Basic.hs
+62
-0
lib/src/Control/Arrow/Transformer/Abstract/Fix/Cache/ContextSensitive.hs
.../Arrow/Transformer/Abstract/Fix/Cache/ContextSensitive.hs
+104
-0
lib/src/Control/Arrow/Transformer/Abstract/Fix/Cache/Group.hs
...src/Control/Arrow/Transformer/Abstract/Fix/Cache/Group.hs
+73
-0
lib/src/Control/Arrow/Transformer/Abstract/Fix/Chaotic.hs
lib/src/Control/Arrow/Transformer/Abstract/Fix/Chaotic.hs
+110
-102
lib/src/Control/Arrow/Transformer/Abstract/Fix/Context.hs
lib/src/Control/Arrow/Transformer/Abstract/Fix/Context.hs
+57
-0
lib/src/Control/Arrow/Transformer/Abstract/Fix/Finite.hs
lib/src/Control/Arrow/Transformer/Abstract/Fix/Finite.hs
+0
-47
lib/src/Control/Arrow/Transformer/Abstract/Fix/IterationStrategy.hs
...ntrol/Arrow/Transformer/Abstract/Fix/IterationStrategy.hs
+0
-41
lib/src/Control/Arrow/Transformer/Abstract/Fix/Parallel.hs
lib/src/Control/Arrow/Transformer/Abstract/Fix/Parallel.hs
+78
-86
lib/src/Control/Arrow/Transformer/Abstract/Fix/Stack.hs
lib/src/Control/Arrow/Transformer/Abstract/Fix/Stack.hs
+91
-0
lib/src/Control/Arrow/Transformer/Abstract/Fix/StackWidening.hs
...c/Control/Arrow/Transformer/Abstract/Fix/StackWidening.hs
+0
-45
lib/src/Control/Arrow/Transformer/Abstract/Fix/Trace.hs
lib/src/Control/Arrow/Transformer/Abstract/Fix/Trace.hs
+71
-0
lib/src/Control/Arrow/Transformer/Abstract/Powerset.hs
lib/src/Control/Arrow/Transformer/Abstract/Powerset.hs
+2
-2
lib/src/Control/Arrow/Transformer/Abstract/ReachingDefinitions.hs
...Control/Arrow/Transformer/Abstract/ReachingDefinitions.hs
+1
-2
lib/src/Control/Arrow/Transformer/Abstract/Store.hs
lib/src/Control/Arrow/Transformer/Abstract/Store.hs
+7
-4
lib/src/Control/Arrow/Transformer/Abstract/Terminating.hs
lib/src/Control/Arrow/Transformer/Abstract/Terminating.hs
+2
-2
lib/src/Control/Arrow/Transformer/Cokleisli.hs
lib/src/Control/Arrow/Transformer/Cokleisli.hs
+141
-0
lib/src/Control/Arrow/Transformer/Concrete/Contour.hs
lib/src/Control/Arrow/Transformer/Concrete/Contour.hs
+0
-64
lib/src/Control/Arrow/Transformer/Concrete/Environment.hs
lib/src/Control/Arrow/Transformer/Concrete/Environment.hs
+2
-2
lib/src/Control/Arrow/Transformer/Concrete/Except.hs
lib/src/Control/Arrow/Transformer/Concrete/Except.hs
+2
-3
lib/src/Control/Arrow/Transformer/Concrete/Failure.hs
lib/src/Control/Arrow/Transformer/Concrete/Failure.hs
+2
-3
lib/src/Control/Arrow/Transformer/Concrete/Random.hs
lib/src/Control/Arrow/Transformer/Concrete/Random.hs
+2
-2
lib/src/Control/Arrow/Transformer/Concrete/ReachingDefinitions.hs
...Control/Arrow/Transformer/Concrete/ReachingDefinitions.hs
+1
-2
lib/src/Control/Arrow/Transformer/Concrete/Store.hs
lib/src/Control/Arrow/Transformer/Concrete/Store.hs
+4
-5
lib/src/Control/Arrow/Transformer/Const.hs
lib/src/Control/Arrow/Transformer/Const.hs
+26
-9
lib/src/Control/Arrow/Transformer/Cont.hs
lib/src/Control/Arrow/Transformer/Cont.hs
+24
-7
lib/src/Control/Arrow/Transformer/FreeVars.hs
lib/src/Control/Arrow/Transformer/FreeVars.hs
+10
-5
lib/src/Control/Arrow/Transformer/Kleisli.hs
lib/src/Control/Arrow/Transformer/Kleisli.hs
+4
-16
lib/src/Control/Arrow/Transformer/ReachingDefinitions.hs
lib/src/Control/Arrow/Transformer/ReachingDefinitions.hs
+14
-14
lib/src/Control/Arrow/Transformer/Reader.hs
lib/src/Control/Arrow/Transformer/Reader.hs
+36
-24
lib/src/Control/Arrow/Transformer/State.hs
lib/src/Control/Arrow/Transformer/State.hs
+30
-26
lib/src/Control/Arrow/Transformer/Static.hs
lib/src/Control/Arrow/Transformer/Static.hs
+19
-8
lib/src/Control/Arrow/Transformer/Value.hs
lib/src/Control/Arrow/Transformer/Value.hs
+5
-16
lib/src/Control/Arrow/Transformer/Writer.hs
lib/src/Control/Arrow/Transformer/Writer.hs
+50
-22
lib/src/Control/Arrow/Utils.hs
lib/src/Control/Arrow/Utils.hs
+16
-0
lib/src/Data/Abstract/Boolean.hs
lib/src/Data/Abstract/Boolean.hs
+18
-3
lib/src/Data/Abstract/Cache.hs
lib/src/Data/Abstract/Cache.hs
+0
-113
lib/src/Data/Abstract/CallString.hs
lib/src/Data/Abstract/CallString.hs
+41
-0
lib/src/Data/Abstract/Closure.hs
lib/src/Data/Abstract/Closure.hs
+1
-1
lib/src/Data/Abstract/DiscretePowerset.hs
lib/src/Data/Abstract/DiscretePowerset.hs
+10
-8
lib/src/Data/Abstract/Either.hs
lib/src/Data/Abstract/Either.hs
+11
-26
lib/src/Data/Abstract/Error.hs
lib/src/Data/Abstract/Error.hs
+6
-4
lib/src/Data/Abstract/Except.hs
lib/src/Data/Abstract/Except.hs
+11
-6
lib/src/Data/Abstract/Failure.hs
lib/src/Data/Abstract/Failure.hs
+7
-5
lib/src/Data/Abstract/FreeCompletion.hs
lib/src/Data/Abstract/FreeCompletion.hs
+14
-4
lib/src/Data/Abstract/InfiniteNumbers.hs
lib/src/Data/Abstract/InfiniteNumbers.hs
+18
-12
lib/src/Data/Abstract/Interval.hs
lib/src/Data/Abstract/Interval.hs
+9
-3
lib/src/Data/Abstract/Map.hs
lib/src/Data/Abstract/Map.hs
+3
-2
lib/src/Data/Abstract/Maybe.hs
lib/src/Data/Abstract/Maybe.hs
+7
-6
lib/src/Data/Abstract/Sign.hs
lib/src/Data/Abstract/Sign.hs
+2
-1
lib/src/Data/Abstract/Stable.hs
lib/src/Data/Abstract/Stable.hs
+42
-0
lib/src/Data/Abstract/Stack.hs
lib/src/Data/Abstract/Stack.hs
+0
-6
lib/src/Data/Abstract/StackWidening.hs
lib/src/Data/Abstract/StackWidening.hs
+0
-116
lib/src/Data/Abstract/StrongMap.hs
lib/src/Data/Abstract/StrongMap.hs
+8
-5
lib/src/Data/Abstract/Terminating.hs
lib/src/Data/Abstract/Terminating.hs
+10
-2
lib/src/Data/Abstract/There.hs
lib/src/Data/Abstract/There.hs
+3
-2
lib/src/Data/Abstract/TreeGrammar.hs
lib/src/Data/Abstract/TreeGrammar.hs
+2
-2
lib/src/Data/Abstract/TreeGrammar/Terminal.hs
lib/src/Data/Abstract/TreeGrammar/Terminal.hs
+2
-1
lib/src/Data/Abstract/WeakMap.hs
lib/src/Data/Abstract/WeakMap.hs
+1
-1
lib/src/Data/Abstract/Widening.hs
lib/src/Data/Abstract/Widening.hs
+8
-27
lib/src/Data/Label.hs
lib/src/Data/Label.hs
+2
-2
lib/src/Data/Metric.hs
lib/src/Data/Metric.hs
+34
-0
lib/src/Data/Monoidal.hs
lib/src/Data/Monoidal.hs
+87
-26
lib/src/Data/OrdMap.hs
lib/src/Data/OrdMap.hs
+2
-3
lib/src/Data/Order.hs
lib/src/Data/Order.hs
+1
-3
lib/test/ContextSensitivitySpec.hs
lib/test/ContextSensitivitySpec.hs
+166
-0
lib/test/FixSpec.hs
lib/test/FixSpec.hs
+0
-188
lib/test/FixpointSpec.hs
lib/test/FixpointSpec.hs
+111
-0
lib/test/TestPrograms.hs
lib/test/TestPrograms.hs
+101
-0
pcf/src/ConcreteInterpreter.hs
pcf/src/ConcreteInterpreter.hs
+1
-1
pcf/src/GenericInterpreter.hs
pcf/src/GenericInterpreter.hs
+1
-1
pcf/src/IntervalAnalysis.hs
pcf/src/IntervalAnalysis.hs
+54
-51
pcf/src/Syntax.hs
pcf/src/Syntax.hs
+4
-4
pcf/src/VariableAnalysis.hs
pcf/src/VariableAnalysis.hs
+23
-11
pcf/test/IntervalAnalysisSpec.hs
pcf/test/IntervalAnalysisSpec.hs
+22
-14
stack.yaml
stack.yaml
+2
-2
tutorial/src/SturdyStyle/AbstractInterpreter.hs
tutorial/src/SturdyStyle/AbstractInterpreter.hs
+0
-1
tutorial/src/SturdyStyle/GenericInterpreter.hs
tutorial/src/SturdyStyle/GenericInterpreter.hs
+16
-16
while/src/ConcreteInterpreter.hs
while/src/ConcreteInterpreter.hs
+2
-2
while/src/GenericInterpreter.hs
while/src/GenericInterpreter.hs
+1
-1
while/src/IntervalAnalysis.hs
while/src/IntervalAnalysis.hs
+32
-29
while/src/ReachingDefinitionsAnalysis.hs
while/src/ReachingDefinitionsAnalysis.hs
+37
-29
while/src/Syntax.hs
while/src/Syntax.hs
+8
-8
while/src/UnitSemantics.hs
while/src/UnitSemantics.hs
+16
-12
while/test/ReachingDefinitionsSpec.hs
while/test/ReachingDefinitionsSpec.hs
+6
-6
No files found.
lib/bench/ArrowTransformerBench.hs
View file @
41ab4f5f
...
@@ -17,8 +17,10 @@ import Data.Profunctor
...
@@ -17,8 +17,10 @@ import Data.Profunctor
import
Data.Abstract.Error
import
Data.Abstract.Error
import
Data.Abstract.Except
import
Data.Abstract.Except
import
Data.Abstract.Cache
import
Data.Abstract.Cache
import
qualified
Data.Abstract.Widening
as
W
import
Control.DeepSeq
import
Control.DeepSeq
import
Control.Category
import
Control.Arrow
import
Control.Arrow
import
Control.Arrow.Transformer.Const
import
Control.Arrow.Transformer.Const
import
Control.Arrow.Transformer.Reader
import
Control.Arrow.Transformer.Reader
...
@@ -164,7 +166,7 @@ main = do
...
@@ -164,7 +166,7 @@ main = do
{-# INLINE runExceptT' #-}
{-# INLINE runExceptT' #-}
runChaoticT''
::
Profunctor
c
=>
ChaoticT
Cache
()
()
c
x
y
->
c
x
y
runChaoticT''
::
Profunctor
c
=>
ChaoticT
Cache
()
()
c
x
y
->
c
x
y
runChaoticT''
=
runChaoticT'
runChaoticT''
=
runChaoticT'
id
W
.
finite
{-# INLINE runChaoticT'' #-}
{-# INLINE runChaoticT'' #-}
expr
=
addN
20
(
Num
1
)
expr
=
addN
20
(
Num
1
)
...
...
lib/package.yaml
View file @
41ab4f5f
...
@@ -9,6 +9,7 @@ category: Language
...
@@ -9,6 +9,7 @@ category: Language
dependencies
:
dependencies
:
-
base
-
base
-
containers
-
containers
-
comonad
-
hashable
-
hashable
-
mtl
-
mtl
-
random
-
random
...
@@ -19,7 +20,14 @@ dependencies:
...
@@ -19,7 +20,14 @@ dependencies:
-
profunctors
-
profunctors
library
:
library
:
ghc-options
:
-Wall
ghc-options
:
-Wall
-Wcompat
-Widentities
-Wincomplete-record-updates
-Wincomplete-uni-patterns
-Wpartial-fields
-Wredundant-constraints
source-dirs
:
source-dirs
:
-
src
-
src
...
...
lib/src/Control/Arrow/Fix.hs
View file @
41ab4f5f
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE Arrows #-}
{-# LANGUAGE Arrows #-}
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE DefaultSignatures #-}
module
Control.Arrow.Fix
(
Fix
,
ArrowFix
(
..
),
liftFix
,
IterationStrategy
)
where
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
module
Control.Arrow.Fix
(
Fix
,
Fix'
,
ArrowFix
(
..
),
IterationStrategy
,
transform
,
filter
)
where
import
Prelude
hiding
(
filter
,
pred
)
import
Control.Arrow
import
Control.Arrow
import
Control.Arrow.Trans
import
Control.Arrow.Trans
import
Data.Profunctor
import
Data.Profunctor
import
Data.Lens
(
Iso'
,
from
,
Prism'
,
getMaybe
,
get
,
set
)
-- | Type family that computes the type of the fixpoint.
-- | Type family that computes the type of the fixpoint.
type
family
Fix
x
y
(
c
::
*
->
*
->
*
)
::
*
->
*
->
*
type
family
Fix
(
c
::
*
->
*
->
*
)
x
y
::
*
->
*
->
*
type
Fix'
c
x
y
=
Fix
c
x
y
x
y
-- | Interface for describing fixpoint computations.
-- | Interface for describing fixpoint computations.
class
(
Arrow
c
,
Profunctor
c
)
=>
ArrowFix
x
y
c
where
class
ArrowFix
c
where
-- | Computes the fixpoint of an arrow computation.
-- | Computes the fixpoint of an arrow computation.
fix
::
(
c
x
y
->
c
x
y
)
->
c
x
y
fix
::
(
c
->
c
)
->
c
type
instance
Fix
x
y
(
->
)
=
(
->
)
default
fix
::
(
c
~
c'
x
y
,
ArrowTrans
c'
,
Underlying
c'
x
y
~
c''
x'
y'
,
ArrowFix
(
c''
x'
y'
))
=>
(
c
->
c
)
->
c
instance
ArrowFix
x
y
(
->
)
where
fix
f
=
lift
(
fix
(
unlift
.
f
.
lift
))
fix
f
=
f
(
fix
f
)
{-# INLINE fix #-}
liftFix
::
(
Arrow
c
,
Profunctor
c
,
ArrowFix
(
Dom
t
x
y
)
(
Cod
t
x
y
)
c
,
ArrowTrans
t
)
=>
(
t
c
x
y
->
t
c
x
y
)
->
t
c
x
y
type
instance
Fix
(
->
)
x
y
=
(
->
)
liftFix
f
=
lift
$
fix
(
unlift
.
f
.
lift
)
instance
ArrowFix
(
x
->
y
)
where
{-# INLINE liftFix #-}
fix
f
=
f
(
fix
f
)
type
IterationStrategy
c
a
b
=
c
a
b
->
c
a
b
type
IterationStrategy
c
a
b
=
c
a
b
->
c
a
b
transform
::
Profunctor
c
=>
Iso'
a
a'
->
IterationStrategy
c
a'
b
->
IterationStrategy
c
a
b
transform
iso
strat
f
=
lmap
(
get
iso
)
(
strat
(
lmap
(
get
(
from
iso
))
f
))
{-# INLINE transform #-}
filter
::
(
Profunctor
c
,
ArrowChoice
c
,
ArrowApply
c
)
=>
Prism'
a
a'
->
IterationStrategy
c
a'
b
->
IterationStrategy
c
a
b
filter
pred
strat
f
=
proc
a
->
case
getMaybe
pred
a
of
Just
a'
->
strat
(
lmap
(
\
x
->
set
pred
x
a
)
f
)
-<<
a'
Nothing
->
f
-<
a
{-# INLINE filter #-}
lib/src/Control/Arrow/Fix/Cache.hs
0 → 100644
View file @
41ab4f5f
{-# LANGUAGE FunctionalDependencies #-}
module
Control.Arrow.Fix.Cache
where
import
Control.Arrow
import
Data.Profunctor
import
Data.Abstract.Stable
class
(
Arrow
c
,
Profunctor
c
)
=>
ArrowCache
a
b
c
|
c
->
a
,
c
->
b
where
-- | Looks up if there is an entry in the cache.
lookup
::
c
a
(
Maybe
(
Stable
,
b
))
-- | Write a new entry to the cache.
write
::
c
(
a
,
b
,
Stable
)
()
-- | Update an existing entry in the cache.
update
::
c
(
a
,
b
)
(
Stable
,
b
)
-- | Set a given entry to stable or unstable.
setStable
::
c
(
Stable
,
a
)
()
lib/src/Control/Arrow/Fix/Chaotic.hs
0 → 100644
View file @
41ab4f5f
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
module
Control.Arrow.Fix.Chaotic
where
import
Prelude
hiding
(
head
)
import
Control.Arrow
import
Data.HashSet
(
HashSet
)
import
qualified
Data.HashSet
as
H
import
Data.Identifiable
import
Data.Profunctor
import
Data.Order
import
Text.Printf
class
(
Arrow
c
,
Profunctor
c
)
=>
ArrowIterate
a
c
where
-- | Remembers to iterate on an unstable result until it stabilized.
iterate
::
c
(
a
,
b
)
b
class
(
Arrow
c
,
Profunctor
c
)
=>
ArrowComponent
a
c
|
c
->
a
where
setComponent
::
c
(
Component
a
,
y
)
y
withComponent
::
c
x
y
->
(
c
(
x
,
y
,
Component
a
)
y
)
->
c
x
y
data
Component
a
=
Component
{
head
::
HashSet
a
,
body
::
HashSet
a
}
deriving
(
Eq
)
instance
Identifiable
a
=>
PreOrd
(
Component
a
)
where
c1
⊑
c2
=
head
c1
⊑
head
c2
&&
body
c1
⊑
body
c2
{-# INLINE (⊑) #-}
instance
Identifiable
a
=>
Complete
(
Component
a
)
where
c1
⊔
c2
=
c1
<>
c2
{-# INLINE (⊔) #-}
instance
Identifiable
a
=>
Semigroup
(
Component
a
)
where
Component
h1
b1
<>
Component
h2
b2
=
Component
{
head
=
h1
<>
h2
,
body
=
b1
<>
b2
}
{-# INLINE (<>) #-}
instance
Identifiable
a
=>
Monoid
(
Component
a
)
where
mempty
=
Component
{
head
=
H
.
empty
,
body
=
H
.
empty
}
mappend
=
(
<>
)
{-# INLINE mempty #-}
{-# INLINE mappend #-}
singleton
::
Identifiable
a
=>
a
->
Component
a
singleton
a
=
Component
{
head
=
H
.
singleton
a
,
body
=
H
.
empty
}
{-# INLINE singleton #-}
instance
Show
a
=>
Show
(
Component
a
)
where
show
(
Component
h
b
)
=
printf
"Component { head = %s, body = %s }"
(
show
(
H
.
toList
h
))
(
show
(
H
.
toList
b
))
lib/src/Control/Arrow/Fix/Context.hs
0 → 100644
View file @
41ab4f5f
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE Arrows #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE TypeFamilies #-}
module
Control.Arrow.Fix.Context
where
import
Control.Arrow
import
Control.Arrow.Fix
import
Control.Arrow.State
import
Data.Profunctor
class
(
Arrow
c
,
Profunctor
c
)
=>
ArrowContext
ctx
c
|
c
->
ctx
where
askContext
::
c
()
ctx
localContext
::
c
x
y
->
c
(
ctx
,
x
)
y
class
ArrowJoinContext
cache
a
b
c
where
type
Widening
cache
a
::
*
joinContexts'
::
Widening
cache
a
->
IterationStrategy
c
(
cache
a
b
,
a
)
b
joinContexts
::
forall
a
cache
b
c
.
(
ArrowState
(
cache
a
b
)
c
,
ArrowJoinContext
cache
a
b
c
)
=>
Widening
cache
a
->
IterationStrategy
c
a
b
joinContexts
widen
f
=
proc
a
->
do
cache
<-
get
-<
()
joinContexts'
widen
(
proc
(
cache
,
a
)
->
do
put
-<
cache
f
-<
a
)
-<
(
cache
,
a
)
{-# INLINE joinContexts #-}
lib/src/Control/Arrow/Fix/Reuse.hs
0 → 100644
View file @
41ab4f5f
{-# LANGUAGE Arrows #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TypeFamilies #-}
module
Control.Arrow.Fix.Reuse
where
import
Control.Arrow
import
Control.Arrow.Fix
import
Data.Abstract.Stable
import
Data.Metric
import
Data.Profunctor
import
Data.Monoid
import
Text.Printf
class
(
Arrow
c
,
Profunctor
c
)
=>
ArrowReuse
a
b
c
where
type
Dom
c
::
*
-- | Reuse cached results at the cost of precision.
reuse
::
(
Monoid
m
)
=>
(
Dom
c
->
Dom
c
->
Stable
->
b
->
m
)
->
c
(
a
,
Stable
)
m
reuseFirst
::
(
ArrowChoice
c
,
ArrowReuse
a
b
c
)
=>
IterationStrategy
c
a
b
reuseFirst
f
=
proc
a
->
do
m
<-
reuse
(
\
_
_
_
b
->
First
(
Just
b
))
-<
(
a
,
Stable
)
case
getFirst
m
of
Just
b
->
returnA
-<
b
Nothing
->
f
-<
a
{-# INLINE reuseFirst #-}
reuseExact
::
(
Eq
(
Dom
c
),
ArrowChoice
c
,
ArrowReuse
a
b
c
)
=>
IterationStrategy
c
a
b
reuseExact
=
reuseByMetric
discrete
{-# INLINE reuseExact #-}
reuseByMetric
::
(
Ord
n
,
ArrowChoice
c
,
ArrowReuse
a
b
c
)
=>
Metric
(
Dom
c
)
n
->
IterationStrategy
c
a
b
reuseByMetric
metric
f
=
proc
a
->
do
m
<-
reuse
(
\
a
a'
_
b
->
Just
(
Measured
{
measured
=
metric
a
a'
,
argument
=
b
}))
-<
(
a
,
Stable
)
case
m
of
Just
n
->
returnA
-<
argument
n
Nothing
->
f
-<
a
{-# INLINE reuseByMetric #-}
data
Measured
a
n
=
Measured
{
argument
::
a
,
measured
::
n
}
instance
(
Show
a
,
Show
n
)
=>
Show
(
Measured
a
n
)
where
show
m
=
printf
"%s@%s"
(
show
(
argument
m
))
(
show
(
measured
m
))
instance
Ord
n
=>
Semigroup
(
Measured
a
n
)
where
m1
<>
m2
|
measured
m1
<=
measured
m2
=
m1
|
otherwise
=
m2
{-# INLINE (<>) #-}
lib/src/Control/Arrow/Fix/Stack.hs
0 → 100644
View file @
41ab4f5f
{-# LANGUAGE Arrows #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FunctionalDependencies #-}
module
Control.Arrow.Fix.Stack
where
import
Control.Arrow
import
Data.Profunctor
import
Data.HashSet
class
(
Arrow
c
,
Profunctor
c
)
=>
ArrowStack
a
c
|
c
->
a
where
peek
::
c
()
(
Maybe
a
)
size
::
c
()
Int
push
::
c
a
b
->
c
a
b
elem
::
c
a
Bool
elems
::
c
()
(
HashSet
a
)
lib/src/Control/Arrow/Fix/Widening.hs
0 → 100644
View file @
41ab4f5f
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances #-}
module
Control.Arrow.Fix.Widening
where
import
Control.Arrow
import
Data.Profunctor
import
Data.Order
import
Data.Abstract.Stable
import
Data.Abstract.Widening
(
finite
)
class
(
Arrow
c
,
Profunctor
c
)
=>
ArrowWidening
a
c
where
widening
::
c
(
a
,
a
)
(
Stable
,
a
)
instance
Complete
a
=>
ArrowWidening
a
(
->
)
where
widening
(
a
,
a'
)
=
finite
a
a'
lib/src/Control/Arrow/Monad.hs
View file @
41ab4f5f
...
@@ -3,6 +3,7 @@ module Control.Arrow.Monad where
...
@@ -3,6 +3,7 @@ module Control.Arrow.Monad where
import
Control.Arrow
import
Control.Arrow
import
Control.Monad
(
join
)
import
Control.Monad
(
join
)
import
Control.Comonad
import
Data.Profunctor
import
Data.Profunctor
class
(
Functor
f
,
Arrow
c
,
Profunctor
c
)
=>
ArrowFunctor
f
c
where
class
(
Functor
f
,
Arrow
c
,
Profunctor
c
)
=>
ArrowFunctor
f
c
where
...
@@ -17,3 +18,20 @@ class (Monad f, ArrowFunctor f c) => ArrowMonad f c where
...
@@ -17,3 +18,20 @@ class (Monad f, ArrowFunctor f c) => ArrowMonad f c where
mapJoinA
::
c
x
(
f
y
)
->
c
(
f
x
)
(
f
y
)
mapJoinA
::
c
x
(
f
y
)
->
c
(
f
x
)
(
f
y
)
mapJoinA
f
=
rmap
join
(
mapA
f
)
mapJoinA
f
=
rmap
join
(
mapA
f
)
{-# INLINE unitA #-}
{-# INLINE joinA #-}
{-# INLINE mapJoinA #-}
class
(
Comonad
f
,
ArrowFunctor
f
c
)
=>
ArrowComonad
f
c
where
extractA
::
c
(
f
x
)
x
extractA
=
arr
extract
duplicateA
::
c
(
f
x
)
(
f
(
f
x
))
duplicateA
=
arr
duplicate
mapDuplicateA
::
c
(
f
x
)
y
->
c
(
f
x
)
(
f
y
)
mapDuplicateA
f
=
lmap
duplicate
(
mapA
f
)
{-# INLINE extractA #-}
{-# INLINE duplicateA #-}
{-# INLINE mapDuplicateA #-}
lib/src/Control/Arrow/Order.hs
View file @
41ab4f5f
...
@@ -19,6 +19,7 @@ class (Arrow c, Profunctor c) => ArrowComplete y c where
...
@@ -19,6 +19,7 @@ class (Arrow c, Profunctor c) => ArrowComplete y c where
instance
Complete
y
=>
ArrowComplete
y
(
->
)
where
instance
Complete
y
=>
ArrowComplete
y
(
->
)
where
(
<
⊔
>
)
f
g
=
\
x
->
f
x
⊔
g
x
(
<
⊔
>
)
f
g
=
\
x
->
f
x
⊔
g
x
{-# INLINE (<⊔>) #-}
-- | An arrow computation @c@ is effect commutative iff for all @f, g :: c x y@,
-- | An arrow computation @c@ is effect commutative iff for all @f, g :: c x y@,
--
--
...
...
lib/src/Control/Arrow/Reader.hs
View file @
41ab4f5f
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE UndecidableInstances #-}
module
Control.Arrow.Reader
where
module
Control.Arrow.Reader
where
import
Control.Arrow
import
Control.Arrow
import
Control.Monad.Reader
(
MonadReader
)
import
Data.Profunctor
import
qualified
Control.Monad.Reader
as
M
import
Data.Profunctor
-- | Arrow-based interface for read-only values.
-- | Arrow-based interface for read-only values.
class
(
Arrow
c
,
Profunctor
c
)
=>
ArrowReader
r
c
|
c
->
r
where
class
(
Arrow
c
,
Profunctor
c
)
=>
ArrowReader
r
c
|
c
->
r
where
...
@@ -15,7 +11,3 @@ class (Arrow c, Profunctor c) => ArrowReader r c | c -> r where
...
@@ -15,7 +11,3 @@ class (Arrow c, Profunctor c) => ArrowReader r c | c -> r where
ask
::
c
()
r
ask
::
c
()
r
-- | Runs a computation with a new value.
-- | Runs a computation with a new value.
local
::
c
x
y
->
c
(
r
,
x
)
y
local
::
c
x
y
->
c
(
r
,
x
)
y
instance
MonadReader
r
m
=>
ArrowReader
r
(
Kleisli
m
)
where
ask
=
Kleisli
(
const
M
.
ask
)
local
(
Kleisli
f
)
=
Kleisli
(
\
(
r
,
x
)
->
M
.
local
(
const
r
)
(
f
x
))
lib/src/Control/Arrow/Store.hs
View file @
41ab4f5f
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE ConstraintKinds #-}
...
...
lib/src/Control/Arrow/Trans.hs
View file @
41ab4f5f
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeFamilies #-}
module
Control.Arrow.Trans
where
module
Control.Arrow.Trans
where
import
Control.Arrow
import
Control.Arrow
import
Data.Profunctor
import
Data.Profunctor
import
Data.Coerce
class
(
Arrow
c
,
Profunctor
c
)
=>
ArrowRun
c
where
class
(
Arrow
c
,
Profunctor
c
)
=>
ArrowRun
c
where
type
Rep
c
x
y
type
Run
c
x
y
run
::
c
x
y
->
Rep
c
x
y
run
::
c
x
y
->
Run
c
x
y
default
run
::
(
Underlying
c
x
y
~
c'
x'
y'
,
Run
c
x
y
~
Run
c'
x'
y'
,
ArrowRun
c'
,
ArrowTrans
c
)
=>
c
x
y
->
Run
c
x
y
run
=
run
.
unlift
{-# INLINE run #-}
instance
ArrowRun
(
->
)
where
instance
ArrowRun
(
->
)
where
type
R
ep
(
->
)
x
y
=
x
->
y
type
R
un
(
->
)
x
y
=
x
->
y
run
=
id
run
=
id
{-# INLINE run #-}
class
ArrowLift
t
where
class
ArrowLift
t
where
lift'
::
(
Arrow
c
,
Profunctor
c
)
=>
c
x
y
->
t
c
x
y
lift'
::
(
Arrow
c
,
Profunctor
c
)
=>
c
x
y
->
t
c
x
y
-- | Lifts an inner computation into an arrow transformer and vice versa.
-- | Lifts an inner computation into an arrow transformer and vice versa.
class
ArrowTrans
t
where
class
ArrowTrans
c
where
type
Dom
t
x
y
::
*
type
Underlying
c
x
y
::
*
type
Cod
t
x
y
::
*
lift
::
Underlying
c
x
y
->
c
x
y
unlift
::
c
x
y
->
Underlying
c
x
y
default
lift
::
forall
x
y
.
(
Coercible
(
c
x
y
)
(
Underlying
c
x
y
))
=>
Underlying
c
x
y
->
c
x
y
lift
=
coerce
{-# INLINE lift #-}
default
unlift
::
forall
x
y
.
(
Coercible
(
c
x
y
)
(
Underlying
c
x
y
))
=>
c
x
y
->
Underlying
c
x
y
unlift
=
coerce
{-# INLINE unlift #-}
lift1
::
ArrowTrans
c
=>
(
Underlying
c
x
y
->
Underlying
c
x'
y'
)
->
(
c
x
y
->
c
x'
y'
)
lift1
f
=
lift
.
f
.
unlift
{-# INLINE lift1 #-}
lift
::
(
Arrow
c
,
Profunctor
c
)
=>
c
(
Dom
t
x
y
)
(
Cod
t
x
y
)
->
t
c
x
y
unlift1
::
ArrowTrans
c
=>
(
c
x
y
->
c
x'
y'
)
->
(
Underlying
c
x
y
->
Underlying
c
x'
y'
)
unlift
::
(
Arrow
c
,
Profunctor
c
)
=>
t
c
x
y
->
c
(
Dom
t
x
y
)
(
Cod
t
x
y
)
unlift1
f
=
unlift
.
f
.
lift
{-# INLINE unlift1 #-}
lib/src/Control/Arrow/Transformer/Abstract/BoundedEnvironment.hs
View file @
41ab4f5f
...
@@ -44,12 +44,11 @@ type Env var addr val = (HM.HashMap var addr,HM.HashMap addr val)
...
@@ -44,12 +44,11 @@ type Env var addr val = (HM.HashMap var addr,HM.HashMap addr val)
type
Alloc
c
var
addr
val
=
c
(
var
,
val
,
Env
var
addr
val
)
addr
type
Alloc
c
var
addr
val
=
c
(
var
,
val
,
Env
var
addr
val
)
addr
newtype
EnvT
var
addr
val
c
x
y
=
EnvT
(
ConstT
(
Alloc
c
var
addr
val
)
(
ReaderT
(
Env
var
addr
val
)
c
)
x
y
)
newtype
EnvT
var
addr
val
c
x
y
=
EnvT
(
ConstT
(
Alloc
c
var
addr
val
)
(
ReaderT
(
Env
var
addr
val
)
c
)
x
y
)
deriving
(
Profunctor
,
Category
,
Arrow
,
ArrowChoice
,
ArrowFail
e
,
ArrowComplete
z
,
ArrowLowerBounded
)
deriving
(
Profunctor
,
Category
,
Arrow
,
ArrowChoice
,
ArrowFail
e
,
ArrowComplete
z
,
ArrowLowerBounded
,
ArrowTrans
)
deriving
instance
ArrowExcept
e
c
=>
ArrowExcept
e
(
EnvT
var
addr
val
c
)
deriving
instance
ArrowExcept
e
c
=>
ArrowExcept
e
(
EnvT
var
addr
val
c
)
runEnvT
::
(
Identifiable
var
,
Identifiable
addr
,
Complete
val
,
ArrowChoice
c
,
Profunctor
c
)
runEnvT
::
Alloc
c
var
addr
val
->
EnvT
var
addr
val
c
x
y
->
c
(
Env
var
addr
val
,
x
)
y
=>
Alloc
c
var
addr
val
->
EnvT
var
addr
val
c
x
y
->
c
(
Env
var
addr
val
,
x
)
y
runEnvT
alloc
(
EnvT
f
)
=
runReaderT
(
runConstT
alloc
f
)
runEnvT
alloc
(
EnvT
f
)
=
runReaderT
(
runConstT
alloc
f
)
instance
(
Identifiable
var
,
Identifiable
addr
,
Complete
val
,
ArrowChoice
c
,
Profunctor
c
)
=>
instance
(
Identifiable
var
,
Identifiable
addr
,
Complete
val
,
ArrowChoice
c
,
Profunctor
c
)
=>
...
@@ -73,16 +72,10 @@ instance (Identifiable var, Identifiable addr, Complete val, ArrowChoice c, Prof
...
@@ -73,16 +72,10 @@ instance (Identifiable var, Identifiable addr, Complete val, ArrowChoice c, Prof
(
_
,
store
)
<-
Reader
.
ask
-<
()
(
_
,
store
)
<-
Reader
.
ask
-<
()
Reader
.
local
f
-<
((
env
,
store
),
x
)
Reader
.
local
f
-<
((
env
,
store
),
x
)
instance
(
Identifiable
var
,
Identifiable
addr
,
Complete
val
,
ArrowChoice
c
,
ArrowRun
c
)
=>
ArrowRun
(
EnvT
var
addr
val
c
)
where
instance
(
ArrowChoice
c
,
ArrowRun
c
)
=>
ArrowRun
(
EnvT
var
addr
val
c
)
where
type
R
ep
(
EnvT
var
addr
val
c
)
x
y
=
Alloc
c
var
addr
val
->
Rep
c
(
Env
var
addr
val
,
x
)
y
type
R
un
(
EnvT
var
addr
val
c
)
x
y
=
Alloc
c
var
addr
val
->
Run
c
(
Env
var
addr
val
,
x
)
y
run
f
alloc
=
run
(
runEnvT
alloc
f
)
run
f
alloc
=
run
(
runEnvT
alloc
f
)
instance
ArrowTrans
(
EnvT
var
addr
val
)
where
type
Dom
(
EnvT
var
addr
val
)
x
y
=
(
Env
var
addr
val
,
x
)
type
Cod
(
EnvT
var
addr
val
)
x
y
=
y
lift
=
undefined
unlift
=
undefined
instance
ArrowLift
(
EnvT
var
addr
val
)
where
instance
ArrowLift
(
EnvT
var
addr
val
)
where
lift'
f
=
EnvT
(
lift'
(
lift'
f
))
lift'
f
=
EnvT
(
lift'
(
lift'
f
))
...
@@ -94,6 +87,5 @@ instance ArrowReader r c => ArrowReader r (EnvT var addr val c) where
...
@@ -94,6 +87,5 @@ instance ArrowReader r c => ArrowReader r (EnvT var addr val c) where
instance
(
ArrowApply
c
,
Profunctor
c
)
=>
ArrowApply
(
EnvT
var
addr
val
c
)
where
instance
(
ArrowApply
c
,
Profunctor
c
)
=>
ArrowApply
(
EnvT
var
addr
val
c
)
where
app
=
EnvT
(
app
.#
first
coerce
)
app
=
EnvT
(
app
.#
first
coerce
)
deriving
instance
ArrowFix
(
Dom
(
EnvT
var
addr
val
)
x
y
)
(
Cod
(
EnvT
var
addr
val
)
x
y
)
c
=>
ArrowFix
x
y
(
EnvT
var
addr
val
c
)
type
instance
Fix
(
EnvT
var
addr
val
c
)
x
y
=
EnvT
var
addr
val
(
Fix
c
(
Env
var
addr
val
,
x
)
y
)
deriving
instance
(
Arrow
c
,
Profunctor
c
,
ArrowFix
(
c
(
Env
var
addr
val
,
x
)
y
))
=>
ArrowFix
(
EnvT
var
addr
val
c
x
y
)
type
instance
Fix
x
y
(
EnvT
var
addr
val
c
)
=
EnvT
var
addr
val
(
Fix
(
Dom
(
EnvT
var
addr
val
)
x
y
)
(
Cod
(
EnvT
var
addr
val
)
x
y
)
c
)
lib/src/Control/Arrow/Transformer/Abstract/Completion.hs
View file @
41ab4f5f
...
@@ -43,8 +43,8 @@ runCompletionT = coerce
...
@@ -43,8 +43,8 @@ runCompletionT = coerce