Created
November 5, 2018 20:18
-
-
Save myme/ef63e43ba92c8f5e87f4e77295331548 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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