1{-# LANGUAGE DeriveGeneric #-}
2{-# LANGUAGE DuplicateRecordFields #-}
3{-# LANGUAGE UndecidableInstances #-}
4{-# LANGUAGE TypeApplications #-}
5{-# LANGUAGE DataKinds #-}
6{-# LANGUAGE FlexibleContexts #-}
8-- Note: this file may contain spoilers
9-- (although I would be really surprised if it did, I haven't seen the films)
13import Data.Generics.Product
15data Episode = NEWHOPE | EMPIRE | JEDI
16 deriving (Generic, Show, Eq)
18data Character = Character
20 , friends :: [Character]
21 , appearsIn :: [Episode]
22 } deriving (Generic, Show, Eq)
26 , friends :: [Character]
27 , appearsIn :: [Episode]
28 , homePlanet :: String
29 } deriving (Generic, Show)
32 { friends :: [Character]
33 , appearsIn :: [Episode]
35 , primaryFunction :: String
36 } deriving (Generic, Show)
40 { name = "Luke Skywalker"
42 , appearsIn = [NEWHOPE, EMPIRE, JEDI]
43 , homePlanet = "Saturn (?)"
49 , friends = [upcast luke]
50 , appearsIn = [NEWHOPE, EMPIRE, JEDI]
51 , primaryFunction = "repair ships"
57 , friends = [upcast r2d2, upcast luke]
58 , appearsIn = [NEWHOPE, EMPIRE, JEDI]
59 , primaryFunction = "protocol and human relations"
62getName :: HasField "name" a r => r -> a
63getName = getField @"name"
65-- upcast :: Subtype a b => a -> b
66characters :: [Character]
67characters = [upcast r2d2, upcast luke, upcast c3po]
70names = map getName characters
71-- => ["R2-D2","Luke Skywalker","C3PO"]
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list