Skip to content
Snippets Groups Projects
Commit 4f55630e authored by Alice Brenon's avatar Alice Brenon
Browse files

Reverse associativity of '@': we want to enrich metadata on the right of...

Reverse associativity of '@': we want to enrich metadata on the right of lines, without having to explode existing structures. A paragraph with a class should be just that, and not an article combined to a paragraph number and a class: (Article @ Paragraph) @ Class, not Article @ (Paragraph @ Class)
parent 63f82c9f
No related branches found
No related tags found
No related merge requests found
...@@ -9,8 +9,8 @@ import Data.Aeson.KeyMap as Object (union) ...@@ -9,8 +9,8 @@ import Data.Aeson.KeyMap as Object (union)
import Data.Csv (FromNamedRecord(..), ToNamedRecord(..)) import Data.Csv (FromNamedRecord(..), ToNamedRecord(..))
import Data.HashMap.Strict as Hash (union) import Data.HashMap.Strict as Hash (union)
infixr 9 @ infixl 9 @
infixr 9 :@: infixl 9 :@:
data a @ b = a :@: b data a @ b = a :@: b
class Has a b where class Has a b where
...@@ -19,11 +19,11 @@ class Has a b where ...@@ -19,11 +19,11 @@ class Has a b where
instance Has a a where instance Has a a where
get = id get = id
instance Has a c => Has a (b @ c) where instance Has a b => Has a (b @ c) where
get (_ :@: c) = get c get (b :@: _) = get b
instance {-# OVERLAPS #-} Has a (a @ b) where instance {-# OVERLAPS #-} Has b (a @ b) where
get (a :@: _) = a get (_ :@: b) = b
instance (ToNamedRecord a, ToNamedRecord b) => ToNamedRecord (a @ b) where instance (ToNamedRecord a, ToNamedRecord b) => ToNamedRecord (a @ b) where
toNamedRecord (a :@: b) = Hash.union (toNamedRecord a) (toNamedRecord b) toNamedRecord (a :@: b) = Hash.union (toNamedRecord a) (toNamedRecord b)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment