Skip to content

Instantly share code, notes, and snippets.

@myme
Created November 5, 2018 20:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save myme/ef63e43ba92c8f5e87f4e77295331548 to your computer and use it in GitHub Desktop.
Save myme/ef63e43ba92c8f5e87f4e77295331548 to your computer and use it in GitHub Desktop.
module App.Diff.Entry where
import Prelude
import Data.Either (either)
import Data.Function.Uncurried (Fn2, mkFn2)
import Data.Maybe (Maybe(..))
import Data.Pair (fst, (~))
import Foreign (Foreign)
import App.Diff.Class (Diff, recordDiff)
import Simple.JSON (E, read, write)
type Entry = { id ∷ Int, val ∷ String }
type DiffEntry = { id ∷ Diff Int, val ∷ Diff String }
diff ∷ Entry → Entry → DiffEntry
diff = recordDiff
diffEntry ∷ Fn2 Foreign Foreign (Maybe DiffEntry)
diffEntry = mkFn2 $ \left right → do
let result = do
left' ← read left ∷ E Entry
right' ← read right ∷ E Entry
diff <$> left' <*> right'
either (const Nothing) (Just <<< fst) result
[1/1 TypesDoNotUnify] src/components/Diff/DiffEntry.purs:26:18
26 diff <$> left' <*> right'
^^^^^
Could not match type
( id :: Int
, val :: String
)
with type
{ id :: Int
, val :: String
}
while trying to match type { id :: Int
, val :: String
}
with type t0
{ id :: Int
, val :: String
}
while checking that expression left'
has type t0
{ id :: Int
, val :: String
}
in value declaration diffEntry
where t0 is an unknown type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment