Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
require
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AspectAG
require
Commits
f15f1102
Commit
f15f1102
authored
Apr 23, 2020
by
Juan Pablo Garcia Garland
Browse files
Options
Downloads
Patches
Plain Diff
Figure example
parent
5d5d7514
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Figures.lhs
+78
-0
78 additions, 0 deletions
src/Figures.lhs
with
78 additions
and
0 deletions
src/Figures.lhs
0 → 100644
+
78
−
0
View file @
f15f1102
> {-# LANGUAGE FlexibleInstances #-}
> {-# LANGUAGE GADTs #-}
> {-# LANGUAGE UndecidableInstances #-}
> {-# LANGUAGE TypeFamilies #-}
> {-# LANGUAGE MultiParamTypeClasses #-}
> {-# LANGUAGE TypeApplications #-}
>
module
Figures
where
>
import
Data.Type.Require
>
import
GHC.TypeLits
>
import
Data.Type.Bool
>
import
Data.Type.Equality
>
import
Data.Proxy
>
data
Color
=
RGB
Nat
Nat
Nat
>
type
instance
Equ
(
RGB
r
g
b
)
(
RGB
r'
g'
b'
)
>
=
r
==
r'
&&
g
==
g'
&&
b
==
b'
>
data
Dim
=
R2
|
R3
>
data
family
Figure
(
d
::
Dim
)
(
c
::
Color
)
>
data
instance
Figure
R2
c
>
=
Circle
Double
Double
Double
-- center, radius? not important
>
data
instance
Figure
R3
c
>
=
Sphere
Double
Double
Double
Double
>
combine
::
Figure
d
c
->
Figure
d
c
->
Figure
d
c
>
combine
f
g
=
undefined
combine (Circle 1 1 1) (Sphere 1 1 1 1) ->
• Couldn't match type ‘'R3’ with ‘'R2’
Expected type: Figure 'R2 c
Actual type: Figure 'R3 c
>
data
OpEqDim
(
d
::
Dim
)
(
d'
::
Dim
)
>
data
OpEqDim'
(
b
::
Bool
)
(
d
::
Dim
)
(
d'
::
Dim
)
>
data
OpEqCol
(
c
::
Color
)
(
c'
::
Color
)
>
data
OpEqCol'
(
b
::
Bool
)
(
c
::
Color
)
(
c'
::
Color
)
>
data
OpCombine
d
d'
c
c'
where
>
OpCombine
::
Figure
d
c
->
Figure
d'
c'
->
OpCombine
d
d'
c
c'
>
instance
>
(
Require
(
OpEqDim
d
d'
)
ctx
>
,
Require
(
OpEqCol
c
c'
)
ctx
>
)
>
=>
>
Require
(
OpCombine
d
d'
c
c'
)
ctx
where
>
type
ReqR
(
OpCombine
d
d'
c
c'
)
=
>
Figure
d
c
>
req
ctx
(
OpCombine
f
g
)
=
>
undefined
>
instance
>
Require
(
OpEqDim
d
d'
)
ctx
where
>
type
ReqR
(
OpEqDim
d
d'
)
=
ReqR
(
OpEqDim'
(
d
==
d'
)
d
d'
)
>
instance
Require
(
OpEqDim'
'True
d
d'
)
ctx
where
{}
>
>
instance
Require
(
OpEqCol
c
c'
)
ctx
where
{}
>
instance
Require
(
OpEqCol'
'True
c
c'
)
ctx
where
{}
>
instance
Require
(
OpEqCol'
'False
c
c'
)
ctx
where
{}
>
instance
>
Require
(
OpError
(
Text
"Dimensional error: cannot combine figure of dimension "
>
:<>:
ShowT
d
:<>:
Text
" and dimension "
:<>:
ShowT
d'
))
ctx
>
=>
Require
(
OpEqDim'
'False
d
d'
)
ctx
>
combine'
f
f'
=
req
(
Proxy
@
(
'
[
Text
"combining.."
]
))
(
OpCombine
f
f'
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment